## Using the Checkout provider Build your Stripe integration using React, Stripe Elements, and the [Checkout Sessions API](/api/checkout/sessions.md). See [build a checkout page](/docs/payments/quickstart-checkout-sessions.md) for steps on using Elements with the Checkout Sessions API. The following React components and hooks are available to use as part of your integration. ## CheckoutProvider The `CheckoutProvider` component allows you to use Element components and access data from your [Checkout Session](/api/checkout/sessions/object.md) in any nested component. Wrap the portion of your React tree that renders individual Element components to make the Checkout instance available via React context. To use `CheckoutProvider`, call `loadStripe` from `@stripe/stripe-js` with your publishable key. The `loadStripe` function asynchronously loads the Stripe.js script and initializes a Stripe object. Pass the returned `Promise` to `CheckoutProvider` along with the [client secret](/api/checkout/sessions/object.md#checkout_session_object-client_secret) of your Checkout Session. ### Props - `stripe` (`Stripe` or `Promise`) **required** A [Stripe object](/js/initializing.md) or a `Promise` resolving to a Stripe object. The easiest way to initialize a Stripe object is with the [Stripe.js wrapper module](https://github.com/stripe/stripe-js/blob/master/README.md#readme). After this prop has been set, it can not be changed. - `options` (object) **required** Options for `CheckoutProvider`. - `clientSecret` (Promise | string) **required** The Checkout Session [client secret](/api/checkout/sessions/object.md#checkout_session_object-client_secret) or a promise that resolves to the client secret. - `elementsOptions` (object) A set of options to configure Elements created with [Checkout Sessions](/api/checkout/sessions.md). - `appearance` (object) Match the design of your site with the [appearance option](/elements/appearance-api.md). The layout of each Element stays consistent, but you can modify colors, fonts, borders, padding, and more. - `loader` ('auto' | 'always' | 'never') 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` (array) 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` (object) Options to configure what Elements displays when used to [Save payment details during payment](/payments/checkout/save-during-payment.md). - `enableRedisplay` ('auto' | 'never') Toggle if Elements redisplays Customer saved Payment Methods. Default is `'auto'`. Prior to Clover, this defaulted to `'never'`. - `enableSave` ('auto' | 'never') 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` ('billing' | 'shipping' | 'none') Used with the [Address Element](/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. - `adaptivePricing` (object) Options for [Adaptive Pricing](/payments/currencies/localize-prices/adaptive-pricing.md?payment-ui=embedded-components). - `allowed` (boolean) Whether Adaptive Pricing can be used with this integration. Default is `false`. [Additional setup](/payments/currencies/localize-prices/adaptive-pricing.md?payment-ui=embedded-components) is required before you can use Adaptive Pricing with embedded components. ### Mount CheckoutProvider ```jsx import React from 'react'; import {CheckoutProvider} from '@stripe/react-stripe-js/checkout'; import {loadStripe} from '@stripe/stripe-js'; import {useMemo} from 'react'; // Make sure to call `loadStripe` outside of a component's render to avoid // recreating the `Stripe` object on every render. const stripePromise = loadStripe('{TEST_PUBLISHABLE_KEY}'); const App = () => { const promise = useMemo(() => { return fetch('/create-checkout-session', { method: 'POST', }) .then((res) => res.json()) .then((data) => data.clientSecret); }, []); return ( ); } export default App; ``` ## useCheckout The `useCheckout` hook returns a disjoint union describing the loading state: * `{type: "loading"}` * `{type: "error", error: { message: string }}` * `{type: "success", checkout: object }`. Upon success, it returns a [Session object](/js/custom_checkout/session_object.md) as well as actions to update the Checkout Session. ### Object properties - `id` (string) The ID of the Checkout Session. - `billingAddress` (nullable object) Billing details of the Customer. - `name` (nullable string) Full name. - `address` (nullable object) Address. - `country` (string) Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). - `line1` (nullable string) Address line 1 (e.g., street, PO Box, or company name). - `line2` (nullable string) Address line 2 (e.g., apartment, suite, unit, or building). - `city` (nullable string) City, district, suburb, town, or village. - `postal_code` (nullable string) ZIP or postal code. - `state` (nullable string) State, county, province, or region. - `businessName` (nullable string) The business name as configured in the Business Public Details settings of your Stripe account. - `canConfirm` (boolean) 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` (enum) Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](/currencies.md). - `currencyOptions` (nullable array of objects) The currency options available on the Checkout Session when using [Adaptive Pricing](/checkout/custom-checkout/adaptive-pricing.md). - `amount` (string) A formatted string representing the total amount in the source currency, including currency symbols. - `minorUnitsAmount` (integer) An integer representing the total amount in the source currency in the [smallest currency unit](/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `currency` (enum) Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. - `currencyConversion` (optional object) Currency conversion details. This is only present for the customer currency. - `fxRate` (decimal string) The exchange rate used to convert source currency amounts to customer currency amounts. - `sourceCurrency` (enum) The creation currency of the Checkout Session before localization. - `discountAmounts` (array of objects) The aggregate amounts calculated per discount for all line items. - `amount` (string) A formatted string representing the discount amount, including currency symbols. - `minorUnitsAmount` (integer) An integer representing the discount amount in the [smallest currency unit](/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `displayName` (string) A user-facing description of the discount. - `promotionCode` (nullable string) The customer-facing promotion code that was used to apply this discount, if any. - `recurring` (nullable object) Details of how the discount applies to recurring payments. - `type` (enum) 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` (nullable integer) If `duration` is `repeating`, the number of months the coupon applies. Null otherwise. - `percentOff` (nullable integer) An integer representing the discount amount as a percentage. - `email` (nullable string) The Customer's email address. - `lastPaymentError` (nullable object) The error encountered the last time the Checkout Session was confirmed. - `message` (string) An error message to be displayed to the customer. - `lineItems` (array of objects) A list of items the customer is purchasing. - `id` (string) Unique identifier for the object. - `subtotal` (nullable object) Total before any discounts or exclusive taxes are applied. - `amount` (string) A formatted string representing the subtotal amount, including currency symbols. - `minorUnitsAmount` (integer) An integer representing the subtotal amount in the [smallest currency unit](/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `discount` (nullable object) Total discount amount. A positive number reduces the amount to be paid. - `amount` (string) A formatted string representing the discount amount, including currency symbols. - `minorUnitsAmount` (integer) An integer representing the discount amount in the [smallest currency unit](/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `taxExclusive` (nullable object) Total amount of exclusive tax (tax that is collected in addition to the subtotal). - `amount` (string) A formatted string representing the exclusive tax amount, including currency symbols. - `minorUnitsAmount` (integer) An integer representing the exclusive tax amount in the [smallest currency unit](/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `taxInclusive` (nullable object) Total amount of inclusive tax (tax that is already included in the subtotal). - `amount` (string) A formatted string representing the inclusive tax amount, including currency symbols. - `minorUnitsAmount` (integer) An integer representing the inclusive tax amount in the [smallest currency unit](/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `total` (nullable object) Total amount for this line item, including discounts and tax. - `amount` (string) A formatted string representing the total amount, including currency symbols. - `minorUnitsAmount` (integer) An integer representing the total amount in the [smallest currency unit](/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `unitAmount` (nullable object) The amount representing the cost of a single unit of the item. - `amount` (string) A formatted string representing the unit amount, including currency symbols. - `minorUnitsAmount` (integer) An integer representing the unit amount in the [smallest currency unit](/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `description` (optional string) An arbitrary string attached to the object. Often useful for displaying to users. - `name` (string) The item's name, meant to be displayable to users. - `images` (array of strings) An array of image URLs for the line item. Specify [images](/api/checkout/sessions/create.md#create_checkout_session-line_items-price_data-product_data-images) on the Product when creating the Checkout Session. - `quantity` (integer) The quantity of products being purchased. - `discountAmounts` (array of objects) The amount of discount calculated per discount for this line item. - `amount` (string) A formatted string representing the discount amount, including currency symbols. - `minorUnitsAmount` (integer) An integer representing the discount amount in the [smallest currency unit](/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `displayName` (string) A user-facing description of the discount. - `promotionCode` (nullable string) The customer-facing promotion code that was used to apply this discount, if any. - `recurring` (nullable object) Details of how the discount applies to recurring payments. - `type` (enum) 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` (nullable integer) If `duration` is `repeating`, the number of months the coupon applies. Null otherwise. - `percentOff` (nullable integer) An integer representing the discount amount as a percentage. - `taxAmounts` (nullable array of objects) The amount of tax calculated per tax rate for this line item. - `amount` (string) A formatted string representing the tax amount, including currency symbols. - `minorUnitsAmount` (integer) An integer representing the tax amount in the [smallest currency unit](/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `inclusive` (boolean) Whether this tax amount is [inclusive or exclusive](/tax/faq.md#what-is-the-difference-between-inclusive-and-exclusive-tax). - `displayName` (string) A user-facing description of the tax. - `recurring` (nullable object) The recurring components of a price such as `interval` and `intervalCount`. - `interval` (enum) Specifies billing frequency. Either `day`, `week`, `month`, or `year`. - `intervalCount` (integer) The number of intervals between subscription billings. For example, `interval=month` and `intervalCount=3` bills every 3 months. - `usageType` (enum) 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` (boolean) When true, the amount to be collected today is a prorated amount for a partial billing period, such as when using [billing_cycle_anchor](/api/checkout/sessions/create.md#create_checkout_session-subscription_data-billing_cycle_anchor). - `adjustableQuantity` (nullable object) Configuration for this item's quantity to be adjusted by the customer during checkout. - `maximum` (integer) The maximum quantity the customer can purchase for the Checkout Session. - `minimum` (integer) The minimum quantity the customer can purchase for the Checkout Session. - `livemode` (boolean) Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. - `minorUnitsAmountDivisor` (integer) 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` (nullable string) The Customer's phone number. - `recurring` (object) Details about recurring payments set up by the Checkout Session. - `interval` (enum) Specifies billing frequency. Either `day`, `week`, `month`, or `year`. - `intervalCount` (integer) The number of intervals between subscription billings. For example, `interval=month` and `intervalCount=3` bills every 3 months. - `dueNext` (object) Details about the next scheduled recurring payment. - `subtotal` (nullable object) Total before any discounts or exclusive taxes are applied. - `amount` (string) A formatted string representing the subtotal amount, including currency symbols. - `minorUnitsAmount` (integer) An integer representing the subtotal amount in the [smallest currency unit](/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `discount` (nullable object) Total discount amount. A positive number reduces the amount to be paid. - `amount` (string) A formatted string representing the discount amount, including currency symbols. - `minorUnitsAmount` (integer) An integer representing the discount amount in the [smallest currency unit](/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `taxExclusive` (nullable object) Total amount of exclusive tax (tax that is collected in addition to the subtotal). - `amount` (string) A formatted string representing the exclusive tax amount, including currency symbols. - `minorUnitsAmount` (integer) An integer representing the exclusive tax amount in the [smallest currency unit](/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `taxInclusive` (nullable object) Total amount of inclusive tax (tax that is already included in the subtotal). - `amount` (string) A formatted string representing the inclusive tax amount, including currency symbols. - `minorUnitsAmount` (integer) An integer representing the inclusive tax amount in the [smallest currency unit](/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `billingCycleAnchor` (nullable integer) 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` (nullable object) Details about a free trial, if there is one. - `trialEnd` (integer) Unix timestamp representing the end of the trial period the customer will get before being charged for the first time. - `trialPeriodDays` (integer) Integer representing the number of trial period days before the customer is charged for the first time. - `savedPaymentMethods` (array of objects) An array of payment methods attached to the Customer. - `id` (string) ID of the PaymentMethod object - `type` (enum) The [type](/api/payment_methods/object.md#payment_method_object-type) of the PaymentMethod - `billingDetails` (object) Billing information associated with the PaymentMethod that may be used or required by particular types of payment methods. - `email` (nullable string) Email address. - `phone` (nullable string) Billing phone number (including extension). - `name` (nullable string) Full name. - `address` (nullable object) Address. - `country` (string) Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). - `line1` (nullable string) Address line 1 (e.g., street, PO Box, or company name). - `line2` (nullable string) Address line 2 (e.g., apartment, suite, unit, or building). - `city` (nullable string) City, district, suburb, town, or village. - `postal_code` (nullable string) ZIP or postal code. - `state` (nullable string) State, county, province, or region. - `card` (object) If this is a `card` PaymentMethod, this hash contains the user's card details. - `brand` (string) 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` (integer) Two-digit number representing the card's expiration month. - `expYear` (integer) Four-digit number representing the card's expiration year. - `last4` (string) The last four digits of the card. - `shipping` (nullable object) The selected shipping option, if any. - `shippingOption` (object) Details of the selected shipping option. - `id` (string) Unique identifier for the object. - `amount` (string) A formatted string representing the shipping amount, including currency symbols. - `minorUnitsAmount` (integer) An integer representing the shipping amount in the [smallest currency unit](/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `currency` (string) Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. - `displayName` (nullable string) A user-facing description of the shipping option. - `deliveryEstimate` (nullable object) The estimated range for how long shipping will take. - `maximum` (nullable object) The upper bound of the estimated range. If empty, represents no upper bound i.e., infinite. - `unit` (string) A unit of time. Either `business_day`, `day`, `hour`, `week`, or `month`. - `value` (integer) Must be greater than 0. - `minimum` (nullable object) The lower bound of the estimated range. If empty, represents no lower bound. - `unit` (string) A unit of time. Either `business_day`, `day`, `hour`, `week`, or `month`. - `value` (integer) Must be greater than 0. - `taxAmounts` (array of objects) The amount of tax calculated per tax rate for shipping costs. - `amount` (string) A formatted string representing the tax amount, including currency symbols. - `minorUnitsAmount` (integer) An integer representing the tax amount in the [smallest currency unit](/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `inclusive` (boolean) Whether this tax amount is [inclusive or exclusive](/tax/faq.md#what-is-the-difference-between-inclusive-and-exclusive-tax). - `displayName` (string) A user-facing description of the tax. - `shippingAddress` (nullable object) Shipping address of the Customer. - `name` (nullable string) Full name. - `address` (nullable object) Address. - `country` (string) Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). - `line1` (string) Address line 1 (e.g., street, PO Box, or company name). - `line2` (nullable string) Address line 2 (e.g., apartment, suite, unit, or building). - `city` (nullable string) City, district, suburb, town, or village. - `postal_code` (nullable string) ZIP or postal code. - `state` (nullable string) State, county, province, or region. - `shippingOptions` (array of objects) The list of shipping options that can be selected. - `id` (string) Unique identifier for the object. - `amount` (string) A formatted string representing the shipping amount, including currency symbols. - `minorUnitsAmount` (integer) An integer representing the shipping amount in the [smallest currency unit](/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `currency` (string) Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. - `displayName` (nullable string) A user-facing description of the shipping option. - `deliveryEstimate` (nullable object) The estimated range for how long shipping will take. - `maximum` (nullable object) The upper bound of the estimated range. If empty, represents no upper bound i.e., infinite. - `unit` (string) A unit of time. Either `business_day`, `day`, `hour`, `week`, or `month`. - `value` (integer) Must be greater than 0. - `minimum` (nullable object) The lower bound of the estimated range. If empty, represents no lower bound. - `unit` (string) A unit of time. Either `business_day`, `day`, `hour`, `week`, or `month`. - `value` (integer) Must be greater than 0. - `status` (object) Status of the Checkout Session. - `type` (enum) 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` (nullable enum) 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` (object) Details about the tax computation status. - `status` (enum) 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` (nullable array of objects) 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` (string) A formatted string representing the tax amount, including currency symbols. - `minorUnitsAmount` (integer) An integer representing the tax amount in the [smallest currency unit](/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `inclusive` (boolean) Whether this tax amount is [inclusive or exclusive](/tax/faq.md#what-is-the-difference-between-inclusive-and-exclusive-tax). - `displayName` (string) A user-facing description of the tax. - `total` (object) 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` (object) The total amount of line items, excluding tax, discounts, and shipping. - `amount` (string) A formatted string representing the subtotal amount, including currency symbols. - `minorUnitsAmount` (integer) An integer representing the subtotal amount in the [smallest currency unit](/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `taxExclusive` (object) The sum of all [exclusive](/tax/faq.md#what-is-the-difference-between-inclusive-and-exclusive-tax) tax amounts - `amount` (string) A formatted string representing the exclusive tax amount, including currency symbols. - `minorUnitsAmount` (integer) An integer representing the exclusive tax amount in the [smallest currency unit](/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `taxInclusive` (object) The sum of all [inclusive](/tax/faq.md#what-is-the-difference-between-inclusive-and-exclusive-tax) tax amounts - `amount` (string) A formatted string representing the inclusive tax amount, including currency symbols. - `minorUnitsAmount` (integer) An integer representing the inclusive tax amount in the [smallest currency unit](/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `shippingRate` (object) The sum of all shipping amounts. - `amount` (string) A formatted string representing the total shipping amount, including currency symbols. - `minorUnitsAmount` (integer) An integer representing the total shipping amount in the [smallest currency unit](/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `discount` (object) The sum of all the discounts. A positive number reduces the amount to be paid. - `amount` (string) A formatted string representing the discount amount, including currency symbols. - `minorUnitsAmount` (integer) An integer representing the discount amount in the [smallest currency unit](/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `total` (object) Total computed amount, including discounts and tax. - `amount` (string) A formatted string representing the total amount, including currency symbols. - `minorUnitsAmount` (integer) An integer representing the total amount in the [smallest currency unit](/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `appliedBalance` (object) Total amount of [customer credit balance](/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` (string) A formatted string representing the applied customer balance amount, including currency symbols. - `minorUnitsAmount` (integer) An integer representing the applied customer balance amount in the [smallest currency unit](/currencies.md#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - `balanceAppliedToNextInvoice` (boolean) 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](/currencies.md#minimum-and-maximum-charge-amounts). ### Call useCheckout hook ```jsx import React from 'react'; import {useCheckout} from '@stripe/react-stripe-js/checkout'; const CheckoutPage = () => { const checkoutState = useCheckout(); if (checkoutState.type === "loading") { // ... your loading component here } if (checkoutState.type === "error") { // ... your error component here } const {currency, currencyOptions, lineItems, taxAmounts, total, recurring} = checkoutState.checkout; // ... your component here } export default CheckoutPage; ``` ## Apply a promotion code Use this method to apply a promotion code that your customer enters. This method returns a `Promise` that resolves with an object containing the following fields: * `type`: one of either `"success"` or `"error"` * `session`: only populated when `type` is `"success"`. Contains a [Session](/js/custom_checkout/session_object) instance representing the updated state. * `error`: only populated when `type` is `"error"`. Contains an object with a string `message` field which can be displayed to your customer. - `promotionCode` (string) **required** The promotion code to apply to the Checkout Session. ### Apply a promotion code ```jsx const checkoutState = useCheckout(); if (checkoutState.type === 'success') { const {applyPromotionCode} = checkoutState.checkout; applyPromotionCode('PROMOTION_CODE'); } ``` ## Remove a promotion code Use this method to remove the currently applied promotion code, if applicable. This method returns a `Promise` that resolves with an object containing the following fields: * `type`: one of either `"success"` or `"error"` * `session`: only populated when `type` is `"success"`. Contains a [Session](/js/custom_checkout/session_object) instance representing the updated state. * `error`: only populated when `type` is `"error"`. Contains an object with a string `message` field which can be displayed to your customer. ### Remove a promotion code ```jsx const checkoutState = useCheckout(); if (checkoutState.type === 'success') { const {removePromotionCode} = checkoutState.checkout; removePromotionCode(); } ``` ## Update the Customer's shipping address Use this method to update the Customer's shipping address. If your integration uses the [Express Checkout Element](/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. This method returns a `Promise` that resolves with an object containing the following fields: * `type`: one of either `"success"` or `"error"` * `session`: only populated when `type` is `"success"`. Contains a [Session](/js/custom_checkout/session_object) instance representing the updated state. * `error`: only populated when `type` is `"error"`. Contains an object with a string `message` field which can be displayed to your customer. - `shippingAddress` (nullable object) **required** New shipping address for the Customer. - `name` (optional string) Full name. - `address` (optional object) Address. - `country` (string) **required** Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). - `line1` (string) **required** Address line 1 (e.g., street, PO Box, or company name). - `line2` (optional string) Address line 2 (e.g., apartment, suite, unit, or building). - `city` (optional string) City, district, suburb, town, or village. - `postal_code` (optional string) ZIP or postal code. - `state` (optional string) State, county, province, or region. ### Update the Customer's shipping address ```jsx const checkoutState = useCheckout(); if (checkoutState.type === 'success') { const {updateShippingAddress} = checkoutState.checkout; updateShippingAddress({ address: { line1: '27 Fredrick Ave', city: 'Brothers', state: 'OR', postal_code: '97712', country: 'US', } }); } ``` ## Update the Customer's billing address Use this method to update the Customer's billing address. If your integration uses the [Express Checkout Element](/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. This method returns a `Promise` that resolves with an object containing the following fields: * `type`: one of either `"success"` or `"error"` * `session`: only populated when `type` is `"success"`. Contains a [Session](/js/custom_checkout/session_object) instance representing the updated state. * `error`: only populated when `type` is `"error"`. Contains an object with a string `message` field which can be displayed to your customer. - `billingAddress` (nullable object) **required** New billing information for the Customer. - `name` (optional string) Full name. - `address` (optional object) Address. - `country` (string) **required** Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). - `line1` (optional string) Address line 1 (e.g., street, PO Box, or company name). - `line2` (optional string) Address line 2 (e.g., apartment, suite, unit, or building). - `city` (optional string) City, district, suburb, town, or village. - `postal_code` (optional string) ZIP or postal code. - `state` (optional string) State, county, province, or region. ### Update the Customer's billing address ```jsx const checkoutState = useCheckout(); if (checkoutState.type === 'success') { const {updateBillingAddress} = checkoutState.checkout; updateBillingAddress({ address: { line1: '27 Fredrick Ave', city: 'Brothers', state: 'OR', postal_code: '97712', country: 'US', } }); } ``` ## Update the Customer's email address Use this method to update the Customer's email address. If your integration uses [Link](/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](/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. This method returns a `Promise` that resolves with an object containing the following fields: * `type`: one of either `"success"` or `"error"` * `session`: only populated when `type` is `"success"`. Contains a [Session](/js/custom_checkout/session_object) instance representing the updated state. * `error`: only populated when `type` is `"error"`. Contains an object with a string `message` field which can be displayed to your customer. - `email` (nullable string) **required** The Customer's email address. ### Update the Customer's email address ```jsx const checkoutState = useCheckout(); if (checkoutState.type === 'success') { const {updateEmail} = checkoutState.checkout; updateEmail('jenny.rosen@example.com'); } ``` ## Update the Customer's phone number Use this method to update the Customer's phone number. If your integration uses the [Express Checkout Element](/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. This method returns a `Promise` that resolves with an object containing the following fields: * `type`: one of either `"success"` or `"error"` * `session`: only populated when `type` is `"success"`. Contains a [Session](/js/custom_checkout/session_object) instance representing the updated state. * `error`: only populated when `type` is `"error"`. Contains an object with a string `message` field which can be displayed to your customer. - `phoneNumber` (nullable string) **required** The Customer's phone number. ### Update the Customer's phone number ```jsx const checkoutState = useCheckout(); if (checkoutState.type === 'success') { const {updatePhoneNumber} = checkoutState.checkout; updatePhoneNumber('5554242424'); } ``` ## Update the Customer's business name and tax ID Use this method to update the Customer's business name and tax ID. This method returns a `Promise` that resolves with an object containing the following fields: * `type`: one of either `"success"` or `"error"` * `session`: only populated when `type` is `"success"`. Contains a [Session](/js/custom_checkout/session_object) instance representing the updated state. * `error`: only populated when `type` is `"error"`. Contains an object with a string `message` field which can be displayed to your customer. - `taxIdInfo` The Customer's tax ID information including the business name and tax ID. - `businessName` (nullable string) **required** The Customer's business name. - `taxId` **required** The Customer's tax ID. - `type` **required** One of [the supported tax ID types](/tax/checkout/tax-ids?payment-ui=embedded-components.md#supported-types) - `value` (nullable string) **required** The value of the tax ID. ### Update the Customer's business name and tax ID ```jsx const checkoutState = useCheckout(); if (checkoutState.type === 'success') { const {updateTaxIdInfo} = checkoutState.checkout; updateTaxIdInfo({ businessName: 'Acme, Inc.', taxID: { type: 'eu_vat', value: 'DK12345678' } }); } ``` ## Update line item quantities Use this method to change the quantity of a line item. This method returns a `Promise` that resolves with an object containing the following fields: * `type`: one of either `"success"` or `"error"` * `session`: only populated when `type` is `"success"`. Contains a [Session](/js/custom_checkout/session_object) instance representing the updated state. * `error`: only populated when `type` is `"error"`. Contains an object with a string `message` field which can be displayed to your customer. - `options` (object) **required** Options for `updateLineItemQuantity`. - `lineItem` (string) **required** The [ID](/js/custom_checkout/session_object.md#custom_checkout_session_object-lineItems-id) of the line item to update. - `quantity` (integer) **required** The new quantity of the line item. ### Update line item quantities ```jsx const checkoutState = useCheckout(); if (checkoutState.type === 'success') { const {updateLineItemQuantity} = checkoutState.checkout; updateLineItemQuantity({ lineItem: 'LINE_ITEM_ID', quantity: 2, }); } ``` ## Update the selected shipping option Use this method to update the selected shipping option. See [shippingOptions](/js/custom_checkout/session_object.md#custom_checkout_session_object-shippingOptions) for a list of the available shipping options. This method returns a `Promise` that resolves with an object containing the following fields: * `type`: one of either `"success"` or `"error"` * `session`: only populated when `type` is `"success"`. Contains a [Session](/js/custom_checkout/session_object) instance representing the updated state. * `error`: only populated when `type` is `"error"`. Contains an object with a string `message` field which can be displayed to your customer. - `shippingOption` (string) The [ID](/js/custom_checkout/session_object.md#custom_checkout_session_object-shippingOptions-id) of the shipping option to select. ### Update the selected shipping option ```jsx const checkoutState = useCheckout(); if (checkoutState.type === 'success') { const {updateShippingOption} = checkoutState.checkout; updateShippingOption('SHIPPING_OPTION_ID'); } ``` ## Confirm the Checkout Session Use this method to confirm the Checkout Session. You must either read [total.total.amount](/js/custom_checkout/session_object.md#custom_checkout_session_object-total-total-amount) or each of [total.total.minorUnitsAmount](/js/custom_checkout/session_object.md#custom_checkout_session_object-total-total-minorUnitsAmount) and [currency](/js/custom_checkout/session_object.md#custom_checkout_session_object-currency) and [minorUnitsAmountDivisor](/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. This method returns a `Promise` that resolves with an object containing the following fields: * `type`: one of either `"success"` or `"error"` * `session`: only populated when `type` is `"success"`. Contains a [Session](/js/custom_checkout/session_object) instance representing the updated state. * `error`: only populated when `type` is `"error"`. Contains an object with a string `message` field which can be displayed to your customer. - `options` (object) Options for `confirm`. - `returnUrl` (string) 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` (string) The ID of a previously collected [PaymentMethod](/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` (boolean) Whether your Customer has provided consent to save the payment method for future purchases. Learn how to [save payment methods](/checkout/custom-checkout/save-payment-methods-checkout.md). - `redirect` ('always' | 'if_required') 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` (string) The Customer's email address. If provided, this value overrides any values previously set using [updateEmail](/js/custom_checkout/update_email.md). - `phoneNumber` (string) The Customer's phone number. If provided, this value overrides any values previously set using [updatePhoneNumber](/js/custom_checkout/update_phone_number.md). - `billingAddress` (object) The Customer's billing address. If provided, this value overrides any values previously set using [updateBillingAddress](/js/custom_checkout/update_billing_address.md). - `name` (optional string) Full name. - `address` (optional object) Address. - `country` (string) **required** Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). - `line1` (optional string) Address line 1 (e.g., street, PO Box, or company name). - `line2` (optional string) Address line 2 (e.g., apartment, suite, unit, or building). - `city` (optional string) City, district, suburb, town, or village. - `postal_code` (optional string) ZIP or postal code. - `state` (optional string) State, county, province, or region. - `shippingAddress` (object) The Customer's shipping address. If provided, this value overrides any values previously set using [updateShippingAddress](/js/custom_checkout/update_shipping_address.md). - `name` (optional string) Full name. - `address` (optional object) Address. - `country` (string) **required** Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). - `line1` (string) **required** Address line 1 (e.g., street, PO Box, or company name). - `line2` (optional string) Address line 2 (e.g., apartment, suite, unit, or building). - `city` (optional string) City, district, suburb, town, or village. - `postal_code` (optional string) ZIP or postal code. - `state` (optional string) State, county, province, or region. - `expressCheckoutConfirmEvent` (object) The [event object](/js/elements_object/express_checkout_element_confirm_event.md#express_checkout_element_on_confirm-handler) passed to your Express Checkout Element `confirm` handler. ### Confirm the Checkout Session ```jsx const checkoutState = useCheckout(); if (checkoutState.type === 'success') { const {confirm} = checkoutState.checkout; confirm({ returnUrl: 'RETURN_URL', }); } ``` ## Run server update 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. This method returns a `Promise` that resolves with an object containing the following fields: * `type`: one of either `"success"` or `"error"` * `session`: only populated when `type` is `"success"`. Contains a [Session](/js/custom_checkout/session_object) instance representing the updated state. * `error`: only populated when `type` is `"error"`. Contains an object with a string `message` field which can be displayed to your customer. - `userFunction` (function) **required** An async function to make a request to your server to update the Checkout Session. ### Run server update ```jsx const checkoutState = useCheckout(); if (checkoutState.type === 'success') { const {runServerUpdate, id} = checkoutState.checkout; runServerUpdate( () => { return fetch('/update-checkout-session', { method: 'POST', body: JSON.stringify({checkoutSessionId: id}), }); } ); } ``` ## PaymentElement Use the `PaymentElement` from `@stripe/react-stripe-js/checkout` to collect payment details for more than [40 payment methods](/docs/payments/payment-methods/integration-options.md) from around the globe. The component must be rendered inside a [CheckoutProvider](/js/react_stripe_js/checkout/checkout_provider.md). ### Props - `id` (string) Sets the DOM `id` attribute on the rendered Element container. Use this to target the Element for styling or testing. - `className` (string) Applies custom CSS classes to the Element container. - `options` (object) Payment Element initialization options. - `fields` (object) 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` ('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. - `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._ - `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 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` (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 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` ('auto' | 'never') - `googlePay` ('auto' | 'never') - `link` ('auto' | 'never') - `onChange` (function) Callback called when any value in the [change event payload](/js/element/events/on_change?type=paymentElement.md#element_on_change-handler) changes. - `onReady` (function) Callback called once the Element is fully rendered. Recieves the [ready event payload](/js/element/events/on_ready.md#element_on_ready-handler). - `onBlur` (function) Callback called when the Element loses focus. - `onFocus` (function) Callback called when the Element receives focus. - `onEscape` (function) Callback called when the escape key is pressed within the Element. - `onLoaderStart` (function) Callback called right before Stripe displays the Element skeleton loader. Receives the Element instance as its only argument. - `onLoadError` (function) Callback called when the Element fails to load. ### Render PaymentElement ```jsx import React from 'react'; import {CheckoutProvider, PaymentElement} from '@stripe/react-stripe-js/checkout'; import {loadStripe} from '@stripe/stripe-js'; const stripePromise = loadStripe('{TEST_PUBLISHABLE_KEY}'); const App = ({clientSecret}) => (
); export default App; ``` ## ExpressCheckoutElement Use the `ExpressCheckoutElement` from `@stripe/react-stripe-js/checkout` to accept payments through one-click payment buttons. The component must be rendered inside a [CheckoutProvider](/js/react_stripe_js/checkout/checkout_provider.md). ### Props - `id` (string) Sets the DOM `id` attribute on the rendered Element container. Use this to target the Element for styling or testing. - `className` (string) Applies custom CSS classes to the Element container. - `options` (object) Express Checkout Element initialization options. - `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`. - `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. - `paymentMethods` (object) 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` ('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`. - `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`. - `link` ('auto' | 'never') - `paypal` ('auto' | 'never') - `onConfirm` (function) **required** Triggered when the Element fires a confirm event. Use this to handle payment confirmation. - `onReady` (function) Callback called once the Element is fully rendered. Recieves the [ready event payload](/js/element/events/on_ready.md#element_on_ready-handler). - `onBlur` (function) Callback called when the Element loses focus. - `onFocus` (function) Callback called when the Element receives focus. - `onEscape` (function) Callback called when the escape key is pressed within the Element. - `onLoadError` (function) Callback called when the Element fails to load. ### Render ExpressCheckoutElement ```jsx import React from 'react'; import {CheckoutProvider, ExpressCheckoutElement} from '@stripe/react-stripe-js/checkout'; import {loadStripe} from '@stripe/stripe-js'; const stripePromise = loadStripe('{TEST_PUBLISHABLE_KEY}'); const App = ({clientSecret}) => ( { // Fulfill order once the payment is confirmed }} /> ); export default App; ``` ## BillingAddressElement Use the `BillingAddressElement` from `@stripe/react-stripe-js/checkout` to render and update the billing address on the current [Checkout Session](/api/checkout/sessions/object.md). The component must be rendered inside a [CheckoutProvider](/js/react_stripe_js/checkout/checkout_provider.md). ### Props - `id` (string) Sets the DOM `id` attribute on the rendered Element container. Use this to target the Element for styling or testing. - `className` (string) Applies custom CSS classes to the Element container. - `options` (object) Billing Address Element initialization options. - `contacts` (array) An array of [Contact](/js/appendix/contact_object.md) objects that can be displayed as saved addresses in the Billing Address Element. The first contact is automatically selected. - `display` (object) You can customize how certain fields are displayed. - `name` ('full' | 'split' | 'organization') 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. - `onChange` (function) Callback called when any value in the [change event payload](/js/element/events/on_change?type=addressElement.md#element_on_change-handler) changes. - `onReady` (function) Callback called once the Element is fully rendered. Recieves the [ready event payload](/js/element/events/on_ready.md#element_on_ready-handler). - `onBlur` (function) Callback called when the Element loses focus. - `onFocus` (function) Callback called when the Element receives focus. - `onEscape` (function) Callback called when the escape key is pressed within the Element. - `onLoaderStart` (function) Callback called right before Stripe displays the Element skeleton loader. Receives the Element instance as its only argument. - `onLoadError` (function) Callback called when the Element fails to load. ### Render BillingAddressElement ```JSX import React from 'react'; import {CheckoutProvider, BillingAddressElement} from '@stripe/react-stripe-js/checkout'; import {loadStripe} from '@stripe/stripe-js'; const stripePromise = loadStripe('{TEST_PUBLISHABLE_KEY}'); const App = ({clientSecret}) => ( ); export default App; ``` ## ShippingAddressElement Use the `ShippingAddressElement` from `@stripe/react-stripe-js/checkout` to render and update the shipping address on the current [Checkout Session](/api/checkout/sessions/object.md). The component must be rendered inside a [CheckoutProvider](/js/react_stripe_js/checkout/checkout_provider.md). ### Props - `id` (string) Sets the DOM `id` attribute on the rendered Element container. Use this to target the Element for styling or testing. - `className` (string) Applies custom CSS classes to the Element container. - `options` (object) Shipping Address Element initialization options. - `contacts` (array) An array of [Contact](/js/appendix/contact_object.md) objects that can be displayed as saved addresses in the Shipping Address Element. The first contact is automatically selected. - `display` (object) You can customize how certain fields are displayed. - `name` ('full' | 'split' | 'organization') 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. - `onChange` (function) Callback called when any value in the [change event payload](/js/element/events/on_change?type=addressElement.md#element_on_change-handler) changes. - `onReady` (function) Callback called once the Element is fully rendered. Recieves the [ready event payload](/js/element/events/on_ready.md#element_on_ready-handler). - `onBlur` (function) Callback called when the Element loses focus. - `onFocus` (function) Callback called when the Element receives focus. - `onEscape` (function) Callback called when the escape key is pressed within the Element. - `onLoaderStart` (function) Callback called right before Stripe displays the Element skeleton loader. Receives the Element instance as its only argument. - `onLoadError` (function) Callback called when the Element fails to load. ### Render ShippingAddressElement ```JSX import React from 'react'; import {CheckoutProvider, ShippingAddressElement} from '@stripe/react-stripe-js/checkout'; import {loadStripe} from '@stripe/stripe-js'; const stripePromise = loadStripe('{TEST_PUBLISHABLE_KEY}'); export const ShippingAddressSection = ({clientSecret}) => ( ); ``` ## CurrencySelectorElement Use the `CurrencySelectorElement` from `@stripe/react-stripe-js/checkout` to allow customers to select the currency for their payment. The component must be rendered inside a [CheckoutProvider](/js/react_stripe_js/checkout/checkout_provider.md). ### Props - `id` (string) Sets the DOM `id` attribute on the rendered Element container. Use this to target the Element for styling or testing. - `className` (string) Applies custom CSS classes to the Element container. - `onReady` (function) Callback called once the Element is fully rendered. Recieves the [ready event payload](/js/element/events/on_ready.md#element_on_ready-handler). - `onBlur` (function) Callback called when the Element loses focus. - `onFocus` (function) Callback called when the Element receives focus. - `onEscape` (function) Callback called when the escape key is pressed within the Element. - `onLoaderStart` (function) Callback called right before Stripe displays the Element skeleton loader. Receives the Element instance as its only argument. - `onLoadError` (function) Callback called when the Element fails to load. ### Render CurrencySelectorElement ```jsx import React from 'react'; import {CheckoutProvider, CurrencySelectorElement} from '@stripe/react-stripe-js/checkout'; import {loadStripe} from '@stripe/stripe-js'; const stripePromise = loadStripe('{TEST_PUBLISHABLE_KEY}'); const App = ({clientSecret}) => ( ); export default App; ``` ## TaxIdElement Use the `TaxIdElement` from `@stripe/react-stripe-js/checkout` to collect tax ID information from your customers, including business name and tax identification number. The component must be rendered inside a [CheckoutProvider](/js/react_stripe_js/checkout/checkout_provider.md). > This feature requires the `custom_checkout_tax_id_1` beta. To use it, pass `betas: ['custom_checkout_tax_id_1']` when initializing Stripe.js via `loadStripe`. ### Props - `id` (string) Sets the DOM `id` attribute on the rendered Element container. Use this to target the Element for styling or testing. - `className` (string) Applies custom CSS classes to the Element container. - `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`. - `onChange` (function) Callback called when any value in the [change event payload](/js/element/events/on_change?type=taxIdElement.md#element_on_change-handler) changes. - `onReady` (function) Callback called once the Element is fully rendered. Recieves the [ready event payload](/js/element/events/on_ready.md#element_on_ready-handler). - `onBlur` (function) Callback called when the Element loses focus. - `onFocus` (function) Callback called when the Element receives focus. - `onEscape` (function) Callback called when the escape key is pressed within the Element. - `onLoaderStart` (function) Callback called right before Stripe displays the Element skeleton loader. Receives the Element instance as its only argument. - `onLoadError` (function) Callback called when the Element fails to load. ### Render TaxIdElement ```jsx import React from 'react'; import {CheckoutProvider, TaxIdElement} from '@stripe/react-stripe-js/checkout'; import {loadStripe} from '@stripe/stripe-js'; const stripePromise = loadStripe('{TEST_PUBLISHABLE_KEY}', { betas: ['custom_checkout_tax_id_1'], }); const App = ({clientSecret}) => ( { // Handle tax ID changes console.log('Tax ID changed:', event); }} /> ); export default App; ```