## Elements with the Checkout Sessions API Build an online checkout page using React, Stripe Elements, and the Checkout Sessions API. See [build a checkout page](https://docs.stripe.com/checkout/custom/quickstart.md) for steps on using Elements with the Checkout Sessions API. The following Stripe.js methods are available to use as part of your integration. ## Initialize the Checkout Elements SDK `stripe.initCheckoutElementsSdk(options?: object)` This method initializes Checkout for [Checkout elements](https://docs.stripe.com/payments/quickstart-checkout-sessions.md) integrations, where you compose individual Elements on your checkout page. - `options` Checkout initialization options. - `clientSecret` The Checkout Session [client secret](https://docs.stripe.com/api/checkout/sessions/object.md#checkout_session_object-client_secret) or a promise that resolves to the client secret. - `elementsOptions` A set of options to configure Elements created with Checkout. - `appearance` Match the design of your site with the [appearance option](https://docs.stripe.com/elements/appearance-api.md). The layout of each Element stays consistent, but you can modify colors, fonts, borders, padding, and more. - `loader` Display skeleton loader UI while waiting for Elements to fully load after they're mounted. Default is `'auto'` (Stripe determines whether or not to show a loader UI). - `fonts` An array of custom fonts that elements created from the `Elements` object can use. You can specify fonts as [CssFontSource](#css_font_source_object) or [CustomFontSource](#custom_font_source_object) objects. - `savedPaymentMethod` Options to configure what Elements displays when used to [Save payment details during payment](https://docs.stripe.com/payments/checkout/save-during-payment.md). - `enableRedisplay` Toggle if Elements redisplays Customer saved Payment Methods. Default is `'auto'`. Prior to Clover, this defaulted to `'never'`. - `enableSave` Toggle if the Payment Element collects consent to save a Customer's Payment Methods. Default is `'auto'`. Prior to Clover, this defaulted to `'never'`. - `syncAddressCheckbox` Used with the [Address Element](https://docs.stripe.com/elements/address-element.md). The `syncAddressCheckbox` parameter configures which Address Element to show the checkbox. The checkbox allows the customer the option to sync billing and shipping addresses when both Billing and Shipping Address Elements are used in a single Elements instance. The default value is `'billing'`. - `adaptivePricing` Options for [Adaptive Pricing](https://docs.stripe.com/payments/currencies/localize-prices/adaptive-pricing.md?payment-ui=embedded-components). - `allowed` Whether Adaptive Pricing can be used with this integration. Default is `false`. [Additional setup](https://docs.stripe.com/payments/currencies/localize-prices/adaptive-pricing.md?payment-ui=embedded-components) is required before you can use Adaptive Pricing with embedded components. - `defaultValues` If customer details are already known, this option may be passed to prefill the Checkout Session and related elements. - `billingAddress` The Customer's billing address. - `name` Full name. - `address` Address. - `country` Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). - `line1` Address line 1 (e.g., street, PO Box, or company name). - `line2` Address line 2 (e.g., apartment, suite, unit, or building). - `city` City, district, suburb, town, or village. - `postal_code` ZIP or postal code. - `state` State, county, province, or region. - `shippingAddress` The Customer's shipping address. - `name` Full name. - `address` Address. - `country` Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). - `line1` Address line 1 (e.g., street, PO Box, or company name). - `line2` Address line 2 (e.g., apartment, suite, unit, or building). - `city` City, district, suburb, town, or village. - `postal_code` ZIP or postal code. - `state` State, county, province, or region. - `email` The Customer's email address. - `phoneNumber` The Customer's phone number. ### Example ```title Initialize the Checkout Elements SDK ``` ## Checkout actions `checkout.loadActions()` After calling [initCheckoutElementsSdk](https://docs.stripe.com/js/custom_checkout/init.md), use `loadActions()` to access methods for reading and manipulating [Checkout Sessions](https://docs.stripe.com/api/checkout/sessions.md). ### Example ```title Checkout actions ``` ## Read session data `actions.getSession()` This method returns an object that contains data about the Checkout Session. ### Example ```title Read session data ``` ## Apply a promotion code `actions.applyPromotionCode(promotionCode: string)` Use this method to apply a promotion code that your customer enters. - `promotionCode` The promotion code to apply to the Checkout Session. ### Example ```title Apply a promotion code ``` ## Remove a promotion code `actions.removePromotionCode()` Use this method to remove the currently applied promotion code, if applicable. ### Example ```title Remove a promotion code ``` ## Update the Customer's shipping address `actions.updateShippingAddress(shippingAddress: nullable object)` Use this method to update the Customer's shipping address. If your integration uses the [Express Checkout Element](https://docs.stripe.com/elements/express-checkout-element.md), the shipping address is collected directly from the wallet and the value set by `updateShippingAddress` is not used for express checkout payments. - `shippingAddress` New shipping address for the Customer. - `name` Full name. - `address` Address. - `country` Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). - `line1` Address line 1 (e.g., street, PO Box, or company name). - `line2` Address line 2 (e.g., apartment, suite, unit, or building). - `city` City, district, suburb, town, or village. - `postal_code` ZIP or postal code. - `state` State, county, province, or region. ### Example ```title Update the Customer's shipping address ``` ## Update the Customer's billing address `actions.updateBillingAddress(billingAddress: nullable object)` Use this method to update the Customer's billing address. If your integration uses the [Express Checkout Element](https://docs.stripe.com/elements/express-checkout-element.md), the billing address is collected directly from the wallet and the value set by `updateBillingAddress` is not used for express checkout payments. - `billingAddress` New billing information for the Customer. - `name` Full name. - `address` Address. - `country` Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). - `line1` Address line 1 (e.g., street, PO Box, or company name). - `line2` Address line 2 (e.g., apartment, suite, unit, or building). - `city` City, district, suburb, town, or village. - `postal_code` ZIP or postal code. - `state` State, county, province, or region. ### Example ```title Update the Customer's billing address ``` ## Update the Customer's email address `actions.updateEmail(email: nullable string)` Use this method to update the Customer's email address. If your integration uses [Link](https://docs.stripe.com/payments/link.md) and you do not provide an email during Checkout Session creation, you must call `updateEmail` for Link to appear as a payment option for returning users. If your integration uses the [Express Checkout Element](https://docs.stripe.com/elements/express-checkout-element.md), the email address is collected directly from the wallet and the value set by `updateEmail` is not used for express checkout payments. - `email` The Customer's email address. ### Example ```title Update the Customer's email address ``` ## Update the Customer's phone number `actions.updatePhoneNumber(phoneNumber: nullable string)` Use this method to update the Customer's phone number. If your integration uses the [Express Checkout Element](https://docs.stripe.com/elements/express-checkout-element.md), the phone number is collected directly from the wallet and the value set by `updatePhoneNumber` is not used for express checkout payments. - `phoneNumber` The Customer's phone number. ### Example ```title Update the Customer's phone number ``` ## Update the Customer's business name and tax ID `actions.updateTaxIdInfo(taxIdInfo?: )` Use this method to update the Customer's business name and tax ID. - `taxIdInfo` The Customer's tax ID information including the business name and tax ID. - `businessName` The Customer's business name. - `taxId` The Customer's tax ID. - `type` One of [the supported tax ID types](https://docs.stripe.com/tax/checkout/tax-ids?payment-ui=embedded-components.md#supported-types) - `value` The value of the tax ID. ### Example ```title Update the Customer's business name and tax ID ``` ## Update line item quantities `actions.updateLineItemQuantity(options: object)` Use this method to change the quantity of a line item. - `options` Options for `updateLineItemQuantity`. - `lineItem` The [ID](https://docs.stripe.com/js/custom_checkout/session_object.md#custom_checkout_session_object-lineItems-id) of the line item to update. - `quantity` The new quantity of the line item. ### Example ```title Update line item quantities ``` ## Update the selected shipping option `actions.updateShippingOption(shippingOption?: string)` Use this method to update the selected shipping option. See [shippingOptions](https://docs.stripe.com/js/custom_checkout/session_object.md#custom_checkout_session_object-shippingOptions) for a list of the available shipping options. - `shippingOption` The [ID](https://docs.stripe.com/js/custom_checkout/session_object.md#custom_checkout_session_object-shippingOptions-id) of the shipping option to select. ### Example ```title Update the selected shipping option ``` ## Confirm the Checkout Session `actions.confirm(options?: object)` Use this method to confirm the Checkout Session. You must either read [total.total.amount](https://docs.stripe.com/js/custom_checkout/session_object.md#custom_checkout_session_object-total-total-amount) or each of [total.total.minorUnitsAmount](https://docs.stripe.com/js/custom_checkout/session_object.md#custom_checkout_session_object-total-total-minorUnitsAmount) and [currency](https://docs.stripe.com/js/custom_checkout/session_object.md#custom_checkout_session_object-currency) and [minorUnitsAmountDivisor](https://docs.stripe.com/js/custom_checkout/session_object.md#custom_checkout_session_object-minorUnitsAmountDivisor) from the checkout object and display in your UI, otherwise an error will be thrown. This helps keep your checkout page in sync as the Checkout Session updates, including adding future Stripe features, with minimal UI code changes. - `options` Options for `confirm`. - `returnUrl` The URL to redirect your customer to after they authenticate or cancel their payment on the payment method’s app or site. This parameter is only required if you didn't specify the `return_url` when creating the Checkout Session. - `paymentMethod` The ID of a previously collected [PaymentMethod](https://docs.stripe.com/api/payment_methods/object.md) to use for confirmation. When this option is provided, Custom Checkout will ignore the payment method collected by the PaymentElement and attempt confirmation using the provided PaymentMethod. - `savePaymentMethod` Whether your Customer has provided consent to save the payment method for future purchases. Learn how to [save payment methods](https://docs.stripe.com/checkout/custom-checkout/save-payment-methods-checkout.md). - `redirect` By default, `confirm` will always redirect to your `returnUrl` after a successful confirmation. If you set `redirect: "if_required"`, then `confirm` will only redirect if your user chooses a redirect-based payment method. - `email` The Customer's email address. If provided, this value overrides any values previously set using [updateEmail](https://docs.stripe.com/js/custom_checkout/update_email.md). - `phoneNumber` The Customer's phone number. If provided, this value overrides any values previously set using [updatePhoneNumber](https://docs.stripe.com/js/custom_checkout/update_phone_number.md). - `billingAddress` The Customer's billing address. If provided, this value overrides any values previously set using [updateBillingAddress](https://docs.stripe.com/js/custom_checkout/update_billing_address.md). - `name` Full name. - `address` Address. - `country` Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). - `line1` Address line 1 (e.g., street, PO Box, or company name). - `line2` Address line 2 (e.g., apartment, suite, unit, or building). - `city` City, district, suburb, town, or village. - `postal_code` ZIP or postal code. - `state` State, county, province, or region. - `shippingAddress` The Customer's shipping address. If provided, this value overrides any values previously set using [updateShippingAddress](https://docs.stripe.com/js/custom_checkout/update_shipping_address.md). - `name` Full name. - `address` Address. - `country` Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). - `line1` Address line 1 (e.g., street, PO Box, or company name). - `line2` Address line 2 (e.g., apartment, suite, unit, or building). - `city` City, district, suburb, town, or village. - `postal_code` ZIP or postal code. - `state` State, county, province, or region. - `expressCheckoutConfirmEvent` The [event object](https://docs.stripe.com/js/elements_object/express_checkout_element_confirm_event.md#express_checkout_element_on_confirm-handler) passed to your Express Checkout Element `confirm` handler. ### Example ```title Confirm the Checkout Session ``` ## Run server update `actions.runServerUpdate(userFunction: function)` Use this method to wrap an async function that makes a request to your server to update the Checkout Session. > `runServerUpdate` enforces a 20-second timeout for your update function. If your function doesn't resolve within 20 seconds, `runServerUpdate` returns an error. Wrap `runServerUpdate` calls in `try`/`catch` blocks to handle any errors. - `userFunction` An async function to make a request to your server to update the Checkout Session. ### Example ```title Run server update ``` ## The Session object The Session object is a view of the [Checkout Session](https://docs.stripe.com/api/checkout/sessions/object.md) API object and represents your customer's session on your checkout page. Because data can change over the lifecycle of a session, avoid storing a reference to the Session object. Instead, call `session()` to retrieve the current value and listen to the [change event](https://docs.stripe.com/js/custom_checkout/change_event.md) to subscribe to updates. - `id` The ID of the Checkout Session. - `billingAddress` Billing details of the Customer. - `name` Full name. - `address` Address. - `country` Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). - `line1` Address line 1 (e.g., street, PO Box, or company name). - `line2` Address line 2 (e.g., apartment, suite, unit, or building). - `city` City, district, suburb, town, or village. - `postal_code` ZIP or postal code. - `state` State, county, province, or region. - `businessName` The business name as configured in the Business Public Details settings of your Stripe account. - `canConfirm` Whether the Checkout Session has collected enough data to confirm. Use this field to indicate to your customer if they can proceed, such as disabling the pay button. - `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://docs.stripe.com/currencies.md). - `currencyOptions` The currency options available on the Checkout Session when using [Adaptive Pricing](https://docs.stripe.com/checkout/custom-checkout/adaptive-pricing.md). - `amount` A formatted string representing the total amount in the source currency, including currency symbols. - `minorUnitsAmount` An integer representing the total amount in the source currency in the [smallest currency unit](https://docs.stripe.com/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. - `currencyConversion` Currency conversion details. This is only present for the customer currency. - `fxRate` The exchange rate used to convert source currency amounts to customer currency amounts. - `sourceCurrency` The creation currency of the Checkout Session before localization. - `discountAmounts` The aggregate amounts calculated per discount for all line items. - `amount` A formatted string representing the discount amount, including currency symbols. - `minorUnitsAmount` An integer representing the discount amount in the [smallest currency unit](https://docs.stripe.com/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `displayName` A user-facing description of the discount. - `promotionCode` The customer-facing promotion code that was used to apply this discount, if any. - `recurring` Details of how the discount applies to recurring payments. - `type` One of `forever` or `repeating`. * `forever`: Applies to all charges from a subscription with this coupon applied. * `repeating`: Applies to charges in the first `durationInMonths` months from a subscription with this coupon applied. - `durationInMonths` If `duration` is `repeating`, the number of months the coupon applies. Null otherwise. - `percentOff` An integer representing the discount amount as a percentage. - `email` The Customer's email address. - `lastPaymentError` The error encountered the last time the Checkout Session was confirmed. - `message` An error message to be displayed to the customer. - `lineItems` A list of items the customer is purchasing. - `id` Unique identifier for the object. - `subtotal` Total before any discounts or exclusive taxes are applied. - `amount` A formatted string representing the subtotal amount, including currency symbols. - `minorUnitsAmount` An integer representing the subtotal amount in the [smallest currency unit](https://docs.stripe.com/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `discount` Total discount amount. A positive number reduces the amount to be paid. - `amount` A formatted string representing the discount amount, including currency symbols. - `minorUnitsAmount` An integer representing the discount amount in the [smallest currency unit](https://docs.stripe.com/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `taxExclusive` Total amount of exclusive tax (tax that is collected in addition to the subtotal). - `amount` A formatted string representing the exclusive tax amount, including currency symbols. - `minorUnitsAmount` An integer representing the exclusive tax amount in the [smallest currency unit](https://docs.stripe.com/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `taxInclusive` Total amount of inclusive tax (tax that is already included in the subtotal). - `amount` A formatted string representing the inclusive tax amount, including currency symbols. - `minorUnitsAmount` An integer representing the inclusive tax amount in the [smallest currency unit](https://docs.stripe.com/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `total` Total amount for this line item, including discounts and tax. - `amount` A formatted string representing the total amount, including currency symbols. - `minorUnitsAmount` An integer representing the total amount in the [smallest currency unit](https://docs.stripe.com/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `unitAmount` The amount representing the cost of a single unit of the item. - `amount` A formatted string representing the unit amount, including currency symbols. - `minorUnitsAmount` An integer representing the unit amount in the [smallest currency unit](https://docs.stripe.com/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `description` An arbitrary string attached to the object. Often useful for displaying to users. - `name` The item's name, meant to be displayable to users. - `images` An array of image URLs for the line item. Specify [images](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-line_items-price_data-product_data-images) on the Product when creating the Checkout Session. - `quantity` The quantity of products being purchased. - `discountAmounts` The amount of discount calculated per discount for this line item. - `amount` A formatted string representing the discount amount, including currency symbols. - `minorUnitsAmount` An integer representing the discount amount in the [smallest currency unit](https://docs.stripe.com/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `displayName` A user-facing description of the discount. - `promotionCode` The customer-facing promotion code that was used to apply this discount, if any. - `recurring` Details of how the discount applies to recurring payments. - `type` One of `forever` or `repeating`. * `forever`: Applies to all charges from a subscription with this coupon applied. * `repeating`: Applies to charges in the first `durationInMonths` months from a subscription with this coupon applied. - `durationInMonths` If `duration` is `repeating`, the number of months the coupon applies. Null otherwise. - `percentOff` An integer representing the discount amount as a percentage. - `taxAmounts` The amount of tax calculated per tax rate for this line item. - `amount` A formatted string representing the tax amount, including currency symbols. - `minorUnitsAmount` An integer representing the tax amount in the [smallest currency unit](https://docs.stripe.com/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `inclusive` Whether this tax amount is [inclusive or exclusive](https://docs.stripe.com/tax/faq.md#what-is-the-difference-between-inclusive-and-exclusive-tax). - `displayName` A user-facing description of the tax. - `recurring` The recurring components of a price such as `interval` and `intervalCount`. - `interval` Specifies billing frequency. Either `day`, `week`, `month`, or `year`. - `intervalCount` The number of intervals between subscription billings. For example, `interval=month` and `intervalCount=3` bills every 3 months. - `usageType` One of `licensed` or `metered`. `licensed` automatically bills the quantity set when adding it to a subscription. `metered` aggregates the total usage based on usage records. - `isProrated` When true, the amount to be collected today is a prorated amount for a partial billing period, such as when using [billing_cycle_anchor](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-subscription_data-billing_cycle_anchor). - `adjustableQuantity` Configuration for this item's quantity to be adjusted by the customer during checkout. - `maximum` The maximum quantity the customer can purchase for the Checkout Session. - `minimum` The minimum quantity the customer can purchase for the Checkout Session. - `livemode` Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. - `minorUnitsAmountDivisor` The factor used to convert between minor and major currency units. This value represents the number of minor currency units per one major unit. For example, in USD, where cents are the minor unit, the divisor is 100. In JPY, which has no minor units, the divisor is 1. - `phoneNumber` The Customer's phone number. - `recurring` Details about recurring payments set up by the Checkout Session. - `interval` Specifies billing frequency. Either `day`, `week`, `month`, or `year`. - `intervalCount` The number of intervals between subscription billings. For example, `interval=month` and `intervalCount=3` bills every 3 months. - `dueNext` Details about the next scheduled recurring payment. - `subtotal` Total before any discounts or exclusive taxes are applied. - `amount` A formatted string representing the subtotal amount, including currency symbols. - `minorUnitsAmount` An integer representing the subtotal amount in the [smallest currency unit](https://docs.stripe.com/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `discount` Total discount amount. A positive number reduces the amount to be paid. - `amount` A formatted string representing the discount amount, including currency symbols. - `minorUnitsAmount` An integer representing the discount amount in the [smallest currency unit](https://docs.stripe.com/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `taxExclusive` Total amount of exclusive tax (tax that is collected in addition to the subtotal). - `amount` A formatted string representing the exclusive tax amount, including currency symbols. - `minorUnitsAmount` An integer representing the exclusive tax amount in the [smallest currency unit](https://docs.stripe.com/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `taxInclusive` Total amount of inclusive tax (tax that is already included in the subtotal). - `amount` A formatted string representing the inclusive tax amount, including currency symbols. - `minorUnitsAmount` An integer representing the inclusive tax amount in the [smallest currency unit](https://docs.stripe.com/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `total` Total computed amount, including discounts and tax. - `amount` A formatted string representing the total amount, including currency symbols. - `minorUnitsAmount` An integer representing the total amount in the [smallest currency unit](https://docs.stripe.com/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `billingCycleAnchor` A future Unix timestamp to anchor the subscription's billing cycle. The anchor is the reference point that aligns future billing cycle dates. If not present, the subscription starts immediately. - `trial` Details about a free trial, if there is one. - `trialEnd` Unix timestamp representing the end of the trial period the customer will get before being charged for the first time. - `trialPeriodDays` Integer representing the number of trial period days before the customer is charged for the first time. - `savedPaymentMethods` An array of payment methods attached to the Customer. - `id` ID of the PaymentMethod object - `type` The [type](https://docs.stripe.com/api/payment_methods/object.md#payment_method_object-type) of the PaymentMethod - `billingDetails` Billing information associated with the PaymentMethod that may be used or required by particular types of payment methods. - `email` Email address. - `phone` Billing phone number (including extension). - `name` Full name. - `address` Address. - `country` Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). - `line1` Address line 1 (e.g., street, PO Box, or company name). - `line2` Address line 2 (e.g., apartment, suite, unit, or building). - `city` City, district, suburb, town, or village. - `postal_code` ZIP or postal code. - `state` State, county, province, or region. - `card` If this is a `card` PaymentMethod, this hash contains the user's card details. - `brand` The brand to use when displaying the card, this accounts for customer's brand choice on dual-branded cards. Can be american_express, cartes_bancaires, diners_club, discover, eftpos_australia, interac, jcb, mastercard, union_pay, visa, or other and may contain more values in the future. - `expMonth` Two-digit number representing the card's expiration month. - `expYear` Four-digit number representing the card's expiration year. - `last4` The last four digits of the card. - `shipping` The selected shipping option, if any. - `shippingOption` Details of the selected shipping option. - `id` Unique identifier for the object. - `amount` A formatted string representing the shipping amount, including currency symbols. - `minorUnitsAmount` An integer representing the shipping amount in the [smallest currency unit](https://docs.stripe.com/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. - `displayName` A user-facing description of the shipping option. - `deliveryEstimate` The estimated range for how long shipping will take. - `maximum` The upper bound of the estimated range. If empty, represents no upper bound i.e., infinite. - `unit` A unit of time. Either `business_day`, `day`, `hour`, `week`, or `month`. - `value` Must be greater than 0. - `minimum` The lower bound of the estimated range. If empty, represents no lower bound. - `unit` A unit of time. Either `business_day`, `day`, `hour`, `week`, or `month`. - `value` Must be greater than 0. - `taxAmounts` The amount of tax calculated per tax rate for shipping costs. - `amount` A formatted string representing the tax amount, including currency symbols. - `minorUnitsAmount` An integer representing the tax amount in the [smallest currency unit](https://docs.stripe.com/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `inclusive` Whether this tax amount is [inclusive or exclusive](https://docs.stripe.com/tax/faq.md#what-is-the-difference-between-inclusive-and-exclusive-tax). - `displayName` A user-facing description of the tax. - `shippingAddress` Shipping address of the Customer. - `name` Full name. - `address` Address. - `country` Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). - `line1` Address line 1 (e.g., street, PO Box, or company name). - `line2` Address line 2 (e.g., apartment, suite, unit, or building). - `city` City, district, suburb, town, or village. - `postal_code` ZIP or postal code. - `state` State, county, province, or region. - `shippingOptions` The list of shipping options that can be selected. - `id` Unique identifier for the object. - `amount` A formatted string representing the shipping amount, including currency symbols. - `minorUnitsAmount` An integer representing the shipping amount in the [smallest currency unit](https://docs.stripe.com/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `currency` Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. - `displayName` A user-facing description of the shipping option. - `deliveryEstimate` The estimated range for how long shipping will take. - `maximum` The upper bound of the estimated range. If empty, represents no upper bound i.e., infinite. - `unit` A unit of time. Either `business_day`, `day`, `hour`, `week`, or `month`. - `value` Must be greater than 0. - `minimum` The lower bound of the estimated range. If empty, represents no lower bound. - `unit` A unit of time. Either `business_day`, `day`, `hour`, `week`, or `month`. - `value` Must be greater than 0. - `status` Status of the Checkout Session. - `type` One of `open`, `expired`, or `complete`. * `open`: The Checkout Session is still in progress. * `expired`: The Checkout Session has expired. No further processing will occur. * `complete`: The Checkout Session is complete. Payment processing may still be in progress. - `paymentStatus` One of `paid`, `unpaid`, or `no_payment_required`. Only present when `type=complete`. * `paid`: The payment funds are available in your account. * `unpaid`: The payment funds are not yet available in your account. * `no_payment_required`: The payment is delayed to a future date, or the Checkout Session is in setup mode and doesn't require a payment at this time. - `tax` Details about the tax computation status. - `status` One of `ready`, `requires_shipping_address`, or `requires_billing_address`. * `ready`: The final tax amount is computed, and the session is ready for confirmation. * `requires_shipping_address`: A shipping address must be provided to calculate tax. * `requires_billing_address`: A billing address must be provided to calculate tax. - `taxAmounts` The aggregate amounts calculated per tax rate for all line items. This value is `null` if tax has not yet been computed, i.e. the Customer's address has not been collected yet. - `amount` A formatted string representing the tax amount, including currency symbols. - `minorUnitsAmount` An integer representing the tax amount in the [smallest currency unit](https://docs.stripe.com/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `inclusive` Whether this tax amount is [inclusive or exclusive](https://docs.stripe.com/tax/faq.md#what-is-the-difference-between-inclusive-and-exclusive-tax). - `displayName` A user-facing description of the tax. - `total` Tax and discount details for the computed total amount. Use this field to render an amount breakdown to your customer, such as in an order summary. - `subtotal` The total amount of line items, excluding tax, discounts, and shipping. - `amount` A formatted string representing the subtotal amount, including currency symbols. - `minorUnitsAmount` An integer representing the subtotal amount in the [smallest currency unit](https://docs.stripe.com/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `taxExclusive` The sum of all [exclusive](https://docs.stripe.com/tax/faq.md#what-is-the-difference-between-inclusive-and-exclusive-tax) tax amounts - `amount` A formatted string representing the exclusive tax amount, including currency symbols. - `minorUnitsAmount` An integer representing the exclusive tax amount in the [smallest currency unit](https://docs.stripe.com/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `taxInclusive` The sum of all [inclusive](https://docs.stripe.com/tax/faq.md#what-is-the-difference-between-inclusive-and-exclusive-tax) tax amounts - `amount` A formatted string representing the inclusive tax amount, including currency symbols. - `minorUnitsAmount` An integer representing the inclusive tax amount in the [smallest currency unit](https://docs.stripe.com/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `shippingRate` The sum of all shipping amounts. - `amount` A formatted string representing the total shipping amount, including currency symbols. - `minorUnitsAmount` An integer representing the total shipping amount in the [smallest currency unit](https://docs.stripe.com/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `discount` The sum of all the discounts. A positive number reduces the amount to be paid. - `amount` A formatted string representing the discount amount, including currency symbols. - `minorUnitsAmount` An integer representing the discount amount in the [smallest currency unit](https://docs.stripe.com/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `total` Total computed amount, including discounts and tax. - `amount` A formatted string representing the total amount, including currency symbols. - `minorUnitsAmount` An integer representing the total amount in the [smallest currency unit](https://docs.stripe.com/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `appliedBalance` Total amount of [customer credit balance](https://docs.stripe.com/billing/customer/balance.md) to be applied to the payment. A positive number increases the amount to be paid, and a negative number decreases the amount to be paid. - `amount` A formatted string representing the applied customer balance amount, including currency symbols. - `minorUnitsAmount` An integer representing the applied customer balance amount in the [smallest currency unit](https://docs.stripe.com/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `balanceAppliedToNextInvoice` When true, no payment will be collected immediately. Instead, the amount due will be added to the Customer's next invoice. This can happen when the amount due today is less than the [minimum chargeable amount](https://docs.stripe.com/currencies.md#minimum-and-maximum-charge-amounts). ## Checkout events Listen to Checkout events to respond to changes caused by customer actions on your checkout page. ## Change event `checkout.on(event: 'change', handler: function)` The change event is triggered when [Checkout Session](https://docs.stripe.com/js/custom_checkout/session_object.md) data changes, such as when the customer changes their shipping address. The event payload is always a [Checkout Session](https://docs.stripe.com/js/custom_checkout/session_object.md) object. - `event` The name of the event. In this case, `change`. - `handler` `handler(session) => void` is a **callback function** that you provide that will be called when the event is fired. When called it will be passed a [Checkout Session](https://docs.stripe.com/js/custom_checkout/session_object.md) object. ### Example ```title Listen to change events ``` ## Use Elements with the Checkout Sessions API [Stripe Elements](https://docs.stripe.com/payments/elements.md) are customizable UI components you can use to build your checkout page. Use the [Checkout Elements SDK](https://docs.stripe.com/js/custom_checkout/init.md) instance to create and manage Elements. ## Create a Payment Element `checkout.createPaymentElement(options?: object)` This method creates an instance of a Payment Element. - `options` Payment Element initialization options. - `fields` By default, the Payment Element will collect only the necessary billing details to complete a payment. If you intend to collect billing details fields outside of the Payment Element, you can disable Payment Element collection of certain fields with the `fields` option. - `billingDetails` Specify `never` to avoid collecting all [billing details](https://docs.stripe.com/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` - `email` - `phone` - `address` 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` - `line2` - `city` The name of a city, town, village, etc. - `state` 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` Two-letter country code, capitalized. Valid two-letter country codes are specified by ISO3166 alpha-2. - `postalCode` The postal code or ZIP code, also known as PIN code in India. - `layout` 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` Defines the layout to render the Payment Element. - `defaultCollapsed` 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` 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` When `true`, the Payment Methods render as standalone buttons with space in between them. _This property is only applicable to the `accordion` layout._ - `visibleAccordionItemsCount` 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` Sets the position of the payment method logo in each accordion item. Default is `start`. _This property is only applicable to the `accordion` layout._ - `paymentMethodOrder` 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 Checkout Session 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. - `readOnly` 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](https://docs.stripe.com/elements/appearance-api.md). - `terms` 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` - `auBecsDebit` - `bancontact` - `card` - `cashapp` - `googlePay` - `ideal` - `paypal` - `sepaDebit` - `sofort` - `usBankAccount` - `wallets` By default, the Payment Element will display all the payment methods that the underlying Checkout Session was created with. However, wallets like Apple Pay and Google Pay are not payment methods per the Checkout Session API. They will show when the Checkout Session 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` - `googlePay` - `link` ### Example ```title Create a Payment Element ``` ## Create a Billing Address Element `checkout.createBillingAddressElement(options?: object)` This method creates an instance of a Billing Address Element. - `options` Billing Address Element initialization options. - `contacts` An array of objects that can be displayed as saved addresses in the Billing Address Element. The first contact is automatically selected. - `name` The name of the contact. This might be a person, or a business name. - `address` The address of the contact. - `line1` - `line2` - `city` The name of a city, town, village, etc. - `state` 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. - `postal_code` The postal code or ZIP code, also known as PIN code in India. - `country` Two-letter country code, capitalized. Valid two-letter country codes are specified by ISO3166 alpha-2. - `phone` The phone number of the contact. - `display` You can customize how certain fields are displayed. - `name` By default, the Billing Address Element displays a full name field. Specify 'split' to display a first name field and a last name field. Specify 'organization' to display an organization field. ### Example ```title Create a Billing Address Element ``` ## Create a Shipping Address Element `checkout.createShippingAddressElement(options?: object)` This method creates an instance of a Shipping Address Element. - `options` Shipping Address Element initialization options. - `contacts` An array of objects that can be displayed as saved addresses in the Shipping Address Element. The first contact is automatically selected. - `name` The name of the contact. This might be a person, or a business name. - `address` The address of the contact. - `line1` - `line2` - `city` The name of a city, town, village, etc. - `state` 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. - `postal_code` The postal code or ZIP code, also known as PIN code in India. - `country` Two-letter country code, capitalized. Valid two-letter country codes are specified by ISO3166 alpha-2. - `phone` The phone number of the contact. - `display` You can customize how certain fields are displayed. - `name` By default, the Shipping Address Element displays a full name field. Specify 'split' to display a first name field and a last name field. Specify 'organization' to display an organization field. ### Example ```title Create a Shipping Address Element ``` ## Create an Express Checkout Element `checkout.createExpressCheckoutElement(options?: object)` This method creates an instance of an Express Checkout Element. - `options` Express Checkout Element initialization options. - `buttonHeight` 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` Specify the preferred button theme to use. By default, Elements determines the themes based on the specified [appearance option](https://docs.stripe.com/js/elements_object/create.md#stripe_elements-options-appearance). - `applePay` - `googlePay` - `paypal` - `klarna` - `buttonType` Specify the preferred button type to display. - `applePay` Default is `plain`. - `googlePay` Default is `buy`. - `paypal` Default is `paypal`. - `klarna` Default is `pay`. - `layout` 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` Defines the maximum number of columns the Express Checkout Element can use to render. Default is `0`, meaning unlimited. - `maxRows` Defines the maximum number of rows the Express Checkout Element can use to render. Default is `0`, meaning unlimited. - `overflow` 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` 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. - `paymentMethods` Besides your Dashboard configuration, the availability of payment methods in the Express Checkout Element is influenced by the CheckoutSession configuration. By default, it displays all available payment methods based on both configurations. When setting the paymentMethods option, the Express Checkout Element merges your specified options with the default logic to determine the final set of payment methods displayed. - `amazonPay` - `applePay` 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`. - `googlePay` 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`. - `link` - `paypal` ### Example ```title Create an Express Checkout Element ``` ## Create a Currency Selector Element `checkout.createCurrencySelectorElement()` This method creates an instance of a Currency Selector Element. ### Example ```title Create a Currency Selector Element ``` ## Create a Tax ID Element `checkout.createTaxIdElement(options?: object)` This method creates an instance of a Tax ID Element. > This feature requires the `custom_checkout_tax_id_1` beta. To use it, pass `betas: ['custom_checkout_tax_id_1']` when initializing Stripe.js. - `options` Tax ID Element initialization options. - `visibility` 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` 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` Specify `always` to collect the business name. Specify `never` to not collect the business name. Default is `auto`. - `validation` By default, the Tax ID Element will enforce preset validation for each field. You can customize the settings by using this option. - `businessName` - `required` Specify `always` to make business name a required field. Specify `never` to make business name an optional field. Default is `auto`. - `taxId` - `required` Specify `always` to make tax ID a required field. Specify `never` to make tax ID an optional field. Default is `auto`. - `verification` Configure real-time tax ID verification. Requires the `custom_checkout_tax_id_verification_1` beta. To use it, pass `betas: ['custom_checkout_tax_id_1', 'custom_checkout_tax_id_verification_1']` when initializing Stripe.js - `taxId` - `mode` Specify `if_supported` to enable real-time tax ID verification for supported tax ID types. Specify `never` to disable verification. Default is `never`. ### Example ```title Create a Tax ID Element ``` ## Get the Payment Element `checkout.getPaymentElement()` This method gets the previously created Payment Element instance, if it exists. ### Example ```title Get the Payment Element ``` ## Get the Billing Address Element `checkout.getBillingAddressElement()` This method gets the previously created Billing Address Element instance, if it exists. ### Example ```title Get the Billing Address Element ``` ## Get the Shipping Address Element `checkout.getShippingAddressElement()` This method gets the previously created Shipping Address Element instance, if it exists. ### Example ```title Get the Shipping Address Element ``` ## Get the Express Checkout Element `checkout.getExpressCheckoutElement()` This method gets the previously created Express Checkout Element instance, if it exists. ### Example ```title Get the Express Checkout Address Element ``` ## Get the Currency Selector Element `checkout.getCurrencySelectorElement()` This method gets the previously created Currency Selector Element instance, if it exists. ### Example ```title Get the Currency Selector Address Element ``` ## Change the visual customization of Elements using the Appearance API `checkout.changeAppearance(appearance: object)` Change the visual customization of Elements created with Custom Checkout using the [Appearance API](https://docs.stripe.com/elements/appearance-api.md) - `appearance` Match the design of your site with the [appearance option](https://docs.stripe.com/elements/appearance-api.md). The layout of each Element stays consistent, but you can modify colors, fonts, borders, padding, and more. ### Example ```title Change the visual customization of Elements ``` ## Load additional custom fonts into Elements `checkout.loadFonts(fonts: array)` Load an additional array of custom fonts into Elements after it loads. - `fonts` An array of custom fonts. Specify fonts as [CssFontSource](#css_font_source_object) or [CustomFontSource](#custom_font_source_object) objects. ### Example ```title Load additional custom fonts ``` ## Listen to Elements events Communicate with your [Element](https://docs.stripe.com/js/custom_checkout/custom_checkout_elements.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. Use the `.on` method on the Element instance to listen to events. See also: [Elements methods](https://docs.stripe.com/js/custom_checkout/custom_checkout_elements.md) | [Listen to Checkout events](https://docs.stripe.com/js/custom_checkout/events.md) ## Change event `element.on(event: 'change', handler: function)` 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. The following Checkout Elements support the `change` event: `paymentElement`, `billingAddressElement`, `shippingAddressElement`, and `taxIdElement`. > Consult with your legal counsel regarding your requirements and obligations about how you collect, use, and store customers' personal data ## Ready event `element.on(event: 'ready', handler: function)` Triggered when the `Element` is fully rendered and methods on the instance, like `element.focus()` and `element.update()`, can be called. - `event` The name of the event. In this case, `ready`. - `handler` `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` The type of element the event is fired from. ### Example ```title Handle an Element ready event ``` ## Focus event `element.on(event: 'focus', handler: function)` Triggered when the `Element` gains focus. - `event` The name of the event. In this case, `focus`. - `handler` `handler(event) => void` is a **callback function** that you provide that will be called when the event is fired. ### Example ```title Handle an Element focus event ``` ## Blur event `element.on(event: 'blur', handler: function)` Triggered when the `Element` loses focus. - `event` The name of the event. In this case, `blur`. - `handler` `handler(event) => void` is a **callback function** that you provide that will be called when the event is fired. ### Example ```title Handle an Element blur event ``` ## Escape event `element.on(event: 'escape', handler: function)` Triggered when the escape key is pressed within an `Element`. - `event` The name of the event. In this case, `escape`. - `handler` `handler(event) => void` is a **callback function** that you provide that will be called when the event is fired. ### Example ```title Handle an Element escape event ``` ## LoadError event `element.on(event: 'loaderror', handler: function)` Triggered when the `Element` fails to load. - `event` The name of the event. In this case, `loaderror`. - `handler` `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` The type of element that emitted this event. - `error` An `error` object that describes the failure. ### Example ```title Handle an Element loaderror event ``` ## LoaderStart event `element.on(event: 'loaderstart', handler: function)` Triggered when the loader UI is mounted to the DOM and ready to be displayed. See also: [Elements methods](https://docs.stripe.com/js/custom_checkout/custom_checkout_elements.md) | [Listen to Elements events](https://docs.stripe.com/js/custom_checkout/element_events.md) - `event` The name of the event. In this case, `loaderstart`. - `handler` `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` The type of element that emitted this event. ### Example ```title Handle a Checkout Element loaderstart event ``` ## Confirm event `expressCheckoutElement.on(event: string, handler: function)` The `confirm` event is triggered from the Express Checkout Element when the customer finalizes their payment. Use this event to trigger payment confirmation. This event is only available on the Express Checkout Element. - `event` The name of the event. In this case, `confirm`. - `handler` 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` The type of element the event fires from, which is `expressCheckout` in this case. - `expressPaymentType` The payment method the customer checks out with. - `paymentFailed` A function `paymentFailed(payload) => void` that's called if you're unable to process the customer's payment. - `reason` Default is `'fail'`. The payment interface might surface the reason to provide a hint to the customer on why their payment failed. - `message` 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. - `billingDetails` Object containing information about the customer's billing details. - `name` The name of the customer. - `email` The email address of the customer. - `phone` The phone number of the customer. - `address` The billing address of the customer. - `shippingAddress` Object containing information about the customer's shipping address. - `name` The name of the recipient. - `address` The shipping address of the customer. - `shippingRate` Object containing information about the selected shipping rate. ### Example ```title Handle 'confirm' event ``` ## Cancel event `expressCheckoutElement.on(event: string, handler: function)` The `cancel` event is triggered from the 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. This event is only available on the Express Checkout Element. - `event` The name of the event. In this case, `cancel`. - `handler` A callback function that you provide that's called after the event is fired. ### Example ```title Handle 'cancel' event ```