## The Element Use `Element` instances to collect sensitive information in your checkout flow. ## The Payment Element The [Payment Element](/payments/payment-element.md) is an embeddable component for securely collecting payment details. The Payment Element supports dozens of payment methods with a single integration. ## Create the Payment Element This method creates an instance of the Payment Element. **Syntax:** `elements.create(...)` - `type` ('payment') **required** The type of Element being created, which is `payment` in this case. - `options` (object) Options for creating the Payment Element. - `layout` ('accordion' | 'tabs' | object) Specify the layout for the Payment Element. If you only pass a layout type (`'accordion'` or `‘tabs’`) without any additional parameters, the Payment Element renders using that layout and the default values associated with it. An object can also be passed to specify the layout with additional configuration. - `type` ('accordion' | 'tabs') **required** Defines the layout to render the Payment Element. - `defaultCollapsed` (boolean) Controls if the Payment Element renders in a collapsed state (where no payment method is selected by default). When you leave this `undefined`, Stripe renders the experience that it determines will have the best conversion. - `radios` ('always' | 'never' | 'if_multiple' | 'auto') Controls when to render each Payment Method with a radio input next to its logo. The radios visually indicate the current selection of the Payment Element. Defaults to `'auto'`. - `'always'` — Always show radio inputs. - `'never'` — Never show radio inputs. - `'if_multiple'` — Show radio inputs only when there are multiple payment methods available. When there is only one payment method, no radio input is displayed. - `'auto'` — Stripe determines the best experience to optimize conversion. _This property is only applicable to the `accordion` layout._ - `spacedAccordionItems` (boolean) When `true`, the Payment Methods render as standalone buttons with space in between them. _This property is only applicable to the `accordion` layout._ - `visibleAccordionItemsCount` (number) Sets the max number of Payment Methods visible before using the "More" button to hide additional Payment Methods. Set this value to `0` to disable the "More" button and render all available Payment Methods. Default is `5`. _This property is only applicable to the `accordion` layout._ - `paymentMethodLogoPosition` ('start' | 'end') Sets the position of the payment method logo in each accordion item. Default is `start`. _This property is only applicable to the `accordion` layout._ - `defaultValues` (object) Provide initial customer information that will be displayed in the Payment Element. The form will render with empty fields if not provided. - `billingDetails` (object) Specify customer's billing details, which lets you pre-fill a customer’s name, email, phone number and address if required by payment method. Pre-filling as much information as possible streamlines the checkout process. - `name` (string) - `email` (string) - `phone` (string) - `address` (object) - `line1` (string) - `line2` (string) - `city` (string) The name of a city, town, village, etc. - `state` (string) The most coarse subdivision of a country. Depending on the country, this might correspond to a state, a province, an oblast, a prefecture, or something else along these lines. - `country` (string) Two-letter country code, capitalized. Valid two-letter country codes are specified by ISO3166 alpha-2. - `postal_code` (string) The postal code or ZIP code, also known as PIN code in India. - `paymentMethods` (object) Specify customer's default information for different payment methods. Pre-filling as much information as possible streamlines the checkout process. - `ideal` (object) - `bank` (string) A pre-filled iDEAL bank value for the Payment Element. Can only be one of the banks listed in the [iDEAL guide](/payments/ideal/accept-a-payment?ui=element.md#bank-reference) (e.g., `abn_amro`). - `payto` (object) - `usePayId` (boolean) When `true`, the PayTo payment method will default to showing the PayID input instead of BSB/account number fields. Customers can still switch between PayID and BSB/account number using the toggle link. - `card` (object) Specify default settings for card payments. - `network` (array) Specifies a network preference for [Card Brand Choice](/card-brand-choice.md). The first network in the array that matches a network on the entered co-branded card will be selected by default in the Card Brand Choice dropdown. See the [supported networks](/api/payment_methods/create.md#create_payment_method-card-networks-preferred) for valid values. - `business` (object) Provide information about your business that will be displayed in the Payment Element. This information will be retrieved from your Stripe account if not provided. - `name` (string) The name of your business. Your business name will be used to render mandate text for some payment methods. - `paymentMethodOrder` (array) By default, the Payment Element will use a dynamic ordering that optimizes payment method display for each user. You can override the default order in which payment methods are displayed in the Payment Element with a list of payment method types. If the associated PaymentIntent has payment method types not specified in `paymentMethodOrder`, they will be displayed after the payment methods you specify. If you specify payment method types not on the associated PaymentIntent, they will be ignored. - `fields` (object) By default, the Payment Element will collect all necessary details to complete a payment. For some payment methods, this means that the Payment Element will collect details like name or email that you may have already collected from the user. If this is the case, you can prevent the Payment Element from collecting these data by using the `fields` option. If you disable the collection of a certain field with the `fields` option, you must pass that same data to [stripe.confirmPayment](/js/payment_intents/confirm_payment.md) or the payment will be rejected. Learn more about how to [customize which billing details to collect](/payments/payment-element/control-billing-details-collection.md) and see [below](/js/elements_object/create_payment_element.md#payment_element_create-customized_fields) for details. - `billingDetails` ('never' | 'auto' | object) Specify `never` to avoid collecting all [billing details](/api/payment_methods/object.md#payment_method_object-billing_details) in the Payment Element. If you would like to disable only certain billing details, pass an object specifying which fields you would like to disable collection for. The default setting for each field or object is `auto`. - `name` ('never' | 'auto') - `email` ('never' | 'auto') - `phone` ('never' | 'auto') - `address` ('never' | 'if_required' | 'auto' | object) Specify `if_required` to only collect the minimum billing address fields required to complete the payment. You can omit and hide optional address fields in the card form, such as country and postal code. Unlike the `never` option, you don't need to include fields omitted in the Payment Element when confirming the payment. This can reduce the amount of information required to complete the form. Disabling address collection can negatively impact authorization rates and network fees for users on a network cost plus pricing plan. - `line1` ('never' | 'auto') - `line2` ('never' | 'auto') - `city` ('never' | 'auto') The name of a city, town, village, etc. - `state` ('never' | 'auto') The most coarse subdivision of a country. Depending on the country, this might correspond to a state, a province, an oblast, a prefecture, or something else along these lines. - `country` ('never' | 'auto') Two-letter country code, capitalized. Valid two-letter country codes are specified by ISO3166 alpha-2. - `postalCode` ('never' | 'auto') The postal code or ZIP code, also known as PIN code in India. - `readOnly` (boolean) Applies a read-only state to the Payment Element so that payment details can’t be changed. Default is false. Enabling the `readOnly` option doesn't change the Payment Element's visual appearance. If you want to adjust the way the Payment Element looks, use the [Appearance API](/elements/appearance-api.md). - `terms` (object) Control how mandates or other legal agreements are displayed in the Payment Element. Use `never` to never display legal agreements. The default setting is `auto`, which causes legal agreements to only be shown when necessary. Consult your legal and compliance advisors before making any changes to the text of mandates or legal agreements. You can't use the `terms` option to violate obligations under your Stripe agreement, Stripe policies, applicable laws or scheme rules. - `applePay` ('auto' | 'always' | 'never') - `auBecsDebit` ('auto' | 'always' | 'never') - `bancontact` ('auto' | 'always' | 'never') - `card` ('auto' | 'always' | 'never') - `cashapp` ('auto' | 'always' | 'never') - `googlePay` ('auto' | 'always' | 'never') - `ideal` ('auto' | 'always' | 'never') - `paypal` ('auto' | 'always' | 'never') - `sepaDebit` ('auto' | 'always' | 'never') - `sofort` ('auto' | 'always' | 'never') - `usBankAccount` ('auto' | 'always' | 'never') - `wallets` (object) By default, the Payment Element will display all the payment methods that the underlying Payment Intent was created with. However, wallets like Apple Pay and Google Pay are not payment methods per the Payment Intent API. They will show when the Payment Intent has the `card` payment method and the customer is using a supported platform and have an active card in their account. This is the `auto` behavior, and it is the default for choice for all wallets. If you do not want to show a given wallet as a payment option, you can set its property in `wallets` to `never`. - `applePay` ('auto' | 'never') - `googlePay` ('auto' | 'never') - `link` ('auto' | 'never') - `applePay` (object) Specify Apple Pay specific options. These are passed through to the Apple Pay API. - `recurringPaymentRequest` (object) Specify a request to set up a recurring payment. See the [Apple Pay documentation](https://developer.apple.com/documentation/apple_pay_on_the_web/applepayrecurringpaymentrequest) for more details. - `paymentDescription` (string) **required** - `managementURL` (string) **required** - `regularBilling` (object) **required** - `amount` (number) **required** - `label` (string) **required** - `recurringPaymentStartDate` (Date) - `recurringPaymentEndDate` (Date) - `recurringPaymentIntervalUnit` ('year' | 'month' | 'day' | 'hour' | 'minute') - `recurringPaymentIntervalCount` (number) - `trialBilling` (object) - `amount` (number) **required** - `label` (string) **required** - `recurringPaymentStartDate` (Date) - `recurringPaymentEndDate` (Date) - `recurringPaymentIntervalUnit` ('year' | 'month' | 'day' | 'hour' | 'minute') - `recurringPaymentIntervalCount` (number) - `billingAgreement` (string) - `deferredPaymentRequest` (object) Specify a request to set up a deferred payment. See the [Apple Pay documentation](https://developer.apple.com/documentation/apple_pay_on_the_web/applepaydeferredpaymentrequest) for more details. - `paymentDescription` (string) **required** - `managementURL` (string) **required** - `deferredBilling` (object) **required** - `amount` (number) **required** - `label` (string) **required** - `deferredPaymentDate` (Date) **required** - `billingAgreement` (string) - `freeCancellationDate` (Date) If set, you must also supply a freeCancellationDateTimeZone., - `freeCancellationDateTimeZone` (string) "If set, you must also supply a freeCancellationDate., - `automaticReloadPaymentRequest` (object) Specify a request to set up an automatic reload payment. See the [Apple Pay documentation](https://developer.apple.com/documentation/apple_pay_on_the_web/applepayautomaticreloadpaymentrequest) for more details. - `paymentDescription` (string) **required** - `managementURL` (string) **required** - `automaticReloadBilling` (object) **required** - `amount` (number) **required** - `label` (string) **required** - `automaticReloadPaymentThresholdAmount` (Date) **required** - `billingAgreement` (string) ### Use case: with customized fields ### Option parameter - `fields` (object) Pass an object to specify payment `fields` you don't want to collect with the Payment Element. - `billingDetails` ('never' | 'auto' | object) Specify `never` to avoid collecting all [billing details](/api/payment_methods/object.md#payment_method_object-billing_details) in the Payment Element. If you would like to disable only certain billing details, pass an object specifying which fields you would like to disable collection for. The default setting for each field or object is `auto`. - `name` ('never' | 'auto') - `email` ('never' | 'auto') - `phone` ('never' | 'auto') - `address` ('never' | 'if_required' | 'auto' | object) Specify `if_required` to only collect the minimum billing address fields required to complete the payment. You can omit and hide optional address fields in the card form, such as country and postal code. Unlike the `never` option, you don't need to include fields omitted in the Payment Element when confirming the payment. This can reduce the amount of information required to complete the form. Disabling address collection can negatively impact authorization rates and network fees for users on a network cost plus pricing plan. - `line1` ('never' | 'auto') - `line2` ('never' | 'auto') - `city` ('never' | 'auto') The name of a city, town, village, etc. - `state` ('never' | 'auto') The most coarse subdivision of a country. Depending on the country, this might correspond to a state, a province, an oblast, a prefecture, or something else along these lines. - `country` ('never' | 'auto') Two-letter country code, capitalized. Valid two-letter country codes are specified by ISO3166 alpha-2. - `postalCode` ('never' | 'auto') The postal code or ZIP code, also known as PIN code in India. ### Create a Payment Element with customized fields ```js // Customize which fields are collected by the Payment Element var paymentElement = elements.create('payment', { fields: { billingDetails: { name: 'never', email: 'never', } } }); // If you disable collecting fields in the Payment Element, you // must pass equivalent data when calling `stripe.confirmPayment`. form.addEventListener('submit', async (event) => { stripe.confirmPayment({ elements, confirmParams: { return_url: 'https://example.com', payment_method_data: { billing_details: { name: 'Jenny Rosen', email: 'jenny.rosen@example.com', } }, }, }) .then(function(result) { if (result.error) { // Inform the customer that there was an error. } }); }); ``` ```es_next // Customize which fields are collected by the Payment Element const paymentElement = elements.create('payment', { fields: { billingDetails: { name: 'never', email: 'never', } } }); // If you disable collecting fields in the Payment Element, you // must pass equivalent data when calling `stripe.confirmPayment`. const handleSubmit = async () => { const {error} = await stripe.confirmPayment({ elements, confirmParams: { return_url: 'https://example.com/return', payment_method_data: { billing_details: { name: 'Jenny Rosen', email: 'jenny.rosen@example.com', } }, }, }); // Other actions ... }; ``` ### Create a Payment Element ```js var paymentElement = elements.create('payment'); ``` ```es_next const paymentElement = elements.create('payment'); ``` ## Get a Payment Element This method retrieves a previously created Payment Element. `elements.getElement('payment')` returns one of the following: * An instance of a Payment Element. * `null`, when no Payment Element has been created. **Syntax:** `elements.getElement(...)` - `type` ('payment') **required** The type of Element being retrieved, which is `payment` in this case. ### Get a Payment Element ```js var paymentElement = elements.getElement('payment'); ``` ```es_next const paymentElement = elements.getElement('payment'); ``` ## Update a Payment Element Updates the options the [Payment Element](/js/element/payment_element.md) was initialized with. Updates are merged into the existing configuration with a shallow merge. **NOTE**: Don't use `element.update()` to fetch updates from a [PaymentIntent](/api/payment_intents.md) or [SetupIntent](/api/setup_intents.md). Use [elements.fetchUpdates()](/js/elements_object/fetch_updates.md) instead. **Syntax:** `element.update(...)` - `options` (object) Options for updating the Payment Element. - `defaultValues` (object) Provide initial customer information that will be displayed in the Payment Element. The form will render with empty fields if not provided. - `billingDetails` (object) Specify customer's billing details, which lets you pre-fill a customer’s name, email, phone number and address if required by payment method. Pre-filling as much information as possible streamlines the checkout process. - `name` (string) - `email` (string) - `phone` (string) - `address` (object) - `line1` (string) - `line2` (string) - `city` (string) The name of a city, town, village, etc. - `state` (string) The most coarse subdivision of a country. Depending on the country, this might correspond to a state, a province, an oblast, a prefecture, or something else along these lines. - `country` (string) Two-letter country code, capitalized. Valid two-letter country codes are specified by ISO3166 alpha-2. - `postal_code` (string) The postal code or ZIP code, also known as PIN code in India. - `paymentMethods` (object) Specify customer's default information for different payment methods. Pre-filling as much information as possible streamlines the checkout process. - `ideal` (object) - `bank` (string) A pre-filled iDEAL bank value for the Payment Element. Can only be one of the banks listed in the [iDEAL guide](/payments/ideal/accept-a-payment?ui=element.md#bank-reference) (e.g., `abn_amro`). - `payto` (object) - `usePayId` (boolean) When `true`, the PayTo payment method will default to showing the PayID input instead of BSB/account number fields. Customers can still switch between PayID and BSB/account number using the toggle link. - `card` (object) Specify default settings for card payments. - `network` (array) Specifies a network preference for [Card Brand Choice](/card-brand-choice.md). The first network in the array that matches a network on the entered co-branded card will be selected by default in the Card Brand Choice dropdown. See the [supported networks](/api/payment_methods/create.md#create_payment_method-card-networks-preferred) for valid values. - `business` (object) Provide information about your business that will be displayed in the Payment Element. This information will be retrieved from your Stripe account if not provided. - `name` (string) The name of your business. Your business name will be used to render mandate text for some payment methods. - `paymentMethodOrder` (array) By default, the Payment Element will use a dynamic ordering that optimizes payment method display for each user. You can override the default order in which payment methods are displayed in the Payment Element with a list of payment method types. If the associated PaymentIntent has payment method types not specified in `paymentMethodOrder`, they will be displayed after the payment methods you specify. If you specify payment method types not on the associated PaymentIntent, they will be ignored. - `fields` (object) By default, the Payment Element will collect all necessary details to complete a payment. For some payment methods, this means that the Payment Element will collect details like name or email that you may have already collected from the user. If this is the case, you can prevent the Payment Element from collecting these data by using the `fields` option. If you disable the collection of a certain field with the `fields` option, you must pass that same data to [stripe.confirmPayment](/js/payment_intents/confirm_payment.md) or the payment will be rejected. Learn more about how to [customize which billing details to collect](/payments/payment-element/control-billing-details-collection.md) and see [below](/js/elements_object/create_payment_element.md#payment_element_create-customized_fields) for details. - `billingDetails` ('never' | 'auto' | object) Specify `never` to avoid collecting all [billing details](/api/payment_methods/object.md#payment_method_object-billing_details) in the Payment Element. If you would like to disable only certain billing details, pass an object specifying which fields you would like to disable collection for. The default setting for each field or object is `auto`. - `name` ('never' | 'auto') - `email` ('never' | 'auto') - `phone` ('never' | 'auto') - `address` ('never' | 'if_required' | 'auto' | object) Specify `if_required` to only collect the minimum billing address fields required to complete the payment. You can omit and hide optional address fields in the card form, such as country and postal code. Unlike the `never` option, you don't need to include fields omitted in the Payment Element when confirming the payment. This can reduce the amount of information required to complete the form. Disabling address collection can negatively impact authorization rates and network fees for users on a network cost plus pricing plan. - `line1` ('never' | 'auto') - `line2` ('never' | 'auto') - `city` ('never' | 'auto') The name of a city, town, village, etc. - `state` ('never' | 'auto') The most coarse subdivision of a country. Depending on the country, this might correspond to a state, a province, an oblast, a prefecture, or something else along these lines. - `country` ('never' | 'auto') Two-letter country code, capitalized. Valid two-letter country codes are specified by ISO3166 alpha-2. - `postalCode` ('never' | 'auto') The postal code or ZIP code, also known as PIN code in India. - `readOnly` (boolean) Applies a read-only state to the Payment Element so that payment details can’t be changed. Default is false. Enabling the `readOnly` option doesn't change the Payment Element's visual appearance. If you want to adjust the way the Payment Element looks, use the [Appearance API](/elements/appearance-api.md). - `terms` (object) Control how mandates or other legal agreements are displayed in the Payment Element. Use `never` to never display legal agreements. The default setting is `auto`, which causes legal agreements to only be shown when necessary. Consult your legal and compliance advisors before making any changes to the text of mandates or legal agreements. You can't use the `terms` option to violate obligations under your Stripe agreement, Stripe policies, applicable laws or scheme rules. - `applePay` ('auto' | 'always' | 'never') - `auBecsDebit` ('auto' | 'always' | 'never') - `bancontact` ('auto' | 'always' | 'never') - `card` ('auto' | 'always' | 'never') - `cashapp` ('auto' | 'always' | 'never') - `googlePay` ('auto' | 'always' | 'never') - `ideal` ('auto' | 'always' | 'never') - `paypal` ('auto' | 'always' | 'never') - `sepaDebit` ('auto' | 'always' | 'never') - `sofort` ('auto' | 'always' | 'never') - `usBankAccount` ('auto' | 'always' | 'never') - `applePay` (object) Specify Apple Pay specific options. These are passed through to the Apple Pay API. - `recurringPaymentRequest` (object) Specify a request to set up a recurring payment. See the [Apple Pay documentation](https://developer.apple.com/documentation/apple_pay_on_the_web/applepayrecurringpaymentrequest) for more details. - `paymentDescription` (string) **required** - `managementURL` (string) **required** - `regularBilling` (object) **required** - `amount` (number) **required** - `label` (string) **required** - `recurringPaymentStartDate` (Date) - `recurringPaymentEndDate` (Date) - `recurringPaymentIntervalUnit` ('year' | 'month' | 'day' | 'hour' | 'minute') - `recurringPaymentIntervalCount` (number) - `trialBilling` (object) - `amount` (number) **required** - `label` (string) **required** - `recurringPaymentStartDate` (Date) - `recurringPaymentEndDate` (Date) - `recurringPaymentIntervalUnit` ('year' | 'month' | 'day' | 'hour' | 'minute') - `recurringPaymentIntervalCount` (number) - `billingAgreement` (string) - `deferredPaymentRequest` (object) Specify a request to set up a deferred payment. See the [Apple Pay documentation](https://developer.apple.com/documentation/apple_pay_on_the_web/applepaydeferredpaymentrequest) for more details. - `paymentDescription` (string) **required** - `managementURL` (string) **required** - `deferredBilling` (object) **required** - `amount` (number) **required** - `label` (string) **required** - `deferredPaymentDate` (Date) **required** - `billingAgreement` (string) - `freeCancellationDate` (Date) If set, you must also supply a freeCancellationDateTimeZone. - `freeCancellationDateTimeZone` (string) If set, you must also supply a freeCancellationDate. These are [tz](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) timezones such as `America/Los_Angeles`, `Europe/Dublin`, and `Asia/Singapore`. - `automaticReloadPaymentRequest` (object) Specify a request to set up an automatic reload payment. See the [Apple Pay documentation](https://developer.apple.com/documentation/apple_pay_on_the_web/applepayautomaticreloadpaymentrequest) for more details. - `paymentDescription` (string) **required** - `managementURL` (string) **required** - `automaticReloadBilling` (object) **required** - `amount` (number) **required** - `label` (string) **required** - `automaticReloadPaymentThresholdAmount` (number) **required** - `billingAgreement` (string) ### Update a Payment Element ```js // Create a Payment Element with customized fields var paymentElement = elements.create('payment', { business: { name: 'Stripe Shop' }, defaultValues: { billingDetails: { name: 'Jenny Rosen', } } }); // Update with modified defaultValues paymentElement.update({ defaultValues: { billingDetails: { email: 'john.smith@example.com', phone: '5554242424', } } }); // In the resulting options, business remains the same, // while defaultValues is overwritten with the updated value // // { // business: { name: 'Stripe Shop' }, // defaultValues: { // billingDetails: { // email: 'john.smith@example.com', // phone: '5554242424', // } // } ``` ```es_next // Create a Payment Element with customized fields const paymentElement = elements.getElement('payment', { business: { name: 'Stripe Shop' }, defaultValues: { billingDetails: { name: 'Jenny Rosen', } } }); // Update with modified defaultValues paymentElement.update({ defaultValues: { billingDetails: { email: 'john.smith@example.com', phone: '5554242424', } } }); // In the resulting options, business remains the same, // while defaultValues is overwritten with the updated value // // { // business: { name: 'Stripe Shop' }, // defaultValues: { // billingDetails: { // email: 'john.smith@example.com', // phone: '5554242424', // } // } ``` ## Fetch Server Updates Used with the [Payment Element](/payments/payment-element.md). This method fetches updates from the associated [PaymentIntent](/api/payment_intents.md) or [SetupIntent](/api/setup_intents.md) on an existing instance of `Elements`, and reflects these updates in the Payment Element. This method returns a `Promise` which resolves with a result object. If this method succeeds, the result object will be empty. If this method fails, the result object will contain a localized error message in the `error.message` field. If the associated [PaymentIntent](/api/payment_intents) or [SetupIntent](/api/setup_intents) is in an unexpected status, the result object will also contain the intent's status in the `error.status` field. **Syntax:** `elements.fetchUpdates(...)` ### Fetch Server Updates ```js elements.fetchUpdates() .then(function(result) { // Handle result.error }); ``` ```es_next const {error} = await elements.fetchUpdates(); ``` ## Collapse a Payment Element This method collapses the Payment Element into a row of payment method tabs. **Syntax:** `element.collapse(...)` ### Collapse a Payment Element ```js // Collapse a Payment Element var paymentElement = elements.getElement('payment'); paymentElement.collapse(); ``` ```es_next // Collapse a Payment Element const paymentElement = elements.getElement('payment'); paymentElement.collapse(); ``` ## The Express Checkout Element The Express Checkout Element is an embeddable component for accepting payments through one-click payment buttons. ## Create the Express Checkout Element This method creates an instance of the Express Checkout Element. **Syntax:** `elements.create(...)` - `type` ('expressCheckout') **required** The type of Element being created, which is `expressCheckout` in this case. - `options` (object) Options for creating the Express Checkout Element. - `allowedShippingCountries` (array) By default, the Express Checkout Element allows all countries for shipping. You can specify which countries are allowed for shipping in the Express Checkout Element with a list of two-letter country codes. - `applePay` (object) Specify Apple Pay specific options. These are passed through to the Apple Pay API. - `recurringPaymentRequest` (object) Specify a request to set up a recurring payment. See the [Apple Pay documentation](https://developer.apple.com/documentation/apple_pay_on_the_web/applepayrecurringpaymentrequest) for more details. - `paymentDescription` (string) **required** - `managementURL` (string) **required** - `regularBilling` (object) **required** - `amount` (number) **required** - `label` (string) **required** - `recurringPaymentStartDate` (Date) - `recurringPaymentEndDate` (Date) - `recurringPaymentIntervalUnit` ('year' | 'month' | 'day' | 'hour' | 'minute') - `recurringPaymentIntervalCount` (number) - `trialBilling` (object) - `amount` (number) **required** - `label` (string) **required** - `recurringPaymentStartDate` (Date) - `recurringPaymentEndDate` (Date) - `recurringPaymentIntervalUnit` ('year' | 'month' | 'day' | 'hour' | 'minute') - `recurringPaymentIntervalCount` (number) - `billingAgreement` (string) - `deferredPaymentRequest` (object) Specify a request to set up a deferred payment. See the [Apple Pay documentation](https://developer.apple.com/documentation/apple_pay_on_the_web/applepaydeferredpaymentrequest) for more details. - `paymentDescription` (string) **required** - `managementURL` (string) **required** - `deferredBilling` (object) **required** - `amount` (number) **required** - `label` (string) **required** - `deferredPaymentDate` (Date) **required** - `billingAgreement` (string) - `freeCancellationDate` (Date) If set, you must also supply a freeCancellationDateTimeZone. - `freeCancellationDateTimeZone` (string) If set, you must also supply a freeCancellationDate. These are [tz](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) timezones such as `America/Los_Angeles`, `Europe/Dublin`, and `Asia/Singapore`. - `automaticReloadPaymentRequest` (object) Specify a request to set up an automatic reload payment. See the [Apple Pay documentation](https://developer.apple.com/documentation/apple_pay_on_the_web/applepayautomaticreloadpaymentrequest) for more details. - `paymentDescription` (string) **required** - `managementURL` (string) **required** - `automaticReloadBilling` (object) **required** - `amount` (number) **required** - `label` (string) **required** - `automaticReloadPaymentThresholdAmount` (number) **required** - `billingAgreement` (string) - `billingAddressRequired` (boolean) Controls whether the Express Checkout Element collects the billing address. The default value depends on your integration: - If you pass `allowedShippingCountries`, `phoneNumberRequired`, `shippingAddressRequired`, `emailRequired`, `applePay`, `lineItems`, or `business` when creating the Express Checkout Element, `billingAddressRequired` defaults to false. - Otherwise, `billingAddressRequired` defaults to true. You can explicitly set `billingAddressRequired` to true or false to override the default behavior. We highly recommend that you collect the billing address because it can be used to perform address verifications and block fraudulent payments. - `business` (object) Provide information about your business that's displayed in the Express Checkout Element. This information will be retrieved from your Stripe account if it's not provided. - `name` (string) The name of your business. Your business name is used to signal to the customer who they're paying. Klarna always retrieves the business name from your Stripe account, even when this option is set. - `buttonHeight` (number) By default, the height of the buttons are 44px. You can override this to specify a custom button height in the range of 40px-55px. - `buttonTheme` (object) Specify the preferred button theme to use. By default, Elements determines the themes based on the specified [appearance option](/js/elements_object/create.md#stripe_elements-options-appearance). - `applePay` ('black' | 'white' | 'white-outline') - `googlePay` ('black' | 'white') - `paypal` ('gold' | 'blue' | 'silver' | 'white' | 'black') - `klarna` ('dark' | 'light' | 'outlined') - `buttonType` (object) Specify the preferred button type to display. - `applePay` ('add-money' | 'book' | 'buy' | 'check-out' | 'contribute' | 'donate' | 'order' | 'plain' | 'reload' | 'rent' | 'subscribe' | 'support' | 'tip' | 'top-up') Default is `plain`. - `googlePay` ('book' | 'buy' | 'checkout' | 'donate' | 'order' | 'pay' | 'plain' | 'subscribe') Default is `buy`. - `paypal` ('paypal' | 'checkout' | 'buynow' | 'pay') Default is `paypal`. - `klarna` ('continue' | 'pay') Default is `pay`. - `emailRequired` (boolean) Collect the customer's email by setting this option to `true`. - `layout` (object) Specify how the buttons are arranged in a grid-like layout in the Express Checkout Element. Elements determines the layout by using certain factors, such as available space, number of buttons, and the defined `layout` object. - `maxColumns` (number) Defines the maximum number of columns the Express Checkout Element can use to render. Default is `0`, meaning unlimited. - `maxRows` (number) Defines the maximum number of rows the Express Checkout Element can use to render. Default is `0`, meaning unlimited. - `overflow` ('auto' | 'never') Specify whether or not to always hide the overflow menu or allow Elements to determine when to show the overflow menu. Default is `auto`. You can't specify both `overflow: 'never'` and set `maxRows` to a number greater than 0. - `lineItems` (array) An array of LineItem objects. These LineItems are shown as line items in the payment interface, if line items are supported. You can represent discounts as negative amount LineItems. - `name` (string) **required** The name of the line item surfaced to the customer in the payment interface. - `amount` (number) **required** The amount in the currency's subunit (for example, cents, yen, etc.). - `paymentMethods` (object) By default, the Express Checkout Element displays all payment methods possible as a result of your Dashboard configuration. This is the `auto` behavior. If you don't want to show a given payment method as a payment option, set its property in `paymentMethods` to `never`. - `amazonPay` ('auto' | 'never') - `applePay` ('always' | 'auto' | 'never') Apple Pay has additional configurations that determine when Stripe can show it. By default, Apple Pay shows when the customer is using a supported platform and when we determine it's advantageous for your conversion. This is the `auto` behavior. If you want to always show Apple Pay when the customer is using a supported platform, you can set its property in `paymentMethods` to `always`. This causes Apple Pay to be shown in supported browsers even when the customer isn't logged in to Apple Pay, resulting in a sign-in flow. Apple Pay on desktop Chromium browsers is only supported on MacOS when its property in `paymentMethods` is set to `always`. - `googlePay` ('always' | 'auto' | 'never') Google Pay has additional configurations that determine when Stripe can show it. By default, Google Pay shows when the customer is using a supported platform and when we determine it's advantageous for your conversion. This is the `auto` behavior. If you want to always show Google Pay when the customer is using a supported platform, you can set its property in `paymentMethods` to `always`. This causes Google Pay to be shown in supported browsers even when the customer isn't logged in to Google Pay, resulting in a sign-in flow. - `link` ('auto' | 'never') - `paypal` ('auto' | 'never') - `klarna` ('auto' | 'never') - `paymentMethodOrder` (array) By default, the Express Checkout Element uses a dynamic ordering that optimizes payment method display for each user. You can override the default order in which payment methods display in the Express Checkout Element with a list of payment method types. If there are payment methods that will show that are not specified in `paymentMethodOrder`, they display after the payment methods you specify. If you specify payment methods that will not show, they are ignored. - `phoneNumberRequired` (boolean) Collect the customer's phone number by setting this option to `true`. PayPal doesn't provide a phone number, even when this option is set to `true`. Google Pay makes a best effort to return the phone number registered to the wallet, but doesn't guarantee it will be provided in all cases. - `shippingAddressRequired` (boolean) Collect the customer's shipping address by setting this option to `true`. If `true`, you must also supply a valid `shippingRates` option in either the `create`, `click`, or `shippingaddresschange` events. - `shippingRates` (array) An array of ShippingRate objects. The first shipping rate listed appears in the payment interface as the default option. - `id` (string) **required** Unique identifier for the object. - `amount` (number) **required** The amount to charge for shipping. - `displayName` (string) **required** The name of the shipping rate, displayed to the customer in the payment interface. - `deliveryEstimate` (object | string) The estimated range for how long shipping takes, displayed to the customer in the payment interface. We recommended using the object format, but you can use a string instead. - `maximum` (object) The upper bound of the estimated range. If empty, it represents no upper bound (for example, infinite). - `unit` ('hour' | 'day' | 'business_day' | 'week' | 'month') A unit of time. - `value` (number) Must be greater than 0. - `minimum` (object) The lower bound of the estimated range. If empty, it represents no lower bound. - `unit` ('hour' | 'day' | 'business_day' | 'week' | 'month') A unit of time. - `value` (number) Must be greater than 0. ### Create an Express Checkout Element ```js var expressCheckoutElement = elements.create('expressCheckout'); ``` ```es_next const expressCheckoutElement = elements.create('expressCheckout'); ``` ## Get an Express Checkout Element This method retrieves a previously created Express Checkout Element. `elements.getElement('expressCheckout')` returns one of the following: * An instance of an Express Checkout Element. * `null`, when no Express Checkout Element has been created. **Syntax:** `elements.getElement(...)` - `type` ('expressCheckout') **required** The type of Element being retrieved, which is `expressCheckout` in this case. ### Get an Express Checkout Element ```js var expressCheckoutElement = elements.getElement('expressCheckout'); ``` ```es_next const expressCheckoutElement = elements.getElement('expressCheckout'); ``` ## Update an Express Checkout Element Updates the options the [Express Checkout Element](/js/element/express_checkout_element.md) was initialized with. Updates merge into the existing configuration. **Syntax:** `element.update(...)` - `options` (object) Options for updating the Express Checkout Element. - `allowedShippingCountries` (array) By default, the Express Checkout Element allows all countries for shipping. You can specify which countries are allowed for shipping in the Express Checkout Element with a list of two-letter country codes. - `billingAddressRequired` (boolean) Controls whether the Express Checkout Element collects the billing address. The default value depends on your integration: - If you pass `allowedShippingCountries`, `phoneNumberRequired`, `shippingAddressRequired`, `emailRequired`, `applePay`, `lineItems`, or `business` when creating the Express Checkout Element, `billingAddressRequired` defaults to false. - Otherwise, `billingAddressRequired` defaults to true. You can explicitly set `billingAddressRequired` to true or false to override the default behavior. We highly recommend that you collect the billing address because it can be used to perform address verifications and block fraudulent payments. - `emailRequired` (boolean) Collect the customer's email by setting this option to `true`. - `layout` (object) Specify how the buttons are arranged in a grid-like layout in the Express Checkout Element. Elements determines the layout by using certain factors, such as available space, number of buttons, and the defined `layout` object. - `maxColumns` (number) Defines the maximum number of columns the Express Checkout Element can use to render. Default is `0`, meaning unlimited. - `maxRows` (number) Defines the maximum number of rows the Express Checkout Element can use to render. Default is `0`, meaning unlimited. - `overflow` ('auto' | 'never') Specify whether or not to always hide the overflow menu or allow Elements to determine when to show the overflow menu. Default is `auto`. You can't specify both `overflow: 'never'` and set `maxRows` to a number greater than 0. - `paymentMethodOrder` (array) By default, the Express Checkout Element uses a dynamic ordering that optimizes payment method display for each user. You can override the default order in which payment methods display in the Express Checkout Element with a list of payment method types. If there are payment methods that will show that are not specified in `paymentMethodOrder`, they display after the payment methods you specify. If you specify payment methods that will not show, they are ignored. - `phoneNumberRequired` (boolean) Collect the customer's phone number by setting this option to `true`. PayPal doesn't provide a phone number, even when this option is set to `true`. Google Pay makes a best effort to return the phone number registered to the wallet, but doesn't guarantee it will be provided in all cases. - `shippingAddressRequired` (boolean) Collect the customer's shipping address by setting this option to `true`. If `true`, you must also supply a valid `shippingRates` option in either the `create`, `click`, or `shippingaddresschange` events. ### Update an Express Checkout Element ```js var expressCheckoutElement = elements.getElement('expressCheckout'); expressCheckoutElement.update({ layout: { maxColumns: 2, overflow: 'auto', }, }); ``` ```es_next const expressCheckoutElement = elements.getElement('expressCheckout'); expressCheckoutElement.update({ layout: { maxColumns: 2, overflow: 'auto', }, }); ``` ## Click event The `click` event is triggered from an Express Checkout Element when the customer clicks a payment button. Use this event to configure the payment interface. **Syntax:** `expressCheckoutElement.on(...)` - `event` ('click') **required** The name of the event. In this case, `click`. - `handler` (function) **required** `handler(event) => void` is a **callback function** you provide that's called after the event is fired. After it's called, it passes an event object with the following properties: - `elementType` ('expressCheckout') **required** The type of element the event is fired from, which is `expressCheckout` in this case. - `expressPaymentType` ('apple_pay' | 'google_pay' | 'amazon_pay' | 'paypal' | 'link' | 'klarna') **required** The payment method the customer checks out with. - `resolve` (function) **required** A function `resolve(payload) => void` that's called to show the payment interface. You must call this function within 1 second if you handle the `click` event. - `allowedShippingCountries (deprecated)` (array) _This parameter has been deprecated in favor of the `allowedShippingCountries` param on the [create](/js/elements_object/create_express_checkout_element.md#express_checkout_element_create-options-allowedShippingCountries) function._ By default, the Express Checkout Element allows all countries for shipping. You can specify which countries are allowed for shipping in the Express Checkout Element with a list of two-letter country codes. - `applePay` (object) Specify Apple Pay specific options. These are passed through to the Apple Pay API. - `recurringPaymentRequest` (object) Specify a request to set up a recurring payment. See the [Apple Pay documentation](https://developer.apple.com/documentation/apple_pay_on_the_web/applepayrecurringpaymentrequest) for more details. - `paymentDescription` (string) **required** - `managementURL` (string) **required** - `regularBilling` (object) **required** - `amount` (number) **required** - `label` (string) **required** - `recurringPaymentStartDate` (Date) - `recurringPaymentEndDate` (Date) - `recurringPaymentIntervalUnit` ('year' | 'month' | 'day' | 'hour' | 'minute') - `recurringPaymentIntervalCount` (number) - `trialBilling` (object) - `amount` (number) **required** - `label` (string) **required** - `recurringPaymentStartDate` (Date) - `recurringPaymentEndDate` (Date) - `recurringPaymentIntervalUnit` ('year' | 'month' | 'day' | 'hour' | 'minute') - `recurringPaymentIntervalCount` (number) - `billingAgreement` (string) - `deferredPaymentRequest` (object) Specify a request to set up a deferred payment. See the [Apple Pay documentation](https://developer.apple.com/documentation/apple_pay_on_the_web/applepaydeferredpaymentrequest) for more details. - `paymentDescription` (string) **required** - `managementURL` (string) **required** - `deferredBilling` (object) **required** - `amount` (number) **required** - `label` (string) **required** - `deferredPaymentDate` (Date) **required** - `billingAgreement` (string) - `freeCancellationDate` (Date) If set, you must also supply a freeCancellationDateTimeZone. - `freeCancellationDateTimeZone` (string) If set, you must also supply a freeCancellationDate. These are [tz](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) timezones such as `America/Los_Angeles`, `Europe/Dublin`, and `Asia/Singapore`. - `automaticReloadPaymentRequest` (object) Specify a request to set up an automatic reload payment. See the [Apple Pay documentation](https://developer.apple.com/documentation/apple_pay_on_the_web/applepayautomaticreloadpaymentrequest) for more details. - `paymentDescription` (string) **required** - `managementURL` (string) **required** - `automaticReloadBilling` (object) **required** - `amount` (number) **required** - `label` (string) **required** - `automaticReloadPaymentThresholdAmount` (number) **required** - `billingAgreement` (string) - `billingAddressRequired (deprecated)` (boolean) _This parameter has been deprecated in favor of the `billingAddressRequired` param on the [create](/js/elements_object/create_express_checkout_element.md#express_checkout_element_create-options-billingAddressRequired) function._ By default, the Express Checkout Element collects the billing address. You can disable this by setting `billingAddressRequired` to `false`. We highly recommend that you collect the billing address because it can be used to perform address verifications and block fraudulent payments. - `business (deprecated)` (object) _This parameter has been deprecated in favor of the `business` param on the [create](/js/elements_object/create_express_checkout_element.md#express_checkout_element_create-options-business) function._ Provide information about your business that's displayed in the Express Checkout Element. This information will be retrieved from your Stripe account if it's not provided. - `name` (string) The name of your business. Your business name is used to signal to the customer who they're paying. Klarna always retrieves the business name from your Stripe account, even when this option is set. - `emailRequired (deprecated)` (boolean) _This parameter has been deprecated in favor of the `emailRequired` param on the [create](/js/elements_object/create_express_checkout_element.md#express_checkout_element_create-options-emailRequired) function._ Collect the customer's email by setting this option to `true`. - `lineItems` (array) An array of LineItem objects. These LineItems are shown as line items in the payment interface, if line items are supported. You can represent discounts as negative amount LineItems. - `name` (string) **required** The name of the line item surfaced to the customer in the payment interface. - `amount` (number) **required** The amount in the currency's subunit (for example, cents, yen, etc.). - `phoneNumberRequired (deprecated)` (boolean) _This parameter has been deprecated in favor of the `phoneNumberRequired` param on the [create](/js/elements_object/create_express_checkout_element.md#express_checkout_element_create-options-phoneNumberRequired) function._ Collect the customer's phone number by setting this option to `true`. PayPal doesn't provide a phone number, even when this option is set to `true`. - `shippingAddressRequired (deprecated)` (boolean) _This parameter has been deprecated in favor of the `shippingAddressRequired` param on the [create](/js/elements_object/create_express_checkout_element.md#express_checkout_element_create-options-shippingAddressRequired) function._ Collect the customer's shipping address by setting this option to `true`. If `true`, you must also supply a valid `shippingRates` option in either the `create`, `click`, or `shippingaddresschange` events. - `shippingRates` (array) An array of ShippingRate objects. The first shipping rate listed appears in the payment interface as the default option. - `id` (string) **required** Unique identifier for the object. - `amount` (number) **required** The amount to charge for shipping. - `displayName` (string) **required** The name of the shipping rate, displayed to the customer in the payment interface. - `deliveryEstimate` (object | string) The estimated range for how long shipping takes, displayed to the customer in the payment interface. We recommended using the object format, but you can use a string instead. - `maximum` (object) The upper bound of the estimated range. If empty, it represents no upper bound (for example, infinite). - `unit` ('hour' | 'day' | 'business_day' | 'week' | 'month') A unit of time. - `value` (number) Must be greater than 0. - `minimum` (object) The lower bound of the estimated range. If empty, it represents no lower bound. - `unit` ('hour' | 'day' | 'business_day' | 'week' | 'month') A unit of time. - `value` (number) Must be greater than 0. - `reject` (function) **required** A function `reject() => void` that's called to cancel the payment interface. You must call this function within 1 second if you handle the `click` event. ### Handle an express checkout element click event ```js expressCheckoutElement.on('click', function(event) { // Handle click event }); ``` ```es_next expressCheckoutElement.on('click', (event) => { // Handle click event }); ``` ## Confirm event The `confirm` event is triggered from an Express Checkout Element when the customer finalizes their payment. Use this event to trigger payment confirmation. **Syntax:** `expressCheckoutElement.on(...)` - `event` (string) **required** The name of the event. In this case, `confirm`. - `handler` (function) **required** A callback function `handler(event) => void` you provide that's called after the event is fired. When called, it passes an event object with the following properties: - `elementType` ('expressCheckout') **required** The type of element the event fires from, which is `expressCheckout` in this case. - `expressPaymentType` ('apple_pay' | 'google_pay' | 'amazon_pay' | 'paypal' | 'link' | 'klarna') **required** The payment method the customer checks out with. - `paymentFailed` (function) **required** A function `paymentFailed(payload) => void` that's called if you're unable to process the customer's payment. - `reason` ('fail' | 'invalid_shipping_address' | 'invalid_billing_address' | 'invalid_payment_data' | 'address_unserviceable') Default is `'fail'`. The payment interface might surface the reason to provide a hint to the customer on why their payment failed. - `message` (string) A short, concise, localized error message to display on the payment sheet. If none is provided, the payment sheet will display a generic error message for the given reason. **Note:** Custom error messages may not be supported or may be truncated by certain wallets. - `billingDetails` (object) Object containing information about the customer's billing details. - `name` (string) The name of the customer. - `email` (string) The email address of the customer. - `phone` (string) The phone number of the customer. - `address` (string) The billing address of the customer. **Note:** When using PayPal, the full billing address of the customer is not always exposed. Typically, only the country code is passed back from PayPal. To access the full billing address, you would need to request it from PayPal directly. - `line1` (string) - `line2` (string) - `city` (string) - `state` (string) - `postal_code` (string) - `country` (string) - `shippingAddress` (object) Object containing information about the customer's shipping address. - `name` (string) The name of the recipient. - `address` (string) The shipping address of the customer. - `line1` (string) - `line2` (string) - `city` (string) - `state` (string) - `postal_code` (string) - `country` (string) - `shippingRate` (object) Object containing information about the selected shipping rate. - `id` (string) **required** Unique identifier for the object. - `amount` (number) **required** The amount to charge for shipping. - `displayName` (string) **required** The name of the shipping rate, displayed to the customer in the payment interface. - `deliveryEstimate` (object | string) The estimated range for how long shipping takes, displayed to the customer in the payment interface. We recommended using the object format, but you can use a string instead. - `maximum` (object) The upper bound of the estimated range. If empty, it represents no upper bound (for example, infinite). - `unit` ('hour' | 'day' | 'business_day' | 'week' | 'month') A unit of time. - `value` (number) Must be greater than 0. - `minimum` (object) The lower bound of the estimated range. If empty, it represents no lower bound. - `unit` ('hour' | 'day' | 'business_day' | 'week' | 'month') A unit of time. - `value` (number) Must be greater than 0. ### Handle 'confirm' event ```js expressCheckoutElement.on('confirm', function(event) { // call Stripe function to initiate payment confirmation stripe.confirmPayment({ elements, clientSecret, confirmParams: { return_url: 'https://example.com', }, }) .then(function(result) { if (result.error) { // Inform the customer that there's an error. } }); }); ``` ```es_next expressCheckoutElement.on('confirm', (event) => { // call Stripe function to initiate payment confirmation const {error} = await stripe.confirmPayment({ elements, clientSecret, confirmParams: { return_url: 'https://example.com', }, }); }); ``` ## Cancel event The `cancel` event is triggered from an Express Checkout Element when the payment interface is dismissed. Note that in some browsers, the payment interface might be dismissed by the customer even after they authorize the payment. This means that you might receive a `cancel` event after receiving a `confirm` event. If you're using the `cancel` event as a hook for canceling the customer's order, make sure you also refund the payment that you just created. **Syntax:** `expressCheckoutElement.on(...)` - `event` (string) **required** The name of the event. In this case, `cancel`. - `handler` (function) **required** A callback function that you provide that's called after the event is fired. ### Handle 'cancel' event ```js expressCheckoutElement.on('cancel', function() { // handle cancel event }); ``` ```es_next expressCheckoutElement.on('cancel', () => { // handle cancel event }); ``` ## Shippingaddresschange event The `shippingaddresschange` event is triggered from an Express Checkout Element whenever the customer selects a new address in the payment interface. This event is not available for Elements with Checkout Sessions (EwCS integrations). When using an Express Checkout Element with a Checkout Session, shipping address changes are managed through the Checkout Session itself. You can update the session on your server after the customer completes their payment rather than responding to this event during the payment flow. **Syntax:** `expressCheckoutElement.on(...)` - `event` (string) **required** The name of the event. In this case, `shippingaddresschange`. - `handler` (function) **required** A callback function `handler(event) => void` you provide that's called after the event is fired. After it's called, it passes an event object with the following properties: - `elementType` ('expressCheckout') **required** The type of element the event is fired from, which is `expressCheckout` in this case. - `resolve` (function) **required** A function `resolve(payload) => void` that's called if the recipient's shipping address is valid. - `applePay` (object) Specify Apple Pay specific options. These are passed through to the Apple Pay API. - `recurringPaymentRequest` (object) Specify a request to set up a recurring payment. See the [Apple Pay documentation](https://developer.apple.com/documentation/apple_pay_on_the_web/applepayrecurringpaymentrequest) for more details. - `paymentDescription` (string) **required** - `managementURL` (string) **required** - `regularBilling` (object) **required** - `amount` (number) **required** - `label` (string) **required** - `recurringPaymentStartDate` (Date) - `recurringPaymentEndDate` (Date) - `recurringPaymentIntervalUnit` ('year' | 'month' | 'day' | 'hour' | 'minute') - `recurringPaymentIntervalCount` (number) - `trialBilling` (object) - `amount` (number) **required** - `label` (string) **required** - `recurringPaymentStartDate` (Date) - `recurringPaymentEndDate` (Date) - `recurringPaymentIntervalUnit` ('year' | 'month' | 'day' | 'hour' | 'minute') - `recurringPaymentIntervalCount` (number) - `automaticReloadPaymentRequest` (object) Specify a request to set up an automatic reload payment. See the [Apple Pay documentation](https://developer.apple.com/documentation/apple_pay_on_the_web/applepayautomaticreloadpaymentrequest) for more details. - `paymentDescription` (string) **required** - `managementURL` (string) **required** - `automaticReloadBilling` (object) **required** - `amount` (number) **required** - `label` (string) **required** - `automaticReloadPaymentThresholdAmount` (number) **required** - `lineItems` (array) An array of LineItem objects. These LineItems are shown as line items in the payment interface, if line items are supported. - `name` (string) **required** The name of the line item surfaced to the customer in the payment interface. - `amount` (number) **required** The amount in the currency's subunit (for example, cents, yen, etc.). - `shippingRates` (array) An array of ShippingRate objects. The first shipping rate listed appears in the payment interface as the default option. - `id` (string) **required** Unique identifier for the object. - `amount` (number) **required** The amount to charge for shipping. - `displayName` (string) **required** The name of the shipping rate, displayed to the customer in the payment interface. - `deliveryEstimate` (object | string) The estimated range for how long shipping takes, displayed to the customer in the payment interface. We recommended using the object format, but you can use a string instead. - `maximum` (object) The upper bound of the estimated range. If empty, it represents no upper bound (for example, infinite). - `unit` ('hour' | 'day' | 'business_day' | 'week' | 'month') A unit of time. - `value` (number) Must be greater than 0. - `minimum` (object) The lower bound of the estimated range. If empty, it represents no lower bound. - `unit` ('hour' | 'day' | 'business_day' | 'week' | 'month') A unit of time. - `value` (number) Must be greater than 0. - `reject` (function) **required** A function `reject() => void` that's called if the recipient's shipping address is invalid. - `name` (string) The name of the recipient. - `address` (string) The shipping address of the recipient. To maintain privacy, browsers might anonymize the shipping address by removing sensitive information that isn't necessary to calculate shipping costs. Depending on the country, some fields can be missing or partially redacted. For example, the shipping address in the US can only contain a city, state, and ZIP code. The full shipping address appears in the [confirm event](/js/elements_object/express_checkout_element_confirm_event.md#express_checkout_element_on_confirm-handler-shippingAddress) object after the purchase is confirmed in the browser’s payment interface. - `city` (string) - `state` (string) - `postal_code` (string) - `country` (string) ### Handle 'shippingaddresschange' event ```js expressCheckoutElement.on('shippingaddresschange', function(event) { var resolve = event.resolve; var address = event.address; // handle shippingaddresschange event // define payload and pass it into resolve var payload = { shippingRates: [ shippingRate ] }; // call event.resolve within 20 seconds resolve(payload); }); ``` ```es_next expressCheckoutElement.on('shippingaddresschange', (event) => { const {resolve, address} = event; // handle shippingaddresschange event // define payload and pass it into resolve const payload = { shippingRates: [ shippingRate ] }; // call event.resolve within 20 seconds resolve(payload); }); ``` ## Shippingratechange event The `shippingratechange` event is triggered from an Express Checkout Element whenever the customer selects a new shipping rate in the payment interface. This event is not available for Elements with Checkout Sessions (EwCS integrations). When using an Express Checkout Element with a Checkout Session, shipping rate changes are managed through the Checkout Session itself. You can update the session on your server after the customer completes their payment rather than responding to this event during the payment flow. **Syntax:** `expressCheckoutElement.on(...)` - `event` (string) **required** The name of the event. In this case, `shippingratechange`. - `handler` (function) **required** A callback function `handler(event) => void` you provide that's called after the event is fired. After it's called, it passes an event object with the following properties: - `elementType` ('expressCheckout') **required** The type of element the event is fired from, which is `expressCheckout` in this case. - `resolve` (function) **required** A function `resolve(payload) => void` that's called if the customer's shipping rate is valid. - `applePay` (object) Specify Apple Pay specific options. These are passed through to the Apple Pay API. - `recurringPaymentRequest` (object) Specify a request to set up a recurring payment. See the [Apple Pay documentation](https://developer.apple.com/documentation/apple_pay_on_the_web/applepayrecurringpaymentrequest) for more details. - `paymentDescription` (string) **required** - `managementURL` (string) **required** - `regularBilling` (object) **required** - `amount` (number) **required** - `label` (string) **required** - `recurringPaymentStartDate` (Date) - `recurringPaymentEndDate` (Date) - `recurringPaymentIntervalUnit` ('year' | 'month' | 'day' | 'hour' | 'minute') - `recurringPaymentIntervalCount` (number) - `trialBilling` (object) - `amount` (number) **required** - `label` (string) **required** - `recurringPaymentStartDate` (Date) - `recurringPaymentEndDate` (Date) - `recurringPaymentIntervalUnit` ('year' | 'month' | 'day' | 'hour' | 'minute') - `recurringPaymentIntervalCount` (number) - `automaticReloadPaymentRequest` (object) Specify a request to set up an automatic reload payment. See the [Apple Pay documentation](https://developer.apple.com/documentation/apple_pay_on_the_web/applepayautomaticreloadpaymentrequest) for more details. - `paymentDescription` (string) **required** - `managementURL` (string) **required** - `automaticReloadBilling` (object) **required** - `amount` (number) **required** - `label` (string) **required** - `automaticReloadPaymentThresholdAmount` (number) **required** - `lineItems` (array) An array of LineItem objects. These LineItems are shown as line items in the payment interface, if line items are supported. - `name` (string) **required** The name of the line item surfaced to the customer in the payment interface. - `amount` (number) **required** The amount in the currency's subunit (for example, cents, yen, etc.). - `shippingRates` (array) An array of ShippingRate objects. The first shipping rate listed appears in the payment interface as the default option. - `id` (string) **required** Unique identifier for the object. - `amount` (number) **required** The amount to charge for shipping. - `displayName` (string) **required** The name of the shipping rate, displayed to the customer in the payment interface. - `deliveryEstimate` (object | string) The estimated range for how long shipping takes, displayed to the customer in the payment interface. We recommended using the object format, but you can use a string instead. - `maximum` (object) The upper bound of the estimated range. If empty, it represents no upper bound (for example, infinite). - `unit` ('hour' | 'day' | 'business_day' | 'week' | 'month') A unit of time. - `value` (number) Must be greater than 0. - `minimum` (object) The lower bound of the estimated range. If empty, it represents no lower bound. - `unit` ('hour' | 'day' | 'business_day' | 'week' | 'month') A unit of time. - `value` (number) Must be greater than 0. - `reject` (function) **required** A function `reject() => void` that's called if the customer's shipping rate is invalid. - `shippingRate` (object) The shipping rate selected by the customer. - `id` (string) **required** Unique identifier for the object. - `amount` (number) **required** The amount to charge for shipping. - `displayName` (string) **required** The name of the shipping rate, displayed to the customer in the payment interface. - `deliveryEstimate` (object | string) The estimated range for how long shipping takes, displayed to the customer in the payment interface. We recommended using the object format, but you can use a string instead. - `maximum` (object) The upper bound of the estimated range. If empty, it represents no upper bound (for example, infinite). - `unit` ('hour' | 'day' | 'business_day' | 'week' | 'month') A unit of time. - `value` (number) Must be greater than 0. - `minimum` (object) The lower bound of the estimated range. If empty, it represents no lower bound. - `unit` ('hour' | 'day' | 'business_day' | 'week' | 'month') A unit of time. - `value` (number) Must be greater than 0. ### Handle 'shippingratechange' event ```js expressCheckoutElement.on('shippingratechange', function(event) { var resolve = event.resolve; var shippingRate = event.shippingRate; // handle shippingratechange event // define payload and pass it into resolve var payload = { shippingRates: [ shippingRate ] }; // call event.resolve within 20 seconds resolve(payload); }); ``` ```es_next expressCheckoutElement.on('shippingratechange', (event) => { const {resolve, shippingRate} = event; // handle shippingratechange event // define payload and pass it into resolve const payload = { shippingRates: [ shippingRate ] }; // call event.resolve within 20 seconds resolve(payload); }); ``` ## The Link Authentication Element The [Link Authentication Element](/payments/link/accept-a-payment.md) is an embeddable component for collecting email addresses and allow users to log into Link on your checkout page. ## Create the Link Authentication Element This method creates an instance of the Link Authentication Element. **Syntax:** `elements.create(...)` - `type` ('linkAuthentication') **required** The type of Element being created, which is `linkAuthentication` in this case. - `options` (object) Options for creating the Link Authentication Element. - `defaultValues` (object) Provide the initial contact information that will be displayed in the Link Authentication Element. The form will render with empty fields if not provided. - `email` (string) ### Create a Link Authentication Element ```js var linkAuthenticationElement = elements.create('linkAuthentication'); ``` ```es_next const linkAuthenticationElement = elements.create('linkAuthentication'); ``` ## Get a Link Authentication Element This method retrieves a previously created Link Authentication Element. `elements.getElement('linkAuthentication')` returns one of the following: * An instance of a Link Authentication Element. * `null`, when no Link Authentication Element has been created. **Syntax:** `elements.getElement(...)` - `type` ('linkAuthentication') **required** The type of Element being retrieved, which is `linkAuthentication` in this case. ### Get a Link Authentication Element ```js var linkAuthenticationElement = elements.getElement('linkAuthentication'); ``` ```es_next const linkAuthenticationElement = elements.getElement('linkAuthentication'); ``` ## The Address Element The Address Element is an embeddable component for collecting local and international billing and shipping addresses. ## Create the Address Element This method creates an instance of the Address Element. **NOTE**: If you are creating multiple instances of the Address Element, configuration of the checkbox to sync shipping and billing addresses exists in the creation of the [Elements](/js/elements_object/create.md#stripe_elements-options-syncAddressCheckbox) instance. **Syntax:** `elements.create(...)` - `type` ('address') **required** The type of Element being created, which is `address` in this case. You can create multiple Address Elements, one of each mode, in a single Elements instance. - `options` (object) **required** Options for creating the Address Element. - `mode` ('shipping' | 'billing') **required** Specify which mode you would like to use Address Element for. When `shipping` mode is used with the Payment Element and Link Authentication Element, it will automatically pass shipping information when confirming Payment Intent or Setup Intent. When `billing` mode is used with the Payment Element, it will automatically pass the billing information when confirming Payment Intent or Setup Intent. - `autocomplete` (object) By default, the Address Element will have autocomplete enabled with Stripe provided Google Maps API key for certain countries if any of the following condition is met: * If Payment Element is mounted in the same elements group as Address Element in a single page application. * If the Address Element is used in an active Link session. [Contact Legal before editing or deleting the Google Maps autocomplete callout]: # By using autocomplete, you agree to comply with the [Google Maps Platform Acceptable Use Policy](https://cloud.google.com/maps-platform/terms/aup). If you violate this policy, we might disable autocomplete, or take any other action as necessary. You can customize the autocomplete setting with this option. - `mode` (‘automatic’ | ‘disabled’ | ‘google_maps_api’) **required** Specify `disabled` to disable autocomplete in the Address Element. Specify `google_maps_api` to enable [Google Maps API](https://developers.google.com/maps/documentation/javascript/places) with your own key. It will only be used when Stripe provided Google Maps API key is not available. The default setting is `automatic`, where we’ll support autocomplete when possible. - `apiKey` (string) Specify your own [Google Maps API key](https://developers.google.com/maps/documentation/javascript/places#add-places-api-to-the-api-keys-api-restrictions-list) with it. **Only needs to be passed in when `autocomplete.mode` is set to `google_maps_api`.** - `allowedCountries` (array) By default, the Address Element will display all countries for selection. You can specify which countries are displayed in the Address Element with a list of two-letter country codes. If only one country is specified, the country field will not display. - `blockPoBox` (boolean) By default, PO boxes are considered a valid address type. You can override this to invalidate PO Boxes. - `contacts` (array) An array of [Contact](/js/appendix/contact_object.md) objects that can be displayed as saved addresses in the Address Element. The first contact will be automatically selected. If using a [CustomerSession](/api/customer_sessions.md), Address Element will ignore contacts and render saved billing addresses instead. - `defaultValues` (object) Provide the initial information that will be displayed in the Address Element. The form will render with empty fields if not provided. - `name` (string) Provide the initial full name or organization name. - `firstName` (string) Provide the initial first name. The [display.name](/js/elements_object/create_address_element.md#address_element_create-options-display-name) option must be set to `split` if this property is specified. - `lastName` (string) Provide the initial last name. The [display.name](/js/elements_object/create_address_element.md#address_element_create-options-display-name) option must be set to `split` if this property is specified. - `phone` (string) Provide the initial phone number value. The [fields.phone](/js/elements_object/create_address_element.md#address_element_create-options-fields-phone) option must be set to `always` if this property is specified. - `address` (object) Provide the initial address details. - `line1` (string) - `line2` (string) - `city` (string) - `state` (string) - `postal_code` (string) - `country` (string) **required** - `fields` (object) By default, the Address Element will collect all the necessary information needed for an address. In some cases, it might be necessary to collect other types of information. You can specify other types of fields to render in the form with this option. - `phone` ('always' | 'auto' | 'never') Specify `always` to enable phone number collection in the Address Element. Only collect phone numbers if you need them for the transaction. Default is `auto`. - `validation` (object) By default, the Address Element will enforce preset validation for each field. You can customize the settings by using this option. - `phone` (object) - `required` ('always' | 'auto' | 'never') Specify `always` to make phone number a required field. The [fields.phone](/js/elements_object/create_address_element.md#address_element_create-options-fields-phone) option must be set to `always` if this property is specified. Default is `auto`. - `display` (object) You can customize how certain fields are displayed. - `name` ('full' | 'split' | 'organization') By default, the Address Element will display a full name field. Specify 'split' to display a first name field and a last name field. Specify 'organization' to display an organization field. ### Create an Address Element ```js // Create the Address Element in shipping mode var shippingAddressElement = elements.create('address', { mode: 'shipping', }); // Create the Address Element in billing mode var billingAddressElement = elements.create('address', { mode: 'billing', }); ``` ```es_next // Create the Address Element in shipping mode const shippingAddressElement = elements.create('address', { mode: 'shipping', }); // Create the Address Element in billing mode const billingAddressElement = elements.create('address', { mode: 'billing', }); ``` ## Get an Address Element This method retrieves a previously created Address Element. `elements.getElement('address')` returns one of the following: * An instance of an Address Element. * `null`, when no Address Element has been created. **Syntax:** `elements.getElement(...)` - `type` ('address') **required** The type of Element being retrieved, which is `address` in this case. - `options` (object) Options for retrieving the Address Element. - `mode` ('shipping' | 'billing') Required when using multiple Address Elements. Specify which mode of the Address Element you would like to retrieve. ### Get an Address Element ```js var addressElement = elements.getElement('address'); ``` ```es_next const addressElement = elements.getElement('address'); ``` ## Update an Address Element Updates the options the [Address Element](/js/element/address_element.md) was initialized with. Updates are merged into the existing configuration. **Syntax:** `element.update(...)` - `options` (object) Options for updating the Address Element. - `fields` (object) By default, the Address Element will collect all the necessary information needed for an address. In some cases, it might be necessary to collect other types of information. You can specify other types of fields to render in the form with this option. - `phone` ('always' | 'auto' | 'never') Specify `always` to enable phone number collection in the Address Element. Only collect phone numbers if you need them for the transaction. Default is `auto`. - `validation` (object) By default, the Address Element will enforce preset validation for each field. You can customize the settings by using this option. - `phone` (object) - `required` ('always' | 'auto' | 'never') Specify `always` to make phone number a required field. The [fields.phone](/js/elements_object/create_address_element.md#address_element_create-options-fields-phone) option must be set to `always` if this property is specified. Default is `auto`. ### Update an Address Element ```js var addressElement = elements.getElement('address'); addressElement.update({ validation: { phone: { required: 'never', }, }, }); ``` ```es_next const addressElement = elements.getElement('address'); addressElement.update({ validation: { phone: { required: 'never', }, }, }); ``` ## Get value from an Address Element Validates and retrieves form values from an Address Element. If there are any input validation errors, the errors will display by their respective fields. `addressElement.getValue()` returns a promise. This promise will return an object with the following: * `complete`, `true` if the value is well-formed and potentially complete. The `complete` value can be used to progressively disclose the next parts of your form or to enable form submission. It is not an indicator of whether a customer is done with their input—it only indicates that the Element contains a potentially complete, well-formed value. In many cases the customer could still add further input. * `isNewAddress`, `true` if the Address Element is currently displaying the form collection view. * `value`, an object containing the current address information. The `firstName` and `lastName` properties only appear if the `display.name` option is set to `split`. The `phone` property only appears if the `fields.phone` option is set to `always`. **Syntax:** `element.getValue(...)` ### Get value from an Address Element ```js var addressElement = elements.getElement('address'); addressElement.getValue() .then(function(result) { if (result.complete) { // Allow user to proceed to the next step // Optionally, use value to store the address details } }) ``` ```es_next const addressElement = elements.getElement('address'); const {complete, value} = await addressElement.getValue(); if (complete) { // Allow user to proceed to the next step // Optionally store the address details with value } ``` ## The Tax ID Element The [Tax ID Element](/elements/tax-id-element.md) is an embeddable component for collecting customer tax ID information for tax reporting and compliance purposes. ## Create a Tax ID Element This method creates an instance of the Tax ID Element. > This feature requires the `elements_tax_id_1` beta. To use it, pass `betas: ['elements_tax_id_1']` when initializing Stripe.js. **Syntax:** `elements.create(...)` - `type` ('taxId') **required** The type of Element being created, which is `taxId` in this case. - `options` (object) Tax ID Element initialization options. - `visibility` ('always' | 'never' | 'auto') By default, the Tax ID Element displays when the user is in a country that supports tax ID collection. Specify `always` to display the element regardless of the user's country. Specify `never` to hide the element completely. - `fields` (object) By default, the Tax ID Element collects all tax ID information. If it's not necessary for you to collect all fields, you can disable Tax ID Element collection of certain fields with the `fields` option. - `businessName` ('always' | 'never' | 'auto') Specify `always` to collect the business name. Specify `never` to not collect the business name. Default is `auto`. - `validation` (object) By default, the Tax ID Element will enforce preset validation for each field. You can customize the settings by using this option. - `businessName` (object) - `required` ('always' | 'never' | 'auto') Specify `always` to make business name a required field. Specify `never` to make business name an optional field. Default is `auto`. - `taxId` (object) - `required` ('always' | 'never' | 'auto') Specify `always` to make tax ID a required field. Specify `never` to make tax ID an optional field. Default is `auto`. ### Create a Tax ID Element ```js var taxIdElement = elements.create('taxId', { visibility: 'auto', }); ``` ```es_next const taxIdElement = elements.create('taxId', { visibility: 'auto', }); ``` ## Retrieve a Tax ID Element This method retrieves a previously created Tax ID Element. `elements.getElement('taxId')` returns one of the following: * An instance of a Tax ID Element. * `null`, when no Tax ID Element has been created. **Syntax:** `elements.getElement(...)` - `type` ('taxId') **required** The type of Element being retrieved, which is `taxId` in this case. ### Retrieve a Tax ID Element ```js var taxIdElement = elements.getElement('taxId'); ``` ```es_next const taxIdElement = elements.getElement('taxId'); ``` ## Get value from a Tax ID Element Validates and retrieves form values from a Tax ID Element. If there are any input validation errors, the errors are displayed by their associated fields. `taxIdElement.getValue()` returns a promise. This promise returns an object with the following: * `complete`, `true` if the value is well-formed and potentially complete. The `complete` value can be used to progressively disclose the next parts of your form or to enable form submission. It doesn't indicate whether a customer is done with their input. Rather, it only indicates that the Element contains a potentially complete, well-formed value. In many cases, the customer can still add further input. * `empty`, `true` if both the business name and tax ID fields are empty. * `visible`, `true` if the Tax ID Element is visible based on the `visibility` option and country. * `value`, an object containing the current tax ID information. The `businessName` property may be `null` if not configured to be collected. **Syntax:** `element.getValue(...)` ### Get value from a Tax ID Element ```js var taxIdElement = elements.getElement('taxId'); taxIdElement.getValue() .then(function(result) { if (result.complete) { // Allow user to proceed to the next step // Optionally, use value to store the tax ID details } }) ``` ```es_next const taxIdElement = elements.getElement('taxId'); const {complete, value} = await taxIdElement.getValue(); if (complete) { // Allow user to proceed to the next step // Optionally store the tax ID details with value } ``` ## Issuing Elements [Issuing Elements](/issuing/elements.md) allows you to display the sensitive data of your Issuing cards in a PCI-compliant manner. ## Create an Element This method creates an instance of an individual Issuing Element. It takes the `type` of Element to create as well as an `options` object. **Syntax:** `elements.create(...)` #### issuingCardNumberDisplay - `type` (string) **required** The type of Element being created. One of: `issuingCardNumberDisplay`, `issuingCardCvcDisplay`, `issuingCardExpiryDisplay`, `issuingCardPinDisplay`, or `issuingCardCopyButton`. - `options` (object) **required** Options for creating an Issuing element. - `issuingCard` (string) ID of the [Issuing card](/api/issuing/cards/object.md) to be displayed in this Element. - `ephemeralKeySecret` (string) The `secret` component of the ephemeral key created to display this Element. - `nonce` (string) The ephemeral key nonce used to create the ephemeral key provided to this Element. - `style` (object) Customize the appearance of this Element using CSS properties passed in a [Style](/js/appendix/style.md) object. ### Create a issuingCardNumberDisplay Element ```js var element = elements.create('issuingCardNumberDisplay', { issuingCard: 'ic_1ITi6XKYfU8ZP6raDAXem8ql', nonce: 'ephkn_priv_v9QGxPyA1F1VHjB4dpLhHfw4', ephemeralKeySecret: 'ek_live_YWNjdF8xSmtzQWtQbUd...', }); ``` ```es_next const element = elements.create('issuingCardNumberDisplay', { issuingCard: 'ic_1ITi6XKYfU8ZP6raDAXem8ql', nonce: 'ephkn_priv_v9QGxPyA1F1VHjB4dpLhHfw4', ephemeralKeySecret: 'ek_live_YWNjdF8xSmtzQWtQbUd...', }); ``` #### issuingCardCvcDisplay - `type` (string) **required** The type of Element being created. One of: `issuingCardNumberDisplay`, `issuingCardCvcDisplay`, `issuingCardExpiryDisplay`, `issuingCardPinDisplay`, or `issuingCardCopyButton`. - `options` (object) **required** Options for creating an Issuing element. - `issuingCard` (string) ID of the [Issuing card](/api/issuing/cards/object.md) to be displayed in this Element. - `ephemeralKeySecret` (string) The `secret` component of the ephemeral key created to display this Element. - `nonce` (string) The ephemeral key nonce used to create the ephemeral key provided to this Element. - `style` (object) Customize the appearance of this Element using CSS properties passed in a [Style](/js/appendix/style.md) object. ### Create a issuingCardCvcDisplay Element ```js var element = elements.create('issuingCardCvcDisplay', { issuingCard: 'ic_1ITi6XKYfU8ZP6raDAXem8ql', nonce: 'ephkn_priv_v9QGxPyA1F1VHjB4dpLhHfw4', ephemeralKeySecret: 'ek_live_YWNjdF8xSmtzQWtQbUd...', }); ``` ```es_next const element = elements.create('issuingCardCvcDisplay', { issuingCard: 'ic_1ITi6XKYfU8ZP6raDAXem8ql', nonce: 'ephkn_priv_v9QGxPyA1F1VHjB4dpLhHfw4', ephemeralKeySecret: 'ek_live_YWNjdF8xSmtzQWtQbUd...', }); ``` #### issuingCardExpiryDisplay - `type` (string) **required** The type of Element being created. One of: `issuingCardNumberDisplay`, `issuingCardCvcDisplay`, `issuingCardExpiryDisplay`, `issuingCardPinDisplay`, or `issuingCardCopyButton`. - `options` (object) **required** Options for creating an Issuing element. - `issuingCard` (string) ID of the [Issuing card](/api/issuing/cards/object.md) to be displayed in this Element. - `ephemeralKeySecret` (string) The `secret` component of the ephemeral key created to display this Element. - `nonce` (string) The ephemeral key nonce used to create the ephemeral key provided to this Element. - `style` (object) Customize the appearance of this Element using CSS properties passed in a [Style](/js/appendix/style.md) object. ### Create a issuingCardExpiryDisplay Element ```js var element = elements.create('issuingCardExpiryDisplay', { issuingCard: 'ic_1ITi6XKYfU8ZP6raDAXem8ql', nonce: 'ephkn_priv_v9QGxPyA1F1VHjB4dpLhHfw4', ephemeralKeySecret: 'ek_live_YWNjdF8xSmtzQWtQbUd...', }); ``` ```es_next const element = elements.create('issuingCardExpiryDisplay', { issuingCard: 'ic_1ITi6XKYfU8ZP6raDAXem8ql', nonce: 'ephkn_priv_v9QGxPyA1F1VHjB4dpLhHfw4', ephemeralKeySecret: 'ek_live_YWNjdF8xSmtzQWtQbUd...', }); ``` #### issuingCardPinDisplay - `type` (string) **required** The type of Element being created. One of: `issuingCardNumberDisplay`, `issuingCardCvcDisplay`, `issuingCardExpiryDisplay`, `issuingCardPinDisplay`, or `issuingCardCopyButton`. - `options` (object) **required** Options for creating an Issuing element. - `issuingCard` (string) ID of the [Issuing card](/api/issuing/cards/object.md) to be displayed in this Element. - `ephemeralKeySecret` (string) The `secret` component of the ephemeral key created to display this Element. - `nonce` (string) The ephemeral key nonce used to create the ephemeral key provided to this Element. - `style` (object) Customize the appearance of this Element using CSS properties passed in a [Style](/js/appendix/style.md) object. ### Create a issuingCardPinDisplay Element ```js var element = elements.create('issuingCardPinDisplay', { issuingCard: 'ic_1ITi6XKYfU8ZP6raDAXem8ql', nonce: 'ephkn_priv_v9QGxPyA1F1VHjB4dpLhHfw4', ephemeralKeySecret: 'ek_live_YWNjdF8xSmtzQWtQbUd...', }); ``` ```es_next const element = elements.create('issuingCardPinDisplay', { issuingCard: 'ic_1ITi6XKYfU8ZP6raDAXem8ql', nonce: 'ephkn_priv_v9QGxPyA1F1VHjB4dpLhHfw4', ephemeralKeySecret: 'ek_live_YWNjdF8xSmtzQWtQbUd...', }); ``` #### issuingCardCopyButton - `type` (string) **required** The type of Element being created. One of: `issuingCardNumberDisplay`, `issuingCardCvcDisplay`, `issuingCardExpiryDisplay`, `issuingCardPinDisplay`, or `issuingCardCopyButton`. - `options` (object) **required** Options for creating an Issuing element. - `toCopy` (string) Reference to the type of Issuing card data to copy. One of `number`, `cvc`, `expiry`, or `pin`. - `style` (object) Customize the appearance of this Element using CSS properties passed in a [Style](/js/appendix/style.md) object. ### Create a issuingCardCopyButton Element ```js var element = elements.create('issuingCardCopyButton', { toCopy: 'number', }); ``` ```es_next const element = elements.create('issuingCardCopyButton', { toCopy: 'number', }); ``` ## Other Elements Stripe also offers a [set of Elements for individual payment methods](/payments/elements.md) that you can use in your payment flows. ## Create an Element This method creates an instance of an individual `Element`. It takes the `type` of `Element` to create as well as an `options` object. **Syntax:** `elements.create(...)` #### card - `type` ('card') **required** The type of element you are creating. In this case, `card`. - `options` (object) Options for creating a `card` element. - `classes` (object) Set custom class names on the container DOM element when the Stripe element is in a particular state. - `base` (string) The base class applied to the container. Defaults to `StripeElement`. - `complete` (string) The class name to apply when the `Element` is complete. Defaults to `StripeElement--complete`. - `empty` (string) The class name to apply when the `Element` is empty. Defaults to `StripeElement--empty`. - `focus` (string) The class name to apply when the `Element` is focused. Defaults to `StripeElement--focus`. - `invalid` (string) The class name to apply when the `Element` is invalid. Defaults to `StripeElement--invalid`. - `webkitAutofill` (string) The class name to apply when the `Element` has its value autofilled by the browser (only on Chrome and Safari). Defaults to `StripeElement--webkit-autofill`. - `style` (object) Customize the appearance of this element using CSS properties passed in a [Style](/js/appendix/style.md) object. - `value` (object) A pre-filled set of values to include in the input. Note that sensitive card information (card number, CVC, and expiration date) cannot be pre-filled. - `postalCode` (string) - `hidePostalCode` (boolean) Hide the postal code field. Default is `false`. If you are already collecting a full billing address or postal code elsewhere, set this to `true`. - `iconStyle` (string) Appearance of the icon in the Element. Either `solid` or `default`. - `hideIcon` (boolean) Hides the icon in the Element. Default is `false`. - `disabled` (boolean) Applies a disabled state to the Element such that user input is not accepted. Default is `false`. - `disableLink` (boolean) Disables and hides the Link button in the Element. Default is `false`. You can also disable Link across all instances of `card` and `cardNumber` elements in your [payment method settings](https://dashboard.stripe.com/settings/payment_methods). - `preferredNetwork` (array) Specifies a network preference for [Card Brand Choice](/card-brand-choice.md). The first network in the array that matches a network on the entered co-branded card will be selected by default in the Card Brand Choice dropdown. See the [supported networks](/api/payment_methods/create.md#create_payment_method-card-networks-preferred) for valid values. If you specify a value for `preferredNetwork` at create time, [hideIcon](#elements_create-options-hideIcon) must not be true (so that the Card Brand Choice dropdown can appear) and you cannot specify [payment_method_options.card.network](/js/payment_intents/confirm_card_payment.md#stripe_confirm_card_payment-data-payment_method_options-card-network) at confirm time. ### Create a card Element ```js var cardElement = elements.create('card'); ``` ```es_next const cardElement = elements.create('card'); ``` #### cardNumber - `type` ('cardNumber') **required** The type of element you are creating. In this case, `cardNumber`. - `options` (object) Options for creating a `cardNumber` element. - `classes` (object) Set custom class names on the container DOM element when the Stripe element is in a particular state. - `base` (string) The base class applied to the container. Defaults to `StripeElement`. - `complete` (string) The class name to apply when the `Element` is complete. Defaults to `StripeElement--complete`. - `empty` (string) The class name to apply when the `Element` is empty. Defaults to `StripeElement--empty`. - `focus` (string) The class name to apply when the `Element` is focused. Defaults to `StripeElement--focus`. - `invalid` (string) The class name to apply when the `Element` is invalid. Defaults to `StripeElement--invalid`. - `webkitAutofill` (string) The class name to apply when the `Element` has its value autofilled by the browser (only on Chrome and Safari). Defaults to `StripeElement--webkit-autofill`. - `style` (object) Customize the appearance of this element using CSS properties passed in a [Style](/js/appendix/style.md) object. - `placeholder` (string) Customize the placeholder text. - `disabled` (boolean) Applies a disabled state to the Element such that user input is not accepted. Default is `false`. - `showIcon` (boolean) Show a card brand icon in the Element. Default is `false`. - `iconStyle` (string) Appearance of the icon in the Element. Either `solid` or `default`. - `disableLink` (boolean) Disables and hides the Link button in the Element. Default is `false`. You can also disable Link across all instances of `card` and `cardNumber` elements in your [payment method settings](https://dashboard.stripe.com/settings/payment_methods). - `preferredNetwork` (array) Specifies a network preference for [Card Brand Choice](/card-brand-choice.md). The first network in the array that matches a network on the entered co-branded card will be selected by default in the Card Brand Choice dropdown. See the [supported networks](/api/payment_methods/create.md#create_payment_method-card-networks-preferred) for valid values. If you specify a value for `preferredNetwork` at create time, [showIcon](#elements_create-options-showIcon) must be true (so that the Card Brand Choice dropdown can appear) and you cannot specify [payment_method_options.card.network](/js/payment_intents/confirm_card_payment.md#stripe_confirm_card_payment-data-payment_method_options-card-network) at confirm time. ### Create a cardNumber Element ```js var cardNumberElement = elements.create('cardNumber'); ``` ```es_next const cardNumberElement = elements.create('cardNumber'); ``` #### cardExpiry - `type` ('cardExpiry') **required** The type of element you are creating. In this case, `cardExpiry`. - `options` (object) Options for creating a `cardExpiry` element. - `classes` (object) Set custom class names on the container DOM element when the Stripe element is in a particular state. - `base` (string) The base class applied to the container. Defaults to `StripeElement`. - `complete` (string) The class name to apply when the `Element` is complete. Defaults to `StripeElement--complete`. - `empty` (string) The class name to apply when the `Element` is empty. Defaults to `StripeElement--empty`. - `focus` (string) The class name to apply when the `Element` is focused. Defaults to `StripeElement--focus`. - `invalid` (string) The class name to apply when the `Element` is invalid. Defaults to `StripeElement--invalid`. - `webkitAutofill` (string) The class name to apply when the `Element` has its value autofilled by the browser (only on Chrome and Safari). Defaults to `StripeElement--webkit-autofill`. - `style` (object) Customize the appearance of this element using CSS properties passed in a [Style](/js/appendix/style.md) object. - `placeholder` (string) Customize the placeholder text. - `disabled` (boolean) Applies a disabled state to the Element such that user input is not accepted. Default is `false`. ### Create a cardExpiry Element ```js var cardExpiryElement = elements.create('cardExpiry'); ``` ```es_next const cardExpiryElement = elements.create('cardExpiry'); ``` #### cardCvc - `type` ('cardCvc') **required** The type of element you are creating. In this case, `cardCvc`. - `options` (object) Options for creating a `cardCvc` element. - `classes` (object) Set custom class names on the container DOM element when the Stripe element is in a particular state. - `base` (string) The base class applied to the container. Defaults to `StripeElement`. - `complete` (string) The class name to apply when the `Element` is complete. Defaults to `StripeElement--complete`. - `empty` (string) The class name to apply when the `Element` is empty. Defaults to `StripeElement--empty`. - `focus` (string) The class name to apply when the `Element` is focused. Defaults to `StripeElement--focus`. - `invalid` (string) The class name to apply when the `Element` is invalid. Defaults to `StripeElement--invalid`. - `webkitAutofill` (string) The class name to apply when the `Element` has its value autofilled by the browser (only on Chrome and Safari). Defaults to `StripeElement--webkit-autofill`. - `style` (object) Customize the appearance of this element using CSS properties passed in a [Style](/js/appendix/style.md) object. - `placeholder` (string) Customize the placeholder text. - `disabled` (boolean) Applies a disabled state to the Element such that user input is not accepted. Default is `false`. ### Create a cardCvc Element ```js var cardCvcElement = elements.create('cardCvc'); ``` ```es_next const cardCvcElement = elements.create('cardCvc'); ``` #### iban - `type` ('iban') **required** The type of element you are creating. In this case, `iban`. - `options` (object) Options for creating an `iban` element. - `classes` (object) Set custom class names on the container DOM element when the Stripe element is in a particular state. - `base` (string) The base class applied to the container. Defaults to `StripeElement`. - `complete` (string) The class name to apply when the `Element` is complete. Defaults to `StripeElement--complete`. - `empty` (string) The class name to apply when the `Element` is empty. Defaults to `StripeElement--empty`. - `focus` (string) The class name to apply when the `Element` is focused. Defaults to `StripeElement--focus`. - `invalid` (string) The class name to apply when the `Element` is invalid. Defaults to `StripeElement--invalid`. - `webkitAutofill` (string) The class name to apply when the `Element` has its value autofilled by the browser (only on Chrome and Safari). Defaults to `StripeElement--webkit-autofill`. - `style` (object) Customize the appearance of this element using CSS properties passed in a [Style](/js/appendix/style.md) object. - `supportedCountries` (array) Specify the list of countries or country-groups whose IBANs you want to allow. Must be `['SEPA']`. - `placeholderCountry` (string) Customize the country and format of the placeholder IBAN. Default is `DE`. - `iconStyle` (string) Appearance of the icon in the Element. Either `solid` or `default`. - `hideIcon` (boolean) Hides the icon in the Element. Default is `false`. - `disabled` (boolean) Applies a disabled state to the Element such that user input is not accepted. Default is `false`. ### Create an iban Element ```js var ibanElement = elements.create('iban'); ``` ```es_next const ibanElement = elements.create('iban'); ``` #### paymentRequestButton - `type` ('paymentRequestButton') **required** The type of element you are creating. In this case, `paymentRequestButton`. - `options` (object) **required** Options for creating a `paymentRequestButton` element. - `classes` (object) Set custom class names on the container DOM element when the Stripe element is in a particular state. - `base` (string) The base class applied to the container. Defaults to `StripeElement`. - `complete` (string) The class name to apply when the `Element` is complete. Defaults to `StripeElement--complete`. - `empty` (string) The class name to apply when the `Element` is empty. Defaults to `StripeElement--empty`. - `focus` (string) The class name to apply when the `Element` is focused. Defaults to `StripeElement--focus`. - `invalid` (string) The class name to apply when the `Element` is invalid. Defaults to `StripeElement--invalid`. - `webkitAutofill` (string) The class name to apply when the `Element` has its value autofilled by the browser (only on Chrome and Safari). Defaults to `StripeElement--webkit-autofill`. - `style` (object) An object used to customize the appearance of the Payment Request Button. The object must have a single `paymentRequestButton` field, containing any of the following sub-fields: - `type` (string) Preferred button type to display. Available types, by wallet: Browser card: `default`, `book`, `buy`, or `donate`. Google Pay: `default`, `buy`, or `donate`. Apple Pay: `default`, `book`, `buy`, `donate`, `check-out`, `subscribe`, `reload`, `add-money`, `top-up`, `order`, `rent`, `support`, `contribute`, `tip` When a wallet does not support the provided value, `default` is used as a fallback. - `theme` (string) One of `dark`, `light`, or `light-outline`. The default is `dark`. - `height` (string) The height of the Payment Request Button. Accepts `px` unit values. - `paymentRequest` (PaymentRequest) **required** A [PaymentRequest](/js/payment_request.md) object used to configure the element. ### Create a paymentRequestButton Element ```js var paymentRequest = stripe.paymentRequest({ country: 'US', currency: 'usd', total: {label: 'Demo total', amount: 1099}, requestPayerName: true, requestPayerEmail: true, }); var paymentRequestButtonElement = elements.create( 'paymentRequestButton', { paymentRequest: paymentRequest, style: { paymentRequestButton: { theme: 'light', }, }, }, ); ``` ```es_next const paymentRequest = stripe.paymentRequest({ country: 'US', currency: 'usd', total: {label: 'Demo total', amount: 1099}, requestPayerName: true, requestPayerEmail: true, }); const paymentRequestButtonElement = elements.create( 'paymentRequestButton', { paymentRequest, style: { paymentRequestButton: { theme: 'light', }, }, }, ); ``` #### auBankAccount - `type` ('auBankAccount') **required** The type of element you are creating. In this case, `auBankAccount`. - `options` (object) Options for creating an `auBankAccount` element. - `classes` (object) Set custom class names on the container DOM element when the Stripe element is in a particular state. - `base` (string) The base class applied to the container. Defaults to `StripeElement`. - `complete` (string) The class name to apply when the `Element` is complete. Defaults to `StripeElement--complete`. - `empty` (string) The class name to apply when the `Element` is empty. Defaults to `StripeElement--empty`. - `focus` (string) The class name to apply when the `Element` is focused. Defaults to `StripeElement--focus`. - `invalid` (string) The class name to apply when the `Element` is invalid. Defaults to `StripeElement--invalid`. - `webkitAutofill` (string) The class name to apply when the `Element` has its value autofilled by the browser (only on Chrome and Safari). Defaults to `StripeElement--webkit-autofill`. - `style` (object) Customize the appearance of this element using CSS properties passed in a [Style](/js/appendix/style.md) object. - `iconStyle` (string) Appearance of the icon in the Element. Either `solid` or `default`. - `hideIcon` (boolean) Hides the icon in the Element. Default is `false`. - `disabled` (boolean) Applies a disabled state to the Element such that user input is not accepted. Default is `false`. ### Create an auBankAccount Element ```js var auBankAccountElement = elements.create('auBankAccount'); ``` ```es_next const auBankAccountElement = elements.create('auBankAccount'); ``` #### paymentMethodMessaging - `type` ('paymentMethodMessaging') **required** The type of element you are creating. In this case, `paymentMethodMessaging`. - `options` (object) **required** Options for displaying a `paymentMethodMessaging` element. [See visual examples in the docs.](/payments/payment-method-messaging.md) - `amount` (number) **required** The total amount in the [smallest currency unit](/currencies.md#zero-decimal). - `currency` (string) **required** The currency. One of `AUD`, `CAD`, `CHF`, `CZK`, `DKK`, `EUR`, `GBP`, `NOK`, `NZD`, `PLN`, `RON`, `SEK`, `USD`. - `countryCode` (string) The end-buyer country. One of `AT`, `AU`, `BE`, `CA`, `CH`, `CZ`, `DE`, `DK`, `ES`, `FI`, `FR`, `GB`, `GR`, `IE`, `IT`, `NL`, `NO`, `NZ`, `PL`, `PT`, `RO`, `SE`, `US`. If not set, the buyer's country will be inferred from the request. - `paymentMethodTypes` (array) A list of payment method types to render. You can omit this attribute to manage your payment methods from the [Stripe Dashboard](https://dashboard.stripe.com/settings/payment_methods). Any combination of `affirm`, `afterpay_clearpay`, `klarna`. - `paymentMethodOrder` (array) By default, the Payment Method Messaging Element uses a dynamic ordering that optimizes payment method display for each user. You can override the default order in which payment methods display in the Payment Method Messaging Element with a list of payment method types. If there are payment methods that will show that aren't specified in `paymentMethodOrder`, they display after the payment methods you specify. If you specify payment methods that won't show, they are ignored. ### Create a paymentMethodMessaging Element ```js const options = { amount: 9900, // $99.00 USD currency: 'USD', // the country that the end-buyer is in countryCode: 'US' }; const paymentMethodMessagingElement = elements.create('paymentMethodMessaging', options); ``` ```es_next const options = { amount: 9900, // $99.00 USD currency: 'USD', // the country that the end-buyer is in countryCode: 'US' }; const paymentMethodMessagingElement = elements.create('paymentMethodMessaging', options); ``` ## Get an Element This method looks up a previously created [Element](/js/element.md) by its type. `elements.getElement` returns one of the following: * An instance of an `Element` with a matching type. * `null`, when no `Element` with a matching type has been created. **Syntax:** `elements.getElement(...)` - `type` (string) **required** The type of [Element](/js/elements_object/create_element.md) to lookup. ### Get an Element ```js var cardElement = elements.getElement('card'); ``` ```es_next const cardElement = elements.getElement('card'); ``` ## Update an Element Updates the options the [Element](/js/element.md) was initialized with. Updates are merged into the existing configuration. If you collect certain information in a different part of your interface (e.g., ZIP or postal code), use `element.update` with the appropriate information. The styles of an `Element` can be dynamically changed using `element.update`. This method can be used to simulate CSS media queries that automatically adjust the size of elements when viewed on different devices. **Syntax:** `element.update(...)` #### card - `options` (object) Options for updating a `card` element. - `classes` (object) Set custom class names on the container DOM element when the Stripe element is in a particular state. - `base` (string) The base class applied to the container. Defaults to `StripeElement`. - `complete` (string) The class name to apply when the `Element` is complete. Defaults to `StripeElement--complete`. - `empty` (string) The class name to apply when the `Element` is empty. Defaults to `StripeElement--empty`. - `focus` (string) The class name to apply when the `Element` is focused. Defaults to `StripeElement--focus`. - `invalid` (string) The class name to apply when the `Element` is invalid. Defaults to `StripeElement--invalid`. - `webkitAutofill` (string) The class name to apply when the `Element` has its value autofilled by the browser (only on Chrome and Safari). Defaults to `StripeElement--webkit-autofill`. - `style` (object) Customize the appearance of this element using CSS properties passed in a [Style](/js/appendix/style.md) object. - `value` (object) A pre-filled set of values to include in the input. Note that sensitive card information (card number, CVC, and expiration date) cannot be pre-filled. - `postalCode` (string) - `hidePostalCode` (boolean) Hide the postal code field. Default is `false`. If you are already collecting a full billing address or postal code elsewhere, set this to `true`. - `iconStyle` (string) Appearance of the icon in the Element. Either `solid` or `default`. - `hideIcon` (boolean) Hides the icon in the Element. Default is `false`. - `disabled` (boolean) Applies a disabled state to the Element such that user input is not accepted. Default is `false`. ### Update a card element ```js // Update an element with details collected elsewhere on your page var myPostalCodeField = document.querySelector('input[name="my-postal-code"]'); myPostalCodeField.addEventListener('change', function(event) { cardElement.update({value: {postalCode: event.target.value}}); }); // Dynamically change the styles of an element window.addEventListener('resize', function(event) { if (window.innerWidth <= 320) { cardElement.update({style: {base: {fontSize: '13px'}}}); } else { cardElement.update({style: {base: {fontSize: '16px'}}}); } }); ``` ```es_next // Update an element with details collected elsewhere on your page const myPostalCodeField = document.querySelector( 'input[name="my-postal-code"]', ); myPostalCodeField.addEventListener('change', ({target}) => { cardElement.update({value: {postalCode: target.value}}); }); // Dynamically change the styles of an element window.addEventListener('resize', (event) => { if (window.innerWidth <= 320) { cardElement.update({style: {base: {fontSize: '13px'}}}); } else { cardElement.update({style: {base: {fontSize: '16px'}}}); } }); ``` #### cardNumber - `options` (object) Options for updating a `cardNumber` element. - `classes` (object) Set custom class names on the container DOM element when the Stripe element is in a particular state. - `base` (string) The base class applied to the container. Defaults to `StripeElement`. - `complete` (string) The class name to apply when the `Element` is complete. Defaults to `StripeElement--complete`. - `empty` (string) The class name to apply when the `Element` is empty. Defaults to `StripeElement--empty`. - `focus` (string) The class name to apply when the `Element` is focused. Defaults to `StripeElement--focus`. - `invalid` (string) The class name to apply when the `Element` is invalid. Defaults to `StripeElement--invalid`. - `webkitAutofill` (string) The class name to apply when the `Element` has its value autofilled by the browser (only on Chrome and Safari). Defaults to `StripeElement--webkit-autofill`. - `style` (object) Customize the appearance of this element using CSS properties passed in a [Style](/js/appendix/style.md) object. - `placeholder` (string) Customize the placeholder text. - `disabled` (boolean) Applies a disabled state to the Element such that user input is not accepted. Default is `false`. - `showIcon` (boolean) Show a card brand icon in the Element. Default is `false`. - `iconStyle` (string) Appearance of the icon in the Element. Either `solid` or `default`. ### Update a cardNumber Element ```js cardNumberElement.update(options); ``` ```es_next cardNumberElement.update(options); ``` #### cardExpiry - `options` (object) Options for updating a `cardExpiry` element. - `classes` (object) Set custom class names on the container DOM element when the Stripe element is in a particular state. - `base` (string) The base class applied to the container. Defaults to `StripeElement`. - `complete` (string) The class name to apply when the `Element` is complete. Defaults to `StripeElement--complete`. - `empty` (string) The class name to apply when the `Element` is empty. Defaults to `StripeElement--empty`. - `focus` (string) The class name to apply when the `Element` is focused. Defaults to `StripeElement--focus`. - `invalid` (string) The class name to apply when the `Element` is invalid. Defaults to `StripeElement--invalid`. - `webkitAutofill` (string) The class name to apply when the `Element` has its value autofilled by the browser (only on Chrome and Safari). Defaults to `StripeElement--webkit-autofill`. - `style` (object) Customize the appearance of this element using CSS properties passed in a [Style](/js/appendix/style.md) object. - `placeholder` (string) Customize the placeholder text. - `disabled` (boolean) Applies a disabled state to the Element such that user input is not accepted. Default is `false`. ### Update a cardExpiry Element ```js cardExpiryElement.update(options); ``` ```es_next cardExpiryElement.update(options); ``` #### cardCvc - `options` (object) Options for updating a `cardCvc` element. - `classes` (object) Set custom class names on the container DOM element when the Stripe element is in a particular state. - `base` (string) The base class applied to the container. Defaults to `StripeElement`. - `complete` (string) The class name to apply when the `Element` is complete. Defaults to `StripeElement--complete`. - `empty` (string) The class name to apply when the `Element` is empty. Defaults to `StripeElement--empty`. - `focus` (string) The class name to apply when the `Element` is focused. Defaults to `StripeElement--focus`. - `invalid` (string) The class name to apply when the `Element` is invalid. Defaults to `StripeElement--invalid`. - `webkitAutofill` (string) The class name to apply when the `Element` has its value autofilled by the browser (only on Chrome and Safari). Defaults to `StripeElement--webkit-autofill`. - `style` (object) Customize the appearance of this element using CSS properties passed in a [Style](/js/appendix/style.md) object. - `placeholder` (string) Customize the placeholder text. - `disabled` (boolean) Applies a disabled state to the Element such that user input is not accepted. Default is `false`. ### Update a cardCvc Element ```js cardCvcElement.update(options); ``` ```es_next cardCvcElement.update(options); ``` #### iban - `options` (object) Options for updating an `iban` element. - `classes` (object) Set custom class names on the container DOM element when the Stripe element is in a particular state. - `base` (string) The base class applied to the container. Defaults to `StripeElement`. - `complete` (string) The class name to apply when the `Element` is complete. Defaults to `StripeElement--complete`. - `empty` (string) The class name to apply when the `Element` is empty. Defaults to `StripeElement--empty`. - `focus` (string) The class name to apply when the `Element` is focused. Defaults to `StripeElement--focus`. - `invalid` (string) The class name to apply when the `Element` is invalid. Defaults to `StripeElement--invalid`. - `webkitAutofill` (string) The class name to apply when the `Element` has its value autofilled by the browser (only on Chrome and Safari). Defaults to `StripeElement--webkit-autofill`. - `style` (object) Customize the appearance of this element using CSS properties passed in a [Style](/js/appendix/style.md) object. - `supportedCountries` (array) Specify the list of countries or country-groups whose IBANs you want to allow. Must be `['SEPA']`. - `placeholderCountry` (string) Customize the country and format of the placeholder IBAN. Default is `DE`. - `iconStyle` (string) Appearance of the icon in the Element. Either `solid` or `default`. - `hideIcon` (boolean) Hides the icon in the Element. Default is `false`. - `disabled` (boolean) Applies a disabled state to the Element such that user input is not accepted. Default is `false`. ### Update an iban Element ```js ibanElement.update(options); ``` ```es_next ibanElement.update(options); ``` #### paymentRequestButton - `options` (object) **required** Options for updating a `paymentRequestButton` element. - `classes` (object) Set custom class names on the container DOM element when the Stripe element is in a particular state. - `base` (string) The base class applied to the container. Defaults to `StripeElement`. - `complete` (string) The class name to apply when the `Element` is complete. Defaults to `StripeElement--complete`. - `empty` (string) The class name to apply when the `Element` is empty. Defaults to `StripeElement--empty`. - `focus` (string) The class name to apply when the `Element` is focused. Defaults to `StripeElement--focus`. - `invalid` (string) The class name to apply when the `Element` is invalid. Defaults to `StripeElement--invalid`. - `webkitAutofill` (string) The class name to apply when the `Element` has its value autofilled by the browser (only on Chrome and Safari). Defaults to `StripeElement--webkit-autofill`. - `style` (object) An object used to customize the appearance of the Payment Request Button. The object must have a single `paymentRequestButton` field, containing any of the following sub-fields: - `type` (string) Preferred button type to display. Available types, by wallet: Browser card: `default`, `book`, `buy`, or `donate`. Google Pay: `default`, `buy`, or `donate`. Apple Pay: `default`, `book`, `buy`, `donate`, `check-out`, `subscribe`, `reload`, `add-money`, `top-up`, `order`, `rent`, `support`, `contribute`, `tip` When a wallet does not support the provided value, `default` is used as a fallback. - `theme` (string) One of `dark`, `light`, or `light-outline`. The default is `dark`. - `height` (string) The height of the Payment Request Button. Accepts `px` unit values. - `paymentRequest` (PaymentRequest) **required** A [PaymentRequest](/js/payment_request.md) object used to configure the element. ### Update a paymentRequestButton Element ```js paymentRequestButtonElement.update(options); ``` ```es_next paymentRequestButtonElement.update(options); ``` #### auBankAccount - `options` (object) Options for updating an `auBankAccount` element. - `classes` (object) Set custom class names on the container DOM element when the Stripe element is in a particular state. - `base` (string) The base class applied to the container. Defaults to `StripeElement`. - `complete` (string) The class name to apply when the `Element` is complete. Defaults to `StripeElement--complete`. - `empty` (string) The class name to apply when the `Element` is empty. Defaults to `StripeElement--empty`. - `focus` (string) The class name to apply when the `Element` is focused. Defaults to `StripeElement--focus`. - `invalid` (string) The class name to apply when the `Element` is invalid. Defaults to `StripeElement--invalid`. - `webkitAutofill` (string) The class name to apply when the `Element` has its value autofilled by the browser (only on Chrome and Safari). Defaults to `StripeElement--webkit-autofill`. - `style` (object) Customize the appearance of this element using CSS properties passed in a [Style](/js/appendix/style.md) object. - `iconStyle` (string) Appearance of the icon in the Element. Either `solid` or `default`. - `hideIcon` (boolean) Hides the icon in the Element. Default is `false`. - `disabled` (boolean) Applies a disabled state to the Element such that user input is not accepted. Default is `false`. ### Update an auBankAccount Element ```js auBankAccountElement.update({disabled: true}); ``` ```es_next auBankAccountElement.update({disabled: true}); ``` ## Style the Element container Style the container you mount an [Element](/js/element.md) to as if it were an `` on your page. For example, to control `padding` and `border` on an `Element`, set these properties on the container. This is usually done by re-using the classes that you have applied to your DOM `` elements. After the `Element` is mounted, the `.StripeElement` class is added to the container. Additionally, the following classes are automatically added to the container when the `Element` is complete, empty, focused, invalid, or autofilled by the browser: * `.StripeElement--complete` * `.StripeElement--empty` * `.StripeElement--focus` * `.StripeElement--invalid` * `.StripeElement--webkit-autofill` (Chrome and Safari only) These class names can be customized using the `classes` [option](/js/elements_object/create_element.md#elements_create-options-classes) when you [create an Element](#elements_create). ### The Element container ```html
``` ## Input validation Stripe elements validate customer input as it is typed. To help your customers catch mistakes, listen to `change` events on an `Element` and display any errors. ### Display validation errors from an Element ```js cardElement.on('change', function(event) { var displayError = document.getElementById('card-errors'); if (event.error) { displayError.textContent = event.error.message; } else { displayError.textContent = ''; } }); ``` ```es_next cardElement.on('change', ({error}) => { const displayError = document.getElementById('payment-errors'); if (error) { displayError.textContent = error.message; } }); ``` ## Postal code formatting The `card` element automatically determines your customer’s billing address country based on their card number. Using this information, the postal code field validation reflects whether that country uses numeric or alphanumeric-formatted postal codes, or if the country uses postal codes at all. For instance, if a U.S. card is entered, the postal code field only accepts a five-digit numeric value. If it’s a UK card, an alphanumeric value can be provided instead. Many of our test cards have a U.S. billing address country. When using these to test your payment form, you must also use a five-digit U.S. ZIP code (e.g., 12345). To test elements with other postal code formats, use our [international test card numbers](/testing.md#international-cards). ## Mount an Element The `element.mount` method attaches your [Element](/js/element.md) to the DOM. `element.mount` accepts either a CSS Selector (e.g., `'#payment-element'`) or a DOM element. You need to create a container DOM element to mount an `Element`. Add an empty placeholder `div` to your payment form for each Element that you'll mount. Stripe inserts an iframe into each `div` to securely collect payment information. **Syntax:** `element.mount(...)` - `domElement` (string | DOM element) **required** The CSS selector or DOM element where your [Element](/js/element.md) will be mounted. ### Mount an Element ```html
``` ## Element methods Below are a number of methods that are in common between all [Element](/js/element.md) UIs. Wait until the [ready event](/js/element/events/on_ready.md) is triggered before calling these methods. ## Blur an Element Blurs the [Element](/js/element.md). **Syntax:** `element.blur(...)` ### Blur an Element ```js paymentElement.blur(); ``` ```es_next paymentElement.blur(); ``` ## Clear an Element's values Clears the value(s) of the [Element](/js/element.md). **Syntax:** `element.clear(...)` ### Clear an Element ```js paymentElement.clear(); ``` ```es_next paymentElement.clear(); ``` ## Destroy an Element Removes the [Element](/js/element.md) from the DOM and destroys it. A destroyed `Element` can not be re-activated or re-mounted to the DOM. **Syntax:** `element.destroy(...)` ### Destroy an Element ```js paymentElement.destroy(); ``` ```es_next paymentElement.destroy(); ``` ## Focus an Element Focuses the [Element](/js/element.md). > This method will currently not work on iOS 13+ due to a system limitation. **Syntax:** `element.focus(...)` ### Focus an Element ```js paymentElement.focus(); ``` ```es_next paymentElement.focus(); ``` ## Unmount an Element Unmounts the [Element](/js/element.md) from the DOM. Call [`element.mount`](/js/element/mount.md) to re-attach it to the DOM. **Syntax:** `element.unmount(...)` ### Unmount an Element ```js paymentElement.unmount(); ``` ```es_next paymentElement.unmount(); ``` ## Element events Communicate with your [Element](/js/element.md) by listening to an event. An Element might emit any of the events below. All events have a payload object that has an `elementType` property with the type of the `Element` that emitted the event. ## Change event The change event is triggered when any value in the change event payload changes. The event payload always contains certain keys, in addition to some `Element`-specific keys. > Consult with your legal counsel regarding your requirements and obligations about how you collect, use, and store customers' personal data **Syntax:** `element.on(...)` #### paymentElement - `event` ('change') **required** The name of the event. In this case, `change`. - `handler` (function) **required** `handler(event) => void` is a **callback function** that you provide that will be called when the event is fired. When called it will pass an event object with the following properties: - `elementType` (string) The type of element that emitted this event. - `empty` (boolean) `true` if the value is empty. - `complete` (boolean) `true` if all required fields for the selected payment method in the Payment Element have been filled with potentially valid input. - `collapsed` (boolean) `true` if the Payment Element is currently collapsed - `value` (object) An object containing the current selected PaymentMethod type. If a [saved payment method](/payments/save-customer-payment-methods.md) is selected, it will be included in the object. - `type` (string) The type of payment method that was selected. - `payment_method` (object) The currently selected saved payment method attached to the customer. - `id` (string) The ID of the saved payment method. - `type` (string) The type of saved payment method that was selected. - `billing_details` (object) The billing details for the saved payment method. - `address` (object) - `line1` (string) - `line2` (string) - `city` (string) - `state` (string) - `postal_code` (string) - `country` (string) - `email` (string) - `name` (string) - `phone` (string) - `billingDetails` (object) The billing details for the selected payment method. Only postalCode and country are available in the change event. These fields will only appear in the change event if the input is being rendered for the selected payment method. - `postalCode` (string) - `country` (string) - `savePaymentMethod` (boolean) Whether the customer opted in to saving their payment method for future purchases. ### Handle a payment element change event ```js paymentElement.on('change', function(event) { if (event.complete) { // enable payment button } }); ``` ```es_next paymentElement.on('change', (event) => { if (event.complete) { // enable payment button } }); ``` #### linkAuthenticationElement - `event` ('change') **required** The name of the event. In this case, `change`. - `handler` (function) **required** `handler(event) => void` is a **callback function** that you provide that will be called when the event is fired. When called it will pass an event object with the following properties: - `elementType` (string) The type of element that emitted this event. - `empty` (boolean) `true` if the value is empty. - `complete` (boolean) `true` if the value is well-formed and potentially complete. The `complete` value can be used to progressively disclose the next parts of your form or to enable form submission. It is not an indicator of whether a customer is done with their input—it only indicates that the Element contains a potentially complete, well-formed value. In many cases the customer could still add further input. The `complete` value should not be used to perform an action such as advancing the cursor to a subsequent field or performing a tokenization request. - `value` (object) An object containing the current email. ### Handle a link authentication element change event ```js linkAuthenticationElement.on('change', function(event) { if (event.complete) { // Handle change complete event } }); ``` ```es_next linkAuthenticationElement.on('change', (event) => { if (event.complete) { // Handle change complete event } }); ``` #### addressElement - `event` ('change') **required** The name of the event. In this case, `change`. - `handler` (function) **required** `handler(event) => void` is a **callback function** that you provide that will be called when the event is fired. When called it will pass an event object with the following properties: - `elementType` (string) The type of element that emitted this event. - `empty` (boolean) `true` if the value is empty. - `complete` (boolean) `true` if the value is well-formed and potentially complete. The `complete` value can be used to progressively disclose the next parts of your form or to enable form submission. It is not an indicator of whether a customer is done with their input—it only indicates that the Element contains a potentially complete, well-formed value. In many cases the customer could still add further input. The `complete` value should not be used to perform an action such as advancing the cursor to a subsequent field or performing a tokenization request. - `isNewAddress` (boolean) `true` if the Address Element is currently displaying the form collection view. - `value` (object) An object containing the current address information. The `firstName` and `lastName` properties only appear if the `display.name` option is set to `split`. The `phone` property only appears if the `fields.phone` option is set to `always`. ### Handle an address element change event ```js addressElement.on('change', function(event) { if (event.complete) { // extract potentially complete address } }); ``` ```es_next addressElement.on('change', (event) => { if (event.complete) { // extract potentially complete address } }); ``` #### cardElement - `event` ('change') **required** The name of the event. In this case, `change`. - `handler` (function) **required** `handler(event) => void` is a **callback function** that you provide that will be called when the event is fired. When called it will pass an event object with the following properties: - `elementType` (string) The type of element that emitted this event. - `empty` (boolean) `true` if the value is empty. - `complete` (boolean) `true` if the value is well-formed and potentially complete. The `complete` value can be used to progressively disclose the next parts of your form or to enable form submission. It is not an indicator of whether a customer is done with their input—it only indicates that the Element contains a potentially complete, well-formed value. In many cases the customer could still add further input. The `complete` value should not be used to perform an action such as advancing the cursor to a subsequent field or performing a tokenization request. - `error` (object) The current validation error, if any. Comprised of `message`, `code`, and `type`. The `type` is always set to `validation_error`. - `brand` (string) The card brand of the card number being entered. Can be one of `visa`, `mastercard`, `amex`, `discover`, `diners`, `jcb`, `unionpay`, `link`, or `unknown`. ### Handle a card change event ```js cardElement.on('change', function(event) { if (event.complete) { // enable payment button } else if (event.error) { // show validation to customer } }); ``` ```es_next cardElement.on('change', (event) => { if (event.complete) { // enable payment button } else if (event.error) { // show validation to customer } }); ``` #### cardNumberElement - `event` ('change') **required** The name of the event. In this case, `change`. - `handler` (function) **required** `handler(event) => void` is a **callback function** that you provide that will be called when the event is fired. When called it will pass an event object with the following properties: - `elementType` (string) The type of element that emitted this event. - `empty` (boolean) `true` if the value is empty. - `complete` (boolean) `true` if the value is well-formed and potentially complete. The `complete` value can be used to progressively disclose the next parts of your form or to enable form submission. It is not an indicator of whether a customer is done with their input—it only indicates that the Element contains a potentially complete, well-formed value. In many cases the customer could still add further input. The `complete` value should not be used to perform an action such as advancing the cursor to a subsequent field or performing a tokenization request. - `error` (object) The current validation error, if any. Comprised of `message`, `code`, and `type`. The `type` is always set to `validation_error`. - `brand` (string) The card brand of the card number being entered. Can be one of `visa`, `mastercard`, `amex`, `discover`, `diners`, `jcb`, `unionpay`, `link`, or `unknown`. ### Handle a cardNumber change event ```js cardNumberElement.on('change', function(event) { if (event.error) { // show validation to customer } }); ``` ```es_next cardNumberElement.on('change', (event) => { if (event.error) { // show validation to customer } }); ``` #### cardExpiryElement - `event` ('change') **required** The name of the event. In this case, `change`. - `handler` (function) **required** `handler(event) => void` is a **callback function** that you provide that will be called when the event is fired. When called it will pass an event object with the following properties: - `elementType` (string) The type of element that emitted this event. - `empty` (boolean) `true` if the value is empty. - `complete` (boolean) `true` if the value is well-formed and potentially complete. The `complete` value can be used to progressively disclose the next parts of your form or to enable form submission. It is not an indicator of whether a customer is done with their input—it only indicates that the Element contains a potentially complete, well-formed value. In many cases the customer could still add further input. The `complete` value should not be used to perform an action such as advancing the cursor to a subsequent field or performing a tokenization request. - `error` (object) The current validation error, if any. Comprised of `message`, `code`, and `type`. The `type` is always set to `validation_error`. ### Handle a cardExpiry change event ```js cardExpiryElement.on('change', function(event) { if (event.error) { // show validation to customer } }); ``` ```es_next cardExpiryElement.on('change', (event) => { if (event.error) { // show validation to customer } }); ``` #### cardCvcElement - `event` ('change') **required** The name of the event. In this case, `change`. - `handler` (function) **required** `handler(event) => void` is a **callback function** that you provide that will be called when the event is fired. When called it will pass an event object with the following properties: - `elementType` (string) The type of element that emitted this event. - `empty` (boolean) `true` if the value is empty. - `complete` (boolean) `true` if the value is well-formed and potentially complete. The `complete` value can be used to progressively disclose the next parts of your form or to enable form submission. It is not an indicator of whether a customer is done with their input—it only indicates that the Element contains a potentially complete, well-formed value. In many cases the customer could still add further input. The `complete` value should not be used to perform an action such as advancing the cursor to a subsequent field or performing a tokenization request. - `error` (object) The current validation error, if any. Comprised of `message`, `code`, and `type`. The `type` is always set to `validation_error`. ### Handle a cardCvc change event ```js cardCvcElement.on('change', function(event) { if (event.error) { // show validation to customer } }); ``` ```es_next cardCvcElement.on('change', (event) => { if (event.error) { // show validation to customer } }); ``` #### auBankAccountElement - `event` ('change') **required** The name of the event. In this case, `change`. - `handler` (function) **required** `handler(event) => void` is a **callback function** that you provide that will be called when the event is fired. When called it will pass an event object with the following properties: - `elementType` (string) The type of element that emitted this event. - `empty` (boolean) `true` if the BSB number and account number are empty. - `complete` (boolean) `true` if the value is well-formed and potentially complete. The value is potentially complete when the BSB number is a known BSB number and when the account number matches the length required by the bank (or is between 5-9 digits for banks without a specific account number length). - `error` (object) The current validation error, if any. Comprised of `message`, `code`, and `type`. The `type` is always set to `validation_error`. - `bankName` (string) The financial institution corresponding to BSB number entered into the Element. - `branchName` (string) The financial institution’s branch name corresponding to BSB number entered into the Element. ### Handle an auBankAccount change event ```js auBankAccountElement.on('change', function(event) { if (event.error) { // show validation to customer } else if (event.bankName && event.branchName) { // show both bank and branch name } else if (event.bankName) { // show bank name } }); ``` ```es_next auBankAccountElement.on('change', (event) => { if (event.error) { // show validation to customer } else if (event.bankName && event.branchName) { // show both bank and branch name } else if (event.bankName) { // show bank name } }); ``` #### ibanElement - `event` ('change') **required** The name of the event. In this case, `change`. - `handler` (function) **required** `handler(event) => void` is a **callback function** that you provide that will be called when the event is fired. When called it will pass an event object with the following properties: - `elementType` (string) The type of element that emitted this event. - `empty` (boolean) `true` if the value is empty. - `complete` (boolean) `true` if the value is well-formed and potentially complete. The `complete` value can be used to progressively disclose the next parts of your form or to enable form submission. It is not an indicator of whether a customer is done with their input—it only indicates that the Element contains a potentially complete, well-formed value. In many cases the customer could still add further input. The `complete` value should not be used to perform an action such as advancing the cursor to a subsequent field or performing a tokenization request. - `error` (object) The current validation error, if any. Comprised of `message`, `code`, and `type`. The `type` is always set to `validation_error`. - `country` (string) The country code of the entered IBAN. - `bankName` (string) The financial institution that services the account whose IBAN was entered into the Element. ### Handle an iban change event ```js ibanElement.on('change', function(event) { if (event.error) { // show validation to customer } }); ``` ```es_next ibanElement.on('change', (event) => { if (event.error) { // show validation to customer } }); ``` #### taxIdElement - `event` ('change') **required** The name of the event. In this case, `change`. - `handler` (function) **required** `handler(event) => void` is a **callback function** that you provide that will be called when the event is fired. When called it will pass an event object with the following properties: - `elementType` (string) The type of element that emitted this event. - `empty` (boolean) `true` if both the business name and tax ID fields are empty. - `complete` (boolean) `true` if all required fields in the Tax ID Element have been filled with potentially valid input. - `visible` (boolean) `true` if the Tax ID Element is visible based on the `visibility` option and country. - `value` (object) An object containing the current tax ID information. The `taxIdType` value corresponds to the selected country-specific type in the Tax ID Element. The `externalTaxIdType` value corresponds to the tax ID type you would pass to Stripe APIs (for example, EU countries use `eu_vat`). - `businessName` (string) The business name entered in the Tax ID Element. - `taxId` (string) The tax ID value entered in the Tax ID Element. - `taxIdType` (string) The selected tax ID type in the Tax ID Element (for example, `de_vat`). - `externalTaxIdType` (string) The tax ID type that corresponds to Stripe API values (for example, `eu_vat`). ### Handle a tax ID element change event ```js taxIdElement.on('change', function(event) { if (event.complete) { // Read tax ID details from event.value } }); ``` ```es_next taxIdElement.on('change', (event) => { if (event.complete) { // Read tax ID details from event.value } }); ``` ## Ready event Triggered when the `Element` is fully rendered and methods on the instance, like `element.focus()` and `element.update()`, can be called. **Syntax:** `element.on(...)` - `event` ('ready') **required** The name of the event. In this case, `ready`. - `handler` (function) **required** `handler(event) => void` is a **callback function** that you provide that will be called when the event is fired. After it's called, it passes an event object with the following properties: - `elementType` (string) **required** The type of element the event is fired from. - `availablePaymentMethods` (object | undefined) This field is **only** present on the `expressCheckout` Element. Describes which buttons render in the Element. Returns undefined if no buttons will render. - `link` (boolean) - `applePay` (boolean) - `googlePay` (boolean) - `paypal` (boolean) - `amazonPay` (boolean) - `klarna` (boolean) ### Handle an Element ready event ```js element.on('ready', function(event) { // Handle ready event }); ``` ```es_next element.on('ready', (event) => { // Handle ready event }); ``` ## Focus event Triggered when the `Element` gains focus. **Syntax:** `element.on(...)` - `event` ('focus') **required** The name of the event. In this case, `focus`. - `handler` (function) **required** `handler(event) => void` is a **callback function** that you provide that will be called when the event is fired. ### Handle an Element focus event ```js element.on('focus', function(event) { // Handle focus event }); ``` ```es_next element.on('focus', (event) => { // Handle focus event }); ``` ## Blur event Triggered when the `Element` loses focus. **Syntax:** `element.on(...)` - `event` ('blur') **required** The name of the event. In this case, `blur`. - `handler` (function) **required** `handler(event) => void` is a **callback function** that you provide that will be called when the event is fired. ### Handle an Element blur event ```js element.on('blur', function(event) { // Handle blur event }); ``` ```es_next element.on('blur', (event) => { // Handle blur event }); ``` ## Escape event Triggered when the escape key is pressed within an Element. **Syntax:** `element.on(...)` - `event` ('escape') **required** The name of the event. In this case, `escape`. - `handler` (function) **required** `handler(event) => void` is a **callback function** that you provide that will be called when the event is fired. ### Handle an Element escape event ```js element.on('escape', function(event) { // Handle escape event }); ``` ```es_next element.on('escape', (event) => { // Handle escape event }); ``` ## Click event **Syntax:** `element.on(...)` #### expressCheckoutElement The `click` event is triggered from an Express Checkout Element when the customer clicks a payment button. Use this event to configure the payment interface. - `event` ('click') **required** The name of the event. In this case, `click`. - `handler` (function) **required** `handler(event) => void` is a **callback function** you provide that's called after the event is fired. After it's called, it passes an event object with the following properties: - `elementType` ('expressCheckout') **required** The type of element the event is fired from, which is `expressCheckout` in this case. - `expressPaymentType` ('apple_pay' | 'google_pay' | 'amazon_pay' | 'paypal' | 'link' | 'klarna') **required** The payment method the customer checks out with. - `resolve` (function) **required** A function `resolve(payload) => void` that's called to show the payment interface. You must call this function within 1 second if you handle the `click` event. - `allowedShippingCountries (deprecated)` (array) _This parameter has been deprecated in favor of the `allowedShippingCountries` param on the [create](/js/elements_object/create_express_checkout_element.md#express_checkout_element_create-options-allowedShippingCountries) function._ By default, the Express Checkout Element allows all countries for shipping. You can specify which countries are allowed for shipping in the Express Checkout Element with a list of two-letter country codes. - `applePay` (object) Specify Apple Pay specific options. These are passed through to the Apple Pay API. - `recurringPaymentRequest` (object) Specify a request to set up a recurring payment. See the [Apple Pay documentation](https://developer.apple.com/documentation/apple_pay_on_the_web/applepayrecurringpaymentrequest) for more details. - `paymentDescription` (string) **required** - `managementURL` (string) **required** - `regularBilling` (object) **required** - `amount` (number) **required** - `label` (string) **required** - `recurringPaymentStartDate` (Date) - `recurringPaymentEndDate` (Date) - `recurringPaymentIntervalUnit` ('year' | 'month' | 'day' | 'hour' | 'minute') - `recurringPaymentIntervalCount` (number) - `trialBilling` (object) - `amount` (number) **required** - `label` (string) **required** - `recurringPaymentStartDate` (Date) - `recurringPaymentEndDate` (Date) - `recurringPaymentIntervalUnit` ('year' | 'month' | 'day' | 'hour' | 'minute') - `recurringPaymentIntervalCount` (number) - `billingAgreement` (string) - `deferredPaymentRequest` (object) Specify a request to set up a deferred payment. See the [Apple Pay documentation](https://developer.apple.com/documentation/apple_pay_on_the_web/applepaydeferredpaymentrequest) for more details. - `paymentDescription` (string) **required** - `managementURL` (string) **required** - `deferredBilling` (object) **required** - `amount` (number) **required** - `label` (string) **required** - `deferredPaymentDate` (Date) **required** - `billingAgreement` (string) - `freeCancellationDate` (Date) If set, you must also supply a freeCancellationDateTimeZone. - `freeCancellationDateTimeZone` (string) If set, you must also supply a freeCancellationDate. These are [tz](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) timezones such as `America/Los_Angeles`, `Europe/Dublin`, and `Asia/Singapore`. - `automaticReloadPaymentRequest` (object) Specify a request to set up an automatic reload payment. See the [Apple Pay documentation](https://developer.apple.com/documentation/apple_pay_on_the_web/applepayautomaticreloadpaymentrequest) for more details. - `paymentDescription` (string) **required** - `managementURL` (string) **required** - `automaticReloadBilling` (object) **required** - `amount` (number) **required** - `label` (string) **required** - `automaticReloadPaymentThresholdAmount` (number) **required** - `billingAgreement` (string) - `billingAddressRequired (deprecated)` (boolean) _This parameter has been deprecated in favor of the `billingAddressRequired` param on the [create](/js/elements_object/create_express_checkout_element.md#express_checkout_element_create-options-billingAddressRequired) function._ By default, the Express Checkout Element collects the billing address. You can disable this by setting `billingAddressRequired` to `false`. We highly recommend that you collect the billing address because it can be used to perform address verifications and block fraudulent payments. - `business (deprecated)` (object) _This parameter has been deprecated in favor of the `business` param on the [create](/js/elements_object/create_express_checkout_element.md#express_checkout_element_create-options-business) function._ Provide information about your business that's displayed in the Express Checkout Element. This information will be retrieved from your Stripe account if it's not provided. - `name` (string) The name of your business. Your business name is used to signal to the customer who they're paying. Klarna always retrieves the business name from your Stripe account, even when this option is set. - `emailRequired (deprecated)` (boolean) _This parameter has been deprecated in favor of the `emailRequired` param on the [create](/js/elements_object/create_express_checkout_element.md#express_checkout_element_create-options-emailRequired) function._ Collect the customer's email by setting this option to `true`. - `lineItems` (array) An array of LineItem objects. These LineItems are shown as line items in the payment interface, if line items are supported. You can represent discounts as negative amount LineItems. - `name` (string) **required** The name of the line item surfaced to the customer in the payment interface. - `amount` (number) **required** The amount in the currency's subunit (for example, cents, yen, etc.). - `phoneNumberRequired (deprecated)` (boolean) _This parameter has been deprecated in favor of the `phoneNumberRequired` param on the [create](/js/elements_object/create_express_checkout_element.md#express_checkout_element_create-options-phoneNumberRequired) function._ Collect the customer's phone number by setting this option to `true`. PayPal doesn't provide a phone number, even when this option is set to `true`. - `shippingAddressRequired (deprecated)` (boolean) _This parameter has been deprecated in favor of the `shippingAddressRequired` param on the [create](/js/elements_object/create_express_checkout_element.md#express_checkout_element_create-options-shippingAddressRequired) function._ Collect the customer's shipping address by setting this option to `true`. If `true`, you must also supply a valid `shippingRates` option in either the `create`, `click`, or `shippingaddresschange` events. - `shippingRates` (array) An array of ShippingRate objects. The first shipping rate listed appears in the payment interface as the default option. - `id` (string) **required** Unique identifier for the object. - `amount` (number) **required** The amount to charge for shipping. - `displayName` (string) **required** The name of the shipping rate, displayed to the customer in the payment interface. - `deliveryEstimate` (object | string) The estimated range for how long shipping takes, displayed to the customer in the payment interface. We recommended using the object format, but you can use a string instead. - `maximum` (object) The upper bound of the estimated range. If empty, it represents no upper bound (for example, infinite). - `unit` ('hour' | 'day' | 'business_day' | 'week' | 'month') A unit of time. - `value` (number) Must be greater than 0. - `minimum` (object) The lower bound of the estimated range. If empty, it represents no lower bound. - `unit` ('hour' | 'day' | 'business_day' | 'week' | 'month') A unit of time. - `value` (number) Must be greater than 0. - `reject` (function) **required** A function `reject() => void` that's called to cancel the payment interface. You must call this function within 1 second if you handle the `click` event. ### Handle an express checkout element click event ```js expressCheckoutElement.on('click', function(event) { // Handle click event }); ``` ```es_next expressCheckoutElement.on('click', (event) => { // Handle click event }); ``` #### paymentRequestButton Triggered when the `Element` is clicked. - `event` ('click') **required** The name of the event. In this case, `click`. - `handler` (function) **required** `handler(event) => void` is a **callback function** that you provide that will be called when the event is fired. After it's called, it passes an event object with the following properties: - `preventDefault` (function) Calling this function synchronously prevents the browser's payment interface from being shown. If you have your own form validation logic, you can call this when form validation fails. ### Handle a payment request button click event ```js paymentRequestButtonElement.on('click', function(event) { // If form validation fails if (!formValidated) { event.preventDefault(); } }); ``` ```es_next paymentRequestButtonElement.on('click', (event) => { // If form validation fails if (!formValidated) { event.preventDefault(); } }); ``` #### issuingCardCopyButton Triggered when the `Element` is clicked. - `event` ('click') **required** The name of the event. In this case, `click`. - `handler` (function) **required** `handler(event) => void` is a **callback function** that you provide that will be called when the event is fired. When called it will be passed an event object with the following properties: - `preventDefault` (function) Calling this function synchronously prevents the browser's payment interface from being shown. This can be used to validate the form before the payment interface is shown. ### Handle an issuing card copy button click event ```js issuingCardCopyButtonElement.on('click', function(event) { // Handle click event }); ``` ```es_next issuingCardCopyButtonElement.on('click', (event) => { // Handle click event }); ``` ## LoadError event Triggered when the `Element` fails to load. **This event is only emitted from the `payment`, `linkAuthentication`, `address`, `expressCheckout`, `currencySelector`, `taxId`, `card`, and `cardNumber` Elements.** **Syntax:** `element.on(...)` - `event` ('loaderror') **required** The name of the event. In this case, `loaderror`. - `handler` (function) **required** `handler(event) => void` is a **callback function** that you provide that will be called when the event is fired. When called it will be passed an event object with the following properties: - `elementType` (string) The type of element that emitted this event. - `error` (object) An `error` object that describes the failure. ### Handle an Element loaderror event ```js paymentElement.on('loaderror', function(event) { // Handle loaderror event }); ``` ```es_next paymentElement.on('loaderror', (event) => { // Handle loaderror event }); ``` ## LoadStart event Triggered when the [loader](/js/elements_object/create.md#stripe_elements-options-loader) UI is mounted to the DOM and ready to be displayed. **This event is only emitted from the `payment`, `linkAuthentication`, and `address` Elements.** **Syntax:** `element.on(...)` - `event` ('loaderstart') **required** The name of the event. In this case, `loaderstart`. - `handler` (function) **required** `handler(event) => void` is a **callback function** that you provide that will be called when the event is fired. When called it will be passed an event object with the following properties: - `elementType` (string) The type of element that emitted this event. ### Handle an Element loaderstart event ```js paymentElement.on('loaderstart', function(event) { // Handle loaderstart event }); ``` ```es_next paymentElement.on('loaderstart', (event) => { // Handle loaderstart event }); ``` ## NetworksChange event Triggered when there is a change to the available networks the provided card can run on. If the list of available networks is still loading, an event with `networks: null` and `loading: true` is triggered. When the list of available networks loads, Stripe triggers an additional event that contains the list of these networks and shows `loading: false`. Refer to our [card brand choice guide](/card-brand-choice.md#identifying-the-available-card-networks) for further details. **Syntax:** `element.on(...)` #### cardElement - `event` ('networkschange') **required** The name of the event. In this case, `networkschange`. - `handler` (function) **required** `handler(event) => void` is a **callback function** that you provide that will be called when the event is fired. When called it will be passed an event object with the following properties: - `loading` (boolean) `true` if the networks are loading. `false` when Stripe returns all the available networks. - `networks` (stringArray | null) All available networks for the card number provided. `null` if the networks are still loading. If eligible for the Card Element's [Card Brand Choice](/card-brand-choice.md) dropdown, this array will be truncated to a single network so that the user is not presented with multiple network selections. ### Handle a card networkschange event ```js cardElement.on('networkschange', function(event) { if (event.networks && event.networks.length >= 1) { // collect card brand preference } }); ``` ```es_next cardElement.on('networkschange', (event) => { if (event.networks && event.networks.length >= 1) { // collect card brand preference } }); ``` #### cardNumberElement - `event` ('networkschange') **required** The name of the event. In this case, `networkschange`. - `handler` (function) **required** `handler(event) => void` is a **callback function** that you provide that will be called when the event is fired. When called it will be passed an event object with the following properties: - `loading` (boolean) `true` if the networks are loading. `false` when Stripe returns all the available networks. - `networks` (stringArray | null) All available networks for the card number provided. `null` if the networks are still loading. If eligible for the Card Element's [Card Brand Choice](/card-brand-choice.md) dropdown, this array will be truncated to a single network so that the user is not presented with multiple network selections. ### Handle a cardNumber networkschange event ```js cardNumberElement.on('networkschange', function(event) { if (event.networks && event.networks.length >= 1) { // collect card brand preference } }); ``` ```es_next cardNumberElement.on('networkschange', (event) => { if (event.networks && event.networks.length >= 1) { // collect card brand preference } }); ``` ## CardDetailsChange event Triggered when there is a change to the selected payment method. If the card details are loading, an event with `brands: null`, `funding: null` and `loading: true` is triggered. When the card details load, Stripe triggers an additional event that contains a `brands` array, `funding` field and `loading: false`. If a non card payment type is selected, Stripe triggers an event with `loading: false` and undefined `details`. > Consult with your legal counsel regarding your requirements and obligations about how you collect, use, and store customers' personal data **Syntax:** `paymentElement.on(...)` - `event` ('carddetailschange') **required** The name of the event. In this case, `carddetailschange`. - `handler` (function) **required** `handler(event) => void` is a **callback function** that you provide that will be called when the event is fired. When called it will be passed an event object with the following properties: - `elementType` ('paymentElement') The type of element that emitted this event. - `loading` (boolean) `true` if the card details are loading. - `details` (object | undefined) Details of the selected card payment method. `undefined` if the selected payment method is not a card. - `brands` (stringArray | null) All potential brands associated with the card. `null` if the card details are loading. Cards can have multiple brands associated with them. Possible values: `amex`, `diners`, `discover`, `eftpos_au`, `jcb`, `mastercard`, `unionpay`, `visa`, `unknown`. - `funding` ('credit' | 'debit' | 'prepaid' | 'unknown' | null) The funding type of the card. `null` if the card details are loading. `unknown` if the funding type can't be determined. ### Handle the Payment Element carddetailschange event ```js paymentElement.on('carddetailschange', function(event) { if (!event.loading) { // Handle carddetailschange event details } }); ``` ```es_next paymentElement.on('carddetailschange', (event) => { if (!event.loading) { // Handle carddetailschange event details } }); ``` ## SavedPaymentMethodUpdate event Triggered when a saved payment method is updated. > Consult with your legal counsel regarding your requirements and obligations about how you collect, use, and store customers' personal data **Syntax:** `paymentElement.on(...)` - `event` ('savedpaymentmethodupdate') **required** The name of the event. In this case, `savedpaymentmethodupdate`. - `handler` (function) **required** `handler(event) => void` is a **callback function** that you provide that will be called when the event is fired. When called it will be passed an event object with the following properties: - `elementType` ('paymentElement') The type of element that emitted this event. - `success` (success) `true` if the saved payment method is successfully updated. - `error` (string | undefined) Error message if the saved payment method is unsuccessfully updated. `undefined` if the saved payment method is successfully updated. - `payment_method` (object) An object containing the updated saved payment method. ### Handle the Payment Element savedpaymentmethodupdate event ```js paymentElement.on('savedpaymentmethodupdate', function(event) { if (event.success) { // Handle savedpaymentmethodupdate event } }); ``` ```es_next paymentElement.on('savedpaymentmethodupdate', (event) => { if (event.success) { // Handle savedpaymentmethodupdate event } }); ``` ## SavedPaymentMethodRemove event Triggered when a saved payment method is removed. > Consult with your legal counsel regarding your requirements and obligations about how you collect, use, and store customers' personal data **Syntax:** `paymentElement.on(...)` - `event` ('savedpaymentmethodremove') **required** The name of the event. In this case, `savedpaymentmethodremove`. - `handler` (function) **required** `handler(event) => void` is a **callback function** that you provide that will be called when the event is fired. When called it will be passed an event object with the following properties: - `elementType` ('paymentElement') The type of element that emitted this event. - `success` (success) `true` if the saved payment method is successfully removed. - `error` (string | undefined) Error message if the saved payment method is unsuccessfully removed. `undefined` if the saved payment method is successfully removed. - `payment_method` (object) An object containing the removed saved payment method. ### Handle the Payment Element savedpaymentmethodremove event ```js paymentElement.on('savedpaymentmethodremove', function(event) { if (event.success) { // Handle savedpaymentmethodremove event } }); ``` ```es_next paymentElement.on('savedpaymentmethodremove', (event) => { if (event.success) { // Handle savedpaymentmethodremove event } }); ```