/** * Stripe Payment Element Types * * These types are inlined from @stripe/stripe-js to ensure consumers * get proper type definitions without needing to install Stripe separately. * * Source: @stripe/stripe-js v7.6.1 * - elements-group.d.ts (Appearance, StripeElementLocale) * - elements/payment.d.ts (StripePaymentElementOptions) */ /** * Locale configuration for internationalization support. * The IETF language tag of the locale to display placeholders and error strings in. * Default is 'auto' (Stripe detects the locale of the browser). */ export type PaymentElementLocale = 'auto' | 'ar' | 'bg' | 'cs' | 'da' | 'de' | 'el' | 'en' | 'en-AU' | 'en-CA' | 'en-NZ' | 'en-GB' | 'es' | 'es-ES' | 'es-419' | 'et' | 'fi' | 'fil' | 'fr' | 'fr-CA' | 'fr-FR' | 'he' | 'hu' | 'hr' | 'id' | 'it' | 'it-IT' | 'ja' | 'ko' | 'lt' | 'lv' | 'ms' | 'mt' | 'nb' | 'nl' | 'no' | 'pl' | 'pt' | 'pt-BR' | 'ro' | 'ru' | 'sk' | 'sl' | 'sv' | 'th' | 'tr' | 'vi' | 'zh' | 'zh-HK' | 'zh-TW'; /** * CSS font source - loads fonts from a CSS stylesheet URL. * Use this to load fonts from services like Google Fonts. * * @example * { cssSrc: 'https://fonts.googleapis.com/css?family=Open+Sans' } * * @docs https://stripe.com/docs/js/elements_object/create */ export type CssFontSource = { /** * The URL of a CSS stylesheet to load fonts from. */ cssSrc: string; }; /** * Custom font source - loads a specific font file directly. * Use this to load custom fonts from your own domain. * * @example * { * family: 'Avenir', * src: 'url(https://my-domain.com/assets/avenir.woff)', * weight: '500' * } * * @docs https://stripe.com/docs/js/elements_object/create */ export type CustomFontSource = { /** * A valid CSS font-family name. */ family: string; /** * The URL of the font file. This should be a publicly accessible URL. * Must be a valid CSS src value (e.g., 'url(https://...)'). */ src: string; /** * The font display property. Determines how a font face is displayed based on whether and when it is downloaded and ready to use. */ display?: string; /** * The font style. For example, 'normal', 'italic', or 'oblique'. */ style?: string; /** * The unicode range the font supports. */ unicodeRange?: string; /** * The font weight. For example, '400', 'normal', '500', '700', or 'bold'. */ weight?: string; }; /** * Font source for custom fonts in the Payment Element. * Allows you to load custom fonts using either CSS stylesheet or custom font files. * * @example * // Using CSS source (e.g., Google Fonts) * elementFonts={[ * { cssSrc: 'https://fonts.googleapis.com/css?family=Open+Sans' } * ]} * * @example * // Using custom font source * elementFonts={[{ * family: 'Avenir', * src: 'url(https://my-domain.com/assets/avenir.woff)', * weight: '500' * }]} * * @example * // Using both * elementFonts={[ * { cssSrc: 'https://fonts.googleapis.com/css?family=Roboto' }, * { * family: 'CustomFont', * src: 'url(https://example.com/fonts/custom.woff2)', * weight: '400' * } * ]} * * @docs https://stripe.com/docs/js/elements_object/create */ export type PaymentElementFonts = Array; /** * Appearance configuration for customizing the payment element's visual styling. * Match the Payment Element with the design of your site. * * @docs https://stripe.com/docs/stripe-js/appearance-api */ export type PaymentElementAppearance = { /** * Disable animations in the Payment Element. */ disableAnimations?: boolean; /** * Built-in theme to use as a base. */ theme?: 'stripe' | 'night' | 'flat'; /** * CSS variables to customize the appearance. */ variables?: { fontFamily?: string; fontSmooth?: string; fontVariantLigatures?: string; fontVariationSettings?: string; fontLineHeight?: string; fontSizeBase?: string; fontSizeSm?: string; fontSizeXs?: string; fontSize2Xs?: string; fontSize3Xs?: string; fontSizeLg?: string; fontSizeXl?: string; fontWeightLight?: string; fontWeightNormal?: string; fontWeightMedium?: string; fontWeightBold?: string; spacingUnit?: string; gridRowSpacing?: string; gridColumnSpacing?: string; tabSpacing?: string; accordionItemSpacing?: string; colorPrimary?: string; colorBackground?: string; colorText?: string; colorSuccess?: string; colorDanger?: string; colorWarning?: string; colorTextSecondary?: string; colorTextPlaceholder?: string; accessibleColorOnColorPrimary?: string; accessibleColorOnColorBackground?: string; accessibleColorOnColorSuccess?: string; accessibleColorOnColorDanger?: string; accessibleColorOnColorWarning?: string; iconColor?: string; iconHoverColor?: string; iconCardErrorColor?: string; iconCardCvcColor?: string; iconCardCvcErrorColor?: string; iconCheckmarkColor?: string; iconChevronDownColor?: string; iconChevronDownHoverColor?: string; iconCloseColor?: string; iconCloseHoverColor?: string; iconLoadingIndicatorColor?: string; iconMenuColor?: string; iconMenuHoverColor?: string; iconPasscodeDeviceColor?: string; iconPasscodeDeviceHoverColor?: string; iconPasscodeDeviceNotificationColor?: string; iconRedirectColor?: string; tabIconColor?: string; tabIconHoverColor?: string; tabIconSelectedColor?: string; tabIconMoreColor?: string; tabIconMoreHoverColor?: string; logoColor?: string; tabLogoColor?: string; tabLogoSelectedColor?: string; blockLogoColor?: string; focusBoxShadow?: string; focusOutline?: string; buttonBorderRadius?: string; borderRadius?: string; }; /** * CSS rules to customize individual elements. */ rules?: { [selector: string]: { [cssPropertyName: string]: string; }; }; /** * Label placement for form fields. */ labels?: 'above' | 'floating'; }; type CardNetworkBrand = 'accel' | 'amex' | 'carnet' | 'cartes_bancaires' | 'diners' | 'discover' | 'eftpos_au' | 'elo' | 'girocard' | 'interac' | 'jcb' | 'mastercard' | 'nyce' | 'pulse' | 'rupay' | 'star' | 'unionpay' | 'visa'; /** * Default values to pre-fill in the payment element. */ export type PaymentElementDefaultValues = { billingDetails?: { name?: string; email?: string; phone?: string; address?: { country?: string; postal_code?: string; state?: string; city?: string; line1?: string; line2?: string; }; }; card?: { network?: CardNetworkBrand[]; }; }; /** * Field display option. */ export type PaymentElementFieldOption = 'auto' | 'never'; /** * Control which fields are displayed in the Payment Element. */ export type PaymentElementFields = { billingDetails?: PaymentElementFieldOption | { name?: PaymentElementFieldOption; email?: PaymentElementFieldOption; phone?: PaymentElementFieldOption; address?: PaymentElementFieldOption | 'if_required' | { country?: PaymentElementFieldOption; postalCode?: PaymentElementFieldOption; state?: PaymentElementFieldOption; city?: PaymentElementFieldOption; line1?: PaymentElementFieldOption; line2?: PaymentElementFieldOption; }; }; }; /** * Term display option. */ export type PaymentElementTermOption = 'auto' | 'always' | 'never'; /** * Control terms display for different payment methods. */ export type PaymentElementTerms = { applePay?: PaymentElementTermOption; auBecsDebit?: PaymentElementTermOption; bancontact?: PaymentElementTermOption; card?: PaymentElementTermOption; cashapp?: PaymentElementTermOption; googlePay?: PaymentElementTermOption; ideal?: PaymentElementTermOption; paypal?: PaymentElementTermOption; sepaDebit?: PaymentElementTermOption; sofort?: PaymentElementTermOption; usBankAccount?: PaymentElementTermOption; }; /** * Wallet display option. */ export type PaymentElementWalletOption = 'auto' | 'never'; /** * Control wallet display in the Payment Element. */ export type PaymentElementWallets = { applePay?: PaymentElementWalletOption; googlePay?: PaymentElementWalletOption; link?: PaymentElementWalletOption; }; /** * Layout type for the Payment Element. */ export type PaymentElementLayout = 'tabs' | 'accordion' | 'auto'; /** * Layout configuration object for the Payment Element. */ export type PaymentElementLayoutObject = { type: PaymentElementLayout; defaultCollapsed?: boolean; radios?: boolean; spacedAccordionItems?: boolean; visibleAccordionItemsCount?: number; }; /** * Stripe Payment Element options for controlling payment form fields and behavior. * * @docs https://stripe.com/docs/js/elements_object/create_payment_element */ export type PaymentElementOptions = { /** * Provide initial customer information that will be displayed in the Payment Element. */ defaultValues?: PaymentElementDefaultValues; /** * Override the business name displayed in the Payment Element. * By default the PaymentElement will use your Stripe account or business name. */ business?: { name: string; }; /** * Override the order in which payment methods are displayed in the Payment Element. * By default, the Payment Element will use a dynamic ordering that optimizes payment method display for each user. */ paymentMethodOrder?: string[]; /** * Control which fields are displayed in the Payment Element. */ fields?: PaymentElementFields; /** * Apply a read-only state to the Payment Element so that payment details can't be changed. * Default is false. */ readOnly?: boolean; /** * Control terms display in the Payment Element. */ terms?: PaymentElementTerms; /** * Control wallets display in the Payment Element. */ wallets?: PaymentElementWallets; /** * Specify a layout to use when rendering a Payment Element. */ layout?: PaymentElementLayout | PaymentElementLayoutObject; }; export {};