## Setup Intents Use the [Setup Intents APIs](/payments/setup-intents.md) to save a card and charge it later. For step-by-step instructions on using the Setup Intents APIs, see the [set up recurring payments guide](/payments/save-and-reuse.md). The following Stripe.js methods are available for working with Setup Intents. ## Confirm a setup Use `stripe.confirmSetup` to confirm a [SetupIntent](/api/setup_intents.md) using data collected by the [Payment Element](/js/element/payment_element.md), or with manually provided data via `confirmParams`. When called, `stripe.confirmSetup` will attempt to complete any [required actions](/payments/intents.md), such as authenticating your user by displaying a 3DS dialog or redirecting them to a bank authorization page. Your user will be redirected to the `return_url` you pass once the authorization is complete. > The `stripe.confirmSetup` might take several seconds to complete. > During that time, disable your form from being resubmitted and show a waiting indicator, such as a spinner. If you receive an error result, show this error to the user, re-enable the form, and hide the waiting indicator. `stripe.confirmSetup` will return a `Promise`. For payments that don't require a redirect, the `Promise` resolves to the updated Intent. After a successful authorization, Stripe redirects your user to the `return_url` you provided before the `Promise` resolves. For payments that don't require a redirect, the `Promise` resolves to the updated Intent. If the authorization fails, the `Promise` resolves with an `{error}` object that describes the failure. If the [error type](/api/errors#errors-type) is either `card_error` or `validation_error`, directly display the error message in `error.message` to your user. If the error type is `invalid_request_error, you might have an invalid request or 3DS authentication failures. For some payment methods, such as iDEAL or Afterpay/Clearpay, Stripe first redirects your user to an intermediate page to authorize the payment. If iDEAL or Afterpay/Clearpay fail to authorize the payment, Stripe redirects the user to your `return_url`, and the SetupIntent has a `status` of `requires_payment_method`. In this case, attempt to recollect payment from the user. **Syntax:** `stripe.confirmSetup(...)` - `options` (object) **required** - `elements` (object) **required** The [Elements](#payment_element_create) instance used to create the Payment Element. Required if you [collect payment details before creating an Intent](/payments/accept-a-payment-deferred.md?platform=web&type=setup). It's always required if you don't provide a `clientSecret`. - `clientSecret` (string) **required** The SetupIntent's client secret. Required if you [collect payment details before creating an Intent](/payments/accept-a-payment-deferred.md?platform=web&type=setup). It's always required if you don't provide an `elements` instance containing a [client secret](/api/setup_intents/object.md#setup_intent_object-client_secret). - `confirmParams` (object) Parameters that will be passed on to the Stripe API. Refer to the [Setup Intents API](/api/setup_intents/confirm.md) for a full list of parameters. - `return_url` (string) **required** The URL that Stripe redirects your customer to after they complete authentication. - `confirmation_token` (string) If collected previously, the ID of the ConfirmationToken to use to confirm this SetupIntent. This is mutually exclusive with the `elements` parameter. - `payment_method_data` (object) When you call `stripe.confirmSetup`, payment details are collected from the Element and passed to the SetupIntents [confirm endpoint](/api/setup_intents/confirm.md) as the [payment_method_data](/api/setup_intents/confirm.md#confirm_setup_intent-payment_method) parameter. You can also include additional `payment_method_data` fields, which will be merged with the data collected from the Element. - `billing_details` (object) The customer's [billing_details](/api/payment_methods/create.md#create_payment_method-billing_details). Details collected by Elements will override values passed here. Billing fields that are omitted in the Payment Element via the `fields` option required. - `allow_redisplay` ('unspecified' | 'always' | 'limited') Indicates whether the payment method can be displayed to the customer in subsequent checkout flows. The value passed here will override the [allow_redisplay](docs/api/payment_methods/object#payment_method_object-allow_redisplay) determined by the provided `elements` parameter. - `expand` (array) An array of pass through [SetupIntent](/api/setup_intents/object.md) expansion parameters ([learn more](/api/expanding_objects.md)). - `redirect` ('always' | 'if_required') By default, `stripe.confirmSetup` will always redirect to your `return_url` after a successful confirmation. If you set `redirect: "if_required"`, then `stripe.confirmSetup` will only redirect if your user chooses a redirect-based payment method. **Note**: Setting `if_required` requires that you handle successful confirmations for redirect-based and non-redirect based payment methods separately. When a non-redirect based payment method is successfully confirmed, `stripe.confirmSetup` will resolve with a `{setupIntent}` object. ### Confirm a setup intent ```js stripe.confirmSetup({ elements, confirmParams: { // Return URL where the customer should be redirected after the SetupIntent is confirmed. return_url: 'https://example.com', }, }) .then(function(result) { if (result.error) { // Inform the customer that there was an error. } }); ``` ```es_next const {error} = await stripe.confirmSetup( { elements, confirmParams: { // Return URL where the customer should be redirected after the SetupIntent is confirmed. return_url: 'https://example.com', }, } ); if (error) { // Inform the customer that there was an error. } ``` ## Confirm a SetupIntent by payment method Below are a number of methods used to confirm a SetupIntent for a specific payment method type. ## Confirm card setup Use `stripe.confirmCardSetup` in the [Setup Intents API flow](/payments/save-and-reuse.md) when the customer submits your payment form. When called, it will confirm the [SetupIntent](/api/setup_intents.md) with `data` you provide and carry out 3DS or other next actions if they are required. When you confirm a `SetupIntent`, it needs to have an attached [PaymentMethod](/api/payment_methods.md). In addition to confirming the `SetupIntent`, this method can automatically create and attach a new `PaymentMethod` for you. It can also be called with an existing `PaymentMethod`, or if you have already attached a `PaymentMethod` you can call this method without needing to provide any additional data. These use cases are detailed in the sections that follow. > Note that `stripe.confirmCardSetup` may take several seconds to complete. > During that time, you should disable your form from being resubmitted and show a waiting indicator like a spinner. > If you receive an error result, you should be sure to show that error to the customer, re-enable the form, and hide the waiting indicator. > > Additionally, `stripe.confirmCardSetup` may trigger a [3D Secure](/payments/3d-secure.md) authentication challenge. > This will be shown in a modal dialog and may be confusing for customers using assistive technologies like screen readers. > You should make your form accessible by ensuring that success or error messages are clearly read out after this method completes. `stripe.confirmCardSetup` will return a `Promise` which resolves with a `result` object. This object has either: * `result.setupIntent`: the successful [SetupIntent](/api/setup_intents). * `result.error`: an error. Refer to the [API reference](/api/errors) for all possible errors. **Syntax:** `stripe.confirmCardSetup(...)` - `clientSecret` (string) **required** The [client secret](/api/setup_intents/object.md#setup_intent_object-client_secret) of the `SetupIntent`. - `data` (object) Data to be sent with the request. Refer to the [Setup Intents API](/api/setup_intents/confirm.md) for a full list of parameters. - `payment_method` (string | object) Either the `id` of an existing [PaymentMethod](/api/payment_methods.md), or an object containing data to create a `PaymentMethod` with. See the use case sections below for details. - `return_url` (string) If you are [handling next actions yourself](/payments/payment-intents/verifying-status.md#next-actions), pass in a `return_url`. If the subsequent action is `redirect_to_url`, this URL will be used on the return path for the redirect. - `options` (object) An options object to control the behavior of this method. - `handleActions` (boolean) Set this to `false` if you want to [handle next actions yourself](/payments/payment-intents/verifying-status.md#next-actions), or if you want to defer next action handling until later (e.g. for use in the [PaymentRequest API](/stripe-js/elements/payment-request-button.md#complete-payment-intents)). Default is `true`. ### Use case: with payment data from an Element Use `stripe.confirmCardSetup` with payment data from an [Element](/js/element.md) by passing a `card` or `cardNumber` `Element` to `payment_method[card]`. The new `PaymentMethod` will be created with data collected by the `Element` and will be used to confirm the `SetupIntent`. ### Data argument properties - `payment_method` (object) **required** Pass an object to confirm using data collected by a `card` or `cardNumber` [Element](/js/element.md). - `card` (Element) **required** Uses the provided `card` or `cardNumber` [Element](/js/element.md) for confirmation. - `billing_details` (object) The [billing_details](/api/payment_methods/create.md#create_payment_method-billing_details) associated with the card. ### Confirm with an Element ```js stripe .confirmCardSetup('{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { card: cardElement, billing_details: { name: 'Jenny Rosen', }, }, }) .then(function(result) { // Handle result.error or result.setupIntent }); ``` ```es_next const {setupIntent, error} = await stripe.confirmCardSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { card: cardElement, billing_details: { name: 'Jenny Rosen', }, }, }, ); ``` ### Use case: with an existing payment method Use `stripe.confirmCardSetup` with an existing `PaymentMethod` by passing its `id` to `payment_method`. The `PaymentMethod` will be used to confirm the `SetupIntent`. ### Data argument properties - `payment_method` (string) **required** The `id` of an existing [PaymentMethod](/api/payment_methods.md). ### Confirm with existing payment method ```js stripe .confirmCardSetup('{SETUP_INTENT_CLIENT_SECRET}', { payment_method: '{PAYMENT_METHOD_ID}', }) .then(function(result) { // Handle result.error or result.setupIntent }); ``` ```es_next const {setupIntent, error} = await stripe.confirmCardSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: '{PAYMENT_METHOD_ID}', }, ); ``` ### Use case: with an existing token For backwards compatibility, you can convert an existing `Token` into a `PaymentMethod` with `stripe.confirmCardSetup` by passing the `Token` to `payment_method[card][token]`. The newly created `PaymentMethod` will be used to confirm the `PaymentMethod`. ### Data argument properties - `payment_method` (object) **required** Pass an object to confirm using an existing token. - `card` (object) **required** An object of card data. - `token` (string) **required** Converts the provided token into a `PaymentMethod` to use for confirmation. - `billing_details` (object) The [billing_details](/api/payment_methods/create.md#create_payment_method-billing_details) associated with the card. ### Confirm with existing token ```js stripe .confirmCardSetup('{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { card: { token: 'tok_visa', }, }, }) .then(function(result) { // Handle result.error or result.setupIntent }); ``` ```es_next const {setupIntent, error} = await stripe.confirmCardSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { card: { token: 'tok_visa', }, }, }, ); ``` ### Use case: with an attached PaymentMethod If you have already attached a `PaymentMethod` to this `SetupIntent`, then you can confirm the `SetupIntent` using `stripe.confirmCardSetup` without passing in any additional data. ### Confirm with an attached PaymentMethod ```js stripe .confirmCardSetup('{SETUP_INTENT_CLIENT_SECRET}') .then(function(result) { // Handle result.error or result.setupIntent }); ``` ```es_next const {setupIntent, error} = await stripe.confirmCardSetup( '{SETUP_INTENT_CLIENT_SECRET}', ); ``` ### Confirm card setup ```js stripe .confirmCardSetup('{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { card: cardElement, billing_details: { name: 'Jenny Rosen', }, }, }) .then(function(result) { // Handle result.error or result.setupIntent }); ``` ```es_next const {setupIntent, error} = await stripe.confirmCardSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { card: cardElement, billing_details: { name: 'Jenny Rosen', }, }, }, ); ``` ## Confirm an ACH Direct Debit setup Use `stripe.confirmUsBankAccountSetup` in the [Save bank details](/payments/ach-direct-debit/set-up-payment.md) flow for the [ACH Direct Debit](/payments/ach-direct-debit.md) payment method to record the customer’s authorization for future payments. When you confirm a [SetupIntent](/api/setup_intents.md), it needs to have an attached [PaymentMethod](/api/payment_methods.md). We suggest using `stripe.collectBankAccountForSetup`, which automatically collects bank account details and attaches a [PaymentMethod](/api/payment_methods.md). You may also choose to reuse an existing `PaymentMethod` or manually collect bank account details using the `data` parameter. These use cases are detailed in the sections that follow. `stripe.confirmUsBankAccountSetup` will return a `Promise` which resolves with a result object. This object has either: * `result.setupIntent`: the successful [SetupIntent](/api/setup_intents). * `result.error`: an error. Refer to the [API reference](/api#errors) and our [integration guide](/payments/ach-direct-debit/set-up-payment) for all possible errors. **Syntax:** `stripe.confirmUsBankAccountSetup(...)` - `clientSecret` (string) **required** The [client secret](/api/setup_intents/object.md#setup_intent_object-client_secret) of the `SetupIntent`. - `data` (object) Data to be sent with the request. Refer to the [Setup Intents API](/api/setup_intents/confirm.md) for a full list of parameters. - `payment_method` (object | string) The `id` of an existing PaymentMethod or an object of collected data. See use cases below for details. ### Use case: with an existing PaymentMethod If you have already created a `PaymentMethod`, you can pass its `id` to `payment_method` when calling `stripe.confirmUsBankAccountSetup`. ### Data argument properties - `payment_method` (string) **required** The `id` of an existing [PaymentMethod](/api/payment_methods.md). ### Confirm with an existing PaymentMethod ```js stripe.confirmUsBankAccountSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: '{PAYMENT_METHOD_ID}', } ).then(function(result) { if (result.error) { // Inform the customer that there was an error. console.log(result.error.message); } else { // Handle next step based on SetupIntent's status. console.log("SetupIntent ID: " + result.setupIntent.id); console.log("SetupIntent status: " + result.setupIntent.status); } }); ``` ```es_next const {setupIntent, error} = await stripe.confirmUsBankAccountSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: '{PAYMENT_METHOD_ID}', } ); if (error) { // Inform the customer that there was an error. console.log(error.message); } else { // Handle next step based on SetupIntent's status. console.log("SetupIntent ID: " + setupIntent.id); console.log("SetupIntent status: " + setupIntent.status); } ``` ### Use case: with an attached PaymentMethod If you have successfully called `stripe.collectBankAccountForSetup` or attached a `PaymentMethod` to this `SetupIntent` already, then you can confirm the `SetupIntent` without passing in any additional data. ### Confirm with an attached PaymentMethod ```js stripe.confirmUsBankAccountSetup( '{SETUP_INTENT_CLIENT_SECRET}', {} ).then(function(result) { if (result.error) { // Inform the customer that there was an error. console.log(result.error.message); } else { // Handle next step based on SetupIntent's status. console.log("SetupIntent ID: " + result.setupIntent.id); console.log("SetupIntent status: " + result.setupIntent.status); } }); ``` ```es_next const {setupIntent, error} = await stripe.confirmUsBankAccountSetup( '{SETUP_INTENT_CLIENT_SECRET}', {} ); if (error) { // Inform the customer that there was an error. console.log(error.message); } else { // Handle next step based on SetupIntent's status. console.log("SetupIntent ID: " + setupIntent.id); console.log("SetupIntent status: " + setupIntent.status); } ``` ### Use case: with self collected bank account information If you already know the customer’s bank account information, or want to collect it yourself, you can pass them in directly to create a new `PaymentMethod` and confirm the `SetupIntent`. ### Data argument properties - `payment_method` (object) **required** Pass an object to confirm using data collected. - `billing_details` (Object) **required** The customer's [billing_details](/api/payment_methods/create.md#create_payment_method-billing_details). `name` is required. Providing `email` allows your customer to receive [ACH Direct Debit mandate and microdeposit emails](/payments/ach-direct-debit.md#mandate-and-microdeposit-emails). - `name` (string) **required** The customer's name. The first and last name must be at minimum 2 characters each. - `email` (string) The customer's email. - `us_bank_account` (Object) **required** The customer's [bank account information](/api/payment_methods/create.md#create_payment_method-us_bank_account). - `account_number` (string) **required** The customer’s bank account number. - `routing_number` (string) **required** The routing number of the customer’s bank. - `account_holder_type` (string) **required** Account holder type: individual or company. - `account_type` (string) Account type: checkings or savings. Defaults to checking if omitted. ### Confirm with bank account information ```js stripe.confirmUsBankAccountSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { us_bank_account: { routing_number: '110000000', account_number: '000123456789', account_holder_type: 'individual', }, billing_details: { name: 'Jenny Rosen', email: 'jenny@example.com', }, }, } ).then(function(result) { if (result.error) { // Inform the customer that there was an error. console.log(result.error.message); } else { // Handle next step based on SetupIntent's status. console.log("SetupIntent ID: " + result.setupIntent.id); console.log("SetupIntent status: " + result.setupIntent.status); } }); ``` ```es_next const {setupIntent, error} = await stripe.confirmUsBankAccountSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { us_bank_account: { routing_number: '110000000', account_number: '000123456789', account_holder_type: 'individual', }, billing_details: { name: 'Jenny Rosen', email: 'jenny@example.com', }, }, } ); if (error) { // Inform the customer that there was an error. console.log(error.message); } else { // Handle next step based on SetupIntent's status. console.log("SetupIntent ID: " + setupIntent.id); console.log("SetupIntent status: " + setupIntent.status); } ``` ### Confirm an ACH Direct Debit setup ```js stripe.confirmUsBankAccountSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { us_bank_account: { routing_number: '110000000', account_number: '000123456789', account_holder_type: 'individual', }, billing_details: { name: 'Jenny Rosen', email: 'jenny@example.com', }, }, } ).then(function(result) { if (result.error) { // Inform the customer that there was an error. console.log(result.error.message); } else { // Handle next step based on SetupIntent's status. console.log("SetupIntent ID: " + result.setupIntent.id); console.log("SetupIntent status: " + result.setupIntent.status); } }); ``` ```es_next const {setupIntent, error} = await stripe.confirmUsBankAccountSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { us_bank_account: { routing_number: '110000000', account_number: '000123456789', account_holder_type: 'individual', }, billing_details: { name: 'Jenny Rosen', email: 'jenny@example.com', }, }, } ); if (error) { // Inform the customer that there was an error. console.log(error.message); } else { // Handle next step based on SetupIntent's status. console.log("SetupIntent ID: " + setupIntent.id); console.log("SetupIntent status: " + setupIntent.status); } ``` ## Confirm a Canadian pre-authorized debit setup Use `stripe.confirmAcssDebitSetup` in the [Save bank details](/payments/acss-debit/set-up-payment.md) flow to set up a [Canadian pre-authorized debit](/payments/acss-debit.md) payment method for future payments. When called, it will automatically pop up a modal to collect bank account details and verification, accept the mandate, and confirm the [SetupIntent](/api/setup_intents.md) when the user submits the form. Note that there are some additional requirements to this flow that are not covered in this reference. Refer to our [integration guide](/payments/acss-debit/set-up-payment.md) for more details. When you confirm a `SetupIntent`, it needs to have an attached [PaymentMethod](/api/payment_methods.md). `stripe.confirmAcssDebitSetup` automatically creates a new `PaymentMethod` for you when your customer completes the modal UI. It can also be called with an existing `PaymentMethod`, which will load the modal UI to collect a new mandate agreement. These use cases are detailed in the sections that follow. > Note that `stripe.confirmAcssDebitSetup` may take several seconds to complete. > During that time, disable your form from being resubmitted and show a waiting indicator like a spinner. > If you receive an error result, show it to the customer, re-enable the form, and hide the waiting indicator. `stripe.confirmAcssDebitSetup` will return a `Promise` which resolves with a result object. This object has either: * `result.setupIntent`: the successful [SetupIntent](/api/setup_intents). * `result.error`: an error. Refer to the [API reference](/api#errors) and our [integration guide](/payments/acss-debit/set-up-payment) for all possible errors. **Syntax:** `stripe.confirmAcssDebitSetup(...)` - `clientSecret` (string) **required** The [client secret](/api/setup_intents/object.md#setup_intent_object-client_secret) of the `SetupIntent`. - `data` (object) Data to be sent with the request. Refer to the [Setup Intents API](/api/setup_intents/confirm.md) for a full list of parameters. - `payment_method` (object | string) The `id` of an existing PaymentMethod or an object of collected data. See use cases below for details. - `options` (object) An options object to control the behavior of this method. - `skipMandate` (boolean) Set this to `true` if you want to skip displaying the mandate confirmation. ### Use case: with a new PaymentMethod You can pass in the customer’s billing details to create a new `PaymentMethod` and confirm the `SetupIntent`. You are required to collect and include the customer’s name and email address. This method loads an on-page modal UI that handles bank account details collection and verification, presents a hosted mandate agreement and collects authorization for you. ### Data argument properties - `payment_method` (object) **required** Pass an object to confirm using data collected. - `billing_details` (Object) **required** The customer's [billing_details](/api/payment_methods/create.md#create_payment_method-billing_details). `name` and `email` are required. - `name` (string) **required** The customer's name. The first and last name must be at minimum 2 characters each. - `email` (string) **required** The customer's email. ### Confirm with a new PaymentMethod ```js stripe.confirmAcssDebitSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { billing_details: { name: 'Jenny Rosen', email: 'jenny@example.com', }, }, } ).then(function(result) { if (result.error) { // Inform the customer that there was an error. console.log(result.error.message); } else { // Handle next step based on SetupIntent's status. console.log("SetupIntent ID: " + result.setupIntent.id); console.log("SetupIntent status: " + result.setupIntent.status); } }); ``` ```es_next const {setupIntent, error} = await stripe.confirmAcssDebitSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { billing_details: { name: 'Jenny Rosen', email: 'jenny@example.com', }, }, } ); if (error) { // Inform the customer that there was an error. console.log(error.message); } else { // Handle next step based on SetupIntent's status. console.log("SetupIntent ID: " + setupIntent.id); console.log("SetupIntent status: " + setupIntent.status); } ``` ### Use case: with an existing PaymentMethod If you have already created a `PaymentMethod`, you can pass its `id` to `payment_method` when calling `stripe.confirmAcssDebitSetup`. This method loads an on-page modal UI that only presents a hosted mandate agreement and collects authorization for you. ### Data argument properties - `payment_method` (string) **required** The `id` of an existing [PaymentMethod](/api/payment_methods.md). ### Confirm with an existing PaymentMethod ```js stripe.confirmAcssDebitSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: '{PAYMENT_METHOD_ID}', } ).then(function(result) { if (result.error) { // Inform the customer that there was an error. console.log(result.error.message); } else { // Handle next step based on SetupIntent's status. console.log("SetupIntent ID: " + result.setupIntent.id); console.log("SetupIntent status: " + result.setupIntent.status); } }); ``` ```es_next const {setupIntent, error} = await stripe.confirmAcssDebitSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: '{PAYMENT_METHOD_ID}', } ); if (error) { // Inform the customer that there was an error. console.log(error.message); } else { // Handle next step based on SetupIntent's status. console.log("SetupIntent ID: " + setupIntent.id); console.log("SetupIntent status: " + setupIntent.status); } ``` ### Use case: with an attached PaymentMethod If you have already attached a `PaymentMethod` to this `SetupIntent`, then you can confirm the `SetupIntent` without passing in any additional data. This method loads an on-page modal UI that only presents a hosted mandate agreement and collects authorization for you. ### Confirm with an attached PaymentMethod ```js stripe.confirmAcssDebitSetup( '{SETUP_INTENT_CLIENT_SECRET}', {} ).then(function(result) { if (result.error) { // Inform the customer that there was an error. console.log(result.error.message); } else { // Handle next step based on SetupIntent's status. console.log("SetupIntent ID: " + result.setupIntent.id); console.log("SetupIntent status: " + result.setupIntent.status); } }); ``` ```es_next const {setupIntent, error} = await stripe.confirmAcssDebitSetup( '{SETUP_INTENT_CLIENT_SECRET}', {} ); if (error) { // Inform the customer that there was an error. console.log(error.message); } else { // Handle next step based on SetupIntent's status. console.log("SetupIntent ID: " + setupIntent.id); console.log("SetupIntent status: " + setupIntent.status); } ``` ### Use case: with self collected bank account information If you already know the customer’s bank account information, or want to collect it yourself, you can pass them in directly to create a new `PaymentMethod` and confirm the `SetupIntent`. In this case, this method does not load the on-page modal UI, so you will need to [build your own mandate agreement page](/payments/acss-debit/custom-pad-agreement.md). ### Data argument properties - `payment_method` (object) **required** Pass an object to confirm using data collected. - `billing_details` (Object) **required** The customer's [billing_details](/api/payment_methods/create.md#create_payment_method-billing_details). `name` and `email` are required. - `name` (string) **required** The customer's name. The first and last name must be at minimum 2 characters each. - `email` (string) **required** The customer's email. - `acss_debit` (Object) **required** The customer's [bank account information](/api/payment_methods/create.md#create_payment_method-acss_debit). - `account_number` (string) **required** The customer’s bank account number. - `institution_number` (string) **required** The institution number of the customer’s bank. - `transit_number` (string) **required** The transit number of the customer’s bank. ### Confirm with bank account information ```js stripe.confirmAcssDebitSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { acss_debit: { institution_number: '000', transit_number: '11000', account_number: '000123456789', }, billing_details: { name: 'Jenny Rosen', email: 'jenny@example.com', }, }, } ).then(function(result) { if (result.error) { // Inform the customer that there was an error. console.log(result.error.message); } else { // Handle next step based on SetupIntent's status. console.log("SetupIntent ID: " + result.setupIntent.id); console.log("SetupIntent status: " + result.setupIntent.status); } }); ``` ```es_next const {setupIntent, error} = await stripe.confirmAcssDebitSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { acss_debit: { institution_number: '000', transit_number: '11000', account_number: '000123456789', }, billing_details: { name: 'Jenny Rosen', email: 'jenny@example.com', }, }, } ); if (error) { // Inform the customer that there was an error. console.log(error.message); } else { // Handle next step based on SetupIntent's status. console.log("SetupIntent ID: " + setupIntent.id); console.log("SetupIntent status: " + setupIntent.status); } ``` ### Use case: with an existing PaymentMethod but skip mandate display If you have already created a `PaymentMethod` and built your own mandate agreement page, you can reuse it by passing its `id` to `payment_method` when calling `stripe.confirmAcssDebitSetup` and skip the on-page modal UI at the same time. ### Data and options argument paramters - `data` (object) Data to be sent with the request. - `payment_method` (string) **required** The `id` of an existing [PaymentMethod](/api/payment_methods.md). - `options` (object) An options object to control the behavior of this method. - `skipMandate` (boolean) **required** Set to `true` to skip the on-page modal UI. ### Confirm with an existing PaymentMethod but skip mandate display ```js stripe.confirmAcssDebitSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: '{PAYMENT_METHOD_ID}', }, { skipMandate: true, } ).then(function(result) { if (result.error) { // Inform the customer that there was an error. console.log(result.error.message); } else { // Handle next step based on SetupIntent's status. console.log("SetupIntent ID: " + result.setupIntent.id); console.log("SetupIntent status: " + result.setupIntent.status); } }); ``` ```es_next const {setupIntent, error} = await stripe.confirmAcssDebitSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: '{PAYMENT_METHOD_ID}', }, { skipMandate: true, } ); if (error) { // Inform the customer that there was an error. console.log(error.message); } else { // Handle next step based on SetupIntent's status. console.log("SetupIntent ID: " + setupIntent.id); console.log("SetupIntent status: " + setupIntent.status); } ``` ### Confirm Canadian pre-authorized debit setup ```js stripe.confirmAcssDebitSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { billing_details: { name: 'Jenny Rosen', email: 'jenny@example.com', }, }, } ).then(function(result) { if (result.error) { // Inform the customer that there was an error. console.log(result.error.message); } else { // Handle next step based on SetupIntent's status. console.log("SetupIntent ID: " + result.setupIntent.id); console.log("SetupIntent status: " + result.setupIntent.status); } }); ``` ```es_next const {setupIntent, error} = await stripe.confirmAcssDebitSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { billing_details: { name: 'Jenny Rosen', email: 'jenny@example.com', }, }, } ); if (error) { // Inform the customer that there was an error. console.log(error.message); } else { // Handle next step based on SetupIntent's status. console.log("SetupIntent ID: " + setupIntent.id); console.log("SetupIntent status: " + setupIntent.status); } ``` ## Confirm BECS Debit setup Use `stripe.confirmAuBecsDebitSetup` in the [BECS Direct Debit Payments](/payments/au-becs-debit.md) flow when the customer submits your payment form. When called, it will confirm the [SetupIntent](/api/setup_intents.md) with `data` you provide. Note that there are some additional requirements to this flow that are not covered in this reference. Refer to our [integration guide](/payments/au-becs-debit.md) for more details. When you confirm a `SetupIntent`, it needs to have an attached [PaymentMethod](/api/payment_methods.md). In addition to confirming the `SetupIntent`, this method can automatically create and attach a new `PaymentMethod` for you. It can also be called with an existing `PaymentMethod`, or if you have already attached a `PaymentMethod` you can call this method without needing to provide any additional data. These use cases are detailed in the sections that follow. > Note that `stripe.confirmAuBecsDebitSetup` may take several seconds to complete. > During that time, you should disable your form from being resubmitted and show a waiting indicator like a spinner. > If you receive an error result, you should be sure to show that error to the customer, re-enable the form, and hide the waiting indicator. `stripe.confirmAuBecsDebitSetup` will return a `Promise` which resolves with a `result` object. This object has either: * `result.setupIntent`: the successful [SetupIntent](/api/setup_intents). * `result.error`: an error. Refer to the [API reference](/api/errors) for all possible errors. **Syntax:** `stripe.confirmAuBecsDebitSetup(...)` - `clientSecret` (string) **required** The [client secret](/api/setup_intents/object.md#setup_intent_object-client_secret) of the `SetupIntent`. - `data` (object) Data to be sent with the request. Refer to the [Setup Intents API](/api/setup_intents/confirm.md) for a full list of parameters. - `payment_method` (object | string) The `id` of an existing PaymentMethod or an object of collected data. See use cases below for details. ### Use case: with payment data from an Element Create and attach a new `PaymentMethod` with `stripe.confirmAuBecsDebitSetup` by passing an `auBankAccount` [Element](/js/element.md) to `payment_method[au_becs_debit]`. The new `PaymentMethod` will be created with the data collected by the `Element` and will be used to confirm the `SetupIntent`. Additionally, to create a BECS Direct Debit `PaymentMethod`, you are required to collect and include the account holder's name and the customer’s email address. ### Data argument properties - `payment_method` (object) **required** Pass an `object` to confirm using data collected by an `auBankAccount` Element. - `au_becs_debit` (Element) **required** An `auBankAccount` [Element](/js/element.md). - `billing_details` (Object) **required** The customer's [billing_details](/api/payment_methods/create.md#create_payment_method-billing_details). `name` and `email` are required. - `name` (string) **required** The customer's name. - `email` (string) **required** The customer's email. ### Confirm with an Element ```js stripe .confirmAuBecsDebitSetup('{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { au_becs_debit: auBankAccountElement, billing_details: { name: 'John Smith', email: 'john.smith@example.com', }, }, }) .then(function(result) { // Handle result.error or result.setupIntent }); ``` ```es_next const {error, setupIntent} = await stripe.confirmAuBecsDebitSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { au_becs_debit: auBankAccountElement, billing_details: { name: 'John Smith', email: 'john.smith@example.com', }, }, }, ); ``` ### Use case: with an existing payment method If you have already created a `PaymentMethod`, you can pass its `id` to `payment_method` when calling `stripe.confirmAuBecsDebitSetup` and it will be used to confirm the `SetupIntent`. ### Data argument properties - `payment_method` (string) **required** The `id` of an existing `PaymentMethod`. ### Confirm with existing payment method ```js stripe .confirmAuBecsDebitSetup('{SETUP_INTENT_CLIENT_SECRET}', { payment_method: '{PAYMENT_METHOD_ID}', }) .then(function(result) { // Handle result.error or result.setupIntent }); ``` ```es_next const {error, setupIntent} = await stripe.confirmAuBecsDebitSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: '{PAYMENT_METHOD_ID}', }, ); ``` ### Use case: with self collected data If you already know the customer’s BSB number and bank account number or want to collect it yourself, then you do not need to use the `auBankAccount` [Element](/js/element.md). You can pass in the customer’s bank account information directly to create a new `PaymentMethod` and confirm the `SetupIntent`. Additionally, to create a BECS Direct Debit `PaymentMethod`, you are required to collect and include the account holder's name and the customer's email address. ### Data argument properties - `payment_method` (object) **required** Pass an object to confirm using data collected without an `Element`. - `au_becs_debit` (object) **required** An object of self-collected bank account data. - `bsb_number` (string) **required** A Bank State Branch (BSB) number. - `account_number` (string) **required** A bank account number. - `billing_details` (object) **required** The customer's [billing_details](/api/payment_methods/create.md#create_payment_method-billing_details). `name` and `email` are required. - `name` (string) **required** The account holder's name. - `email` (string) **required** The customer's email. ### Confirm with self collected data ```js stripe .confirmAuBecsDebitSetup('{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { au_becs_debit: { bsb_number: '000000', account_number: '000123456' }, billing_details: { name: 'John Smith', email: 'john.smith@example.com', }, }, }) .then(function(result) { // Handle result.error or result.setupIntent }); ``` ```es_next const {setupIntent, error} = await stripe.confirmAuBecsDebitSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { au_becs_debit: { bsb_number: '000000', account_number: '000123456' }, billing_details: { name: 'John Smith', email: 'john.smith@example.com', }, }, }, ); ``` ### Confirm BECS Debit setup ```js stripe .confirmAuBecsDebitSetup('{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { au_becs_debit: auBankAccountElement, billing_details: { name: 'John Smith', email: 'john.smith@example.com', }, }, }) .then(function(result) { // Handle result.error or result.setupIntent }); ``` ```es_next const {error, setupIntent} = await stripe.confirmAuBecsDebitSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { au_becs_debit: auBankAccountElement, billing_details: { name: 'John Smith', email: 'john.smith@example.com', }, }, }, ); ``` ## Confirm Bacs Debit setup Use `stripe.confirmBacsDebitSetup` in the [Bacs Direct Debit Payments](/payments/payment-methods/bacs-debit.md) flow when the customer submits your payment form. When called, it will confirm the [SetupIntent](/api/setup_intents.md) with `data` you provide. Note that there are some additional requirements to this flow that are not covered in this reference. Refer to our [integration guide](/payments/payment-methods/bacs-debit.md) for more details. When you confirm a `SetupIntent`, it needs to have an attached [PaymentMethod](/api/payment_methods.md). In addition to confirming the `SetupIntent`, this method can automatically create and attach a new `PaymentMethod` for you. It can also be called with an existing `PaymentMethod`, or if you have already attached a `PaymentMethod` you can call this method without needing to provide any additional data. These use cases are detailed in the sections that follow. > Note that `stripe.confirmBacsDebitSetup` may take several seconds to complete. > During that time, you should disable your form from being resubmitted and show a waiting indicator like a spinner. > If you receive an error result, you should be sure to show that error to the customer, re-enable the form, and hide the waiting indicator. `stripe.confirmBacsDebitSetup` will return a `Promise` which resolves with a `result` object. This object has either: * `result.setupIntent`: the successful [SetupIntent](/api/setup_intents). * `result.error`: an error. Refer to the [API reference](/api/errors) for all possible errors. **Syntax:** `stripe.confirmBacsDebitSetup(...)` - `clientSecret` (string) **required** The [client secret](/api/setup_intents/object.md#setup_intent_object-client_secret) of the `SetupIntent`. - `data` (object) Data to be sent with the request. Refer to the [Setup Intents API](/api/setup_intents/confirm.md) for a full list of parameters. - `payment_method` (object | string) The `id` of an existing PaymentMethod or an object of collected data. See use cases below for details. ### Use case: with self collected data You can also pass in the customer’s bank account information directly to create a new `PaymentMethod` and confirm the `SetupIntent`. Additionally, to create a Bacs Direct Debit `PaymentMethod`, you are required to collect and include the account holder's name and the customer's email address. ### Data argument properties - `payment_method` (object) **required** Pass an object to confirm using payment method data. - `bacs_debit` (object) **required** An object of self-collected bank account data. - `account_number` (string) **required** A bank account number. - `sort_code` (string) **required** A sort code. - `billing_details` (object) **required** The customer's [billing_details](/api/payment_methods/create.md#create_payment_method-billing_details). `name` and `email` are required. - `address` (string) **required** The account holder's address. - `line1` (string) **required** Line 1 of the account holder's address. - `city` (string) **required** The account holder's city. - `country` (string) **required** The account holder's country. - `postal_code` (string) **required** The account holder's postal code. - `name` (string) **required** The account holder's name. - `email` (string) **required** The customer's email. ### Confirm with self collected data ```js stripe .confirmBacsDebitSetup('{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { bacs_debit: { sort_code: '108800', account_number: '000123456' }, billing_details: { address: { line1: addressLine1, city: addressCity, country: addressCountry, postal_code: addressPostalCode, }, email: customerEmail, name: customerName, }, }, }) .then(function(result) { // Handle result.error or result.setupIntent }); ``` ```es_next const {setupIntent, error} = await stripe.confirmBacsDebitSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { bacs_debit: { sort_code: '108800', account_number: '000123456' }, billing_details: { address: { line1: addressLine1, city: addressCity, country: addressCountry, postal_code: addressPostalCode, }, email: customerEmail, name: customerName, }, }, }, ); ``` ### Use case: with an existing payment method If you have already created a `PaymentMethod`, you can pass its `id` to `payment_method` when calling `stripe.confirmBacsDebitSetup` and it will be used to confirm the `SetupIntent`. ### Data argument properties - `payment_method` (string) **required** The `id` of an existing `PaymentMethod`. ### Confirm with existing payment method ```js stripe .confirmBacsDebitSetup('{SETUP_INTENT_CLIENT_SECRET}', { payment_method: '{PAYMENT_METHOD_ID}', }) .then(function(result) { // Handle result.error or result.setupIntent }); ``` ```es_next const {error, setupIntent} = await stripe.confirmBacsDebitSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: '{PAYMENT_METHOD_ID}', }, ); ``` ### Confirm Bacs Debit setup ```js stripe .confirmBacsDebitSetup('{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { bacs_debit: { sort_code: '108800', account_number: '000123456' }, billing_details: { address: { line1: addressLine1, city: addressCity, country: addressCountry, postal_code: addressPostalCode, }, email: customerEmail, name: customerName, }, }, }) .then(function(result) { // Handle result.error or result.setupIntent }); ``` ```es_next const {setupIntent, error} = await stripe.confirmBacsDebitSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { bacs_debit: { sort_code: '108800', account_number: '000123456' }, billing_details: { address: { line1: addressLine1, city: addressCity, country: addressCountry, postal_code: addressPostalCode, }, email: customerEmail, name: customerName, }, }, }, ); ``` ## Confirm Bancontact setup Use `stripe.confirmBancontactSetup` in the [Set up future payments](/payments/bancontact/set-up-payment.md) flow to use Bancontact bank details to set up a SEPA Direct Debit payment method for future payments. When called, it will confirm a `SetupIntent` with `data` you provide, and it will automatically redirect the customer to authorize the transaction. Once authorization is complete, the customer will be redirected back to your specified `return_url`. Note that there are some additional requirements to this flow that are not covered in this reference. Refer to our [integration guide](/payments/bancontact/set-up-payment.md) for more details. When you confirm a `SetupIntent`, it needs to have an attached [PaymentMethod](/api/payment_methods.md). In addition to confirming the `SetupIntent`, this method can automatically create and attach a new `PaymentMethod` for you. It can also be called with an existing `PaymentMethod`, or if you have already attached a `PaymentMethod` you can call this method without needing to provide any additional data. These use cases are detailed in the sections that follow. > Note that `stripe.confirmBancontactSetup` may take several seconds to complete. > During that time, you should disable your form from being resubmitted and show a waiting indicator like a spinner. > If you receive an error result, you should be sure to show that error to the customer, re-enable the form, and hide the waiting indicator. `stripe.confirmBancontactSetup` will return a `Promise` which resolves with a `result` object. This object has either: * `result.setupIntent`: the successful [SetupIntent](/api/setup_intents). * `result.error`: an error. Refer to the [API reference](/api/errors) for all possible errors. **Syntax:** `stripe.confirmBancontactSetup(...)` - `clientSecret` (string) **required** The [client secret](/api/setup_intents/object.md#setup_intent_object-client_secret) of the `SetupIntent`. - `data` (object) Data to be sent with the request. Refer to the [Setup Intents API](/api/setup_intents/confirm.md) for a full list of parameters. - `payment_method` (object | string) The `id` of an existing PaymentMethod or an object of collected data. See use cases below for details. - `return_url` (string) The url your customer will be directed to after they complete authentication. - `options` (object) An options object to control the behavior of this method. - `handleActions` (boolean) Set this to `false` if you want to [manually handle the authorization redirect](/payments/bancontact/accept-a-payment?platform=web.md#handle-redirect). Default is `true`. ### Use case: with an existing payment method If you have already created a `PaymentMethod`, you can pass its `id` to `payment_method` when calling `stripe.confirmBancontactSetup` and it will be used to confirm the `SetupIntent`. ### Data argument properties - `payment_method` (string) **required** The `id` of an existing `PaymentMethod`. - `return_url` (string) The url your customer will be directed to after they complete authentication. ### Confirm with existing payment method ```js stripe .confirmBancontactSetup('{SETUP_INTENT_CLIENT_SECRET}', { payment_method: '{PAYMENT_METHOD_ID}', }) .then(function(result) { // Handle result.error or result.setupIntent }); ``` ```es_next const {error, setupIntent} = await stripe.confirmBancontactSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: '{PAYMENT_METHOD_ID}', }, ); ``` ### Use case: with self collected data Your customer's name and email are required for the Bancontact authorization to succeed. You can pass in these properties directly to create a new `PaymentMethod` and confirm the `SetupIntent`. ### Data argument properties - `payment_method` (object) **required** Pass an object to confirm with the customer's name and email. - `billing_details` (object) **required** The customer's [billing_details](/api/payment_methods/create.md#create_payment_method-billing_details). `name` and `email` are required. - `name` (string) **required** The customer's name. - `email` (string) **required** The customer's email. - `return_url` (string) The url your customer will be directed to after they complete authentication. ### Confirm with self collected data ```js stripe .confirmBancontactSetup('{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { billing_details: { name: 'Jenny Rosen', email: 'jenny@example.com', }, }, // Return URL where the customer should be redirected after the authorization. return_url: window.location.href, }) .then(function(result) { if (result.error) { // Inform the customer that there was an error. } }); ``` ```es_next const {error} = await stripe.confirmBancontactSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { billing_details: { name: 'Jenny Rosen', email: 'jenny@example.com', }, }, // Return URL where the customer should be redirected after the authorization. return_url: window.location.href, }, ); ``` ### Confirm Bancontact setup ```js stripe .confirmBancontactSetup('{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { billing_details: { name: 'Jenny Rosen', email: 'jenny@example.com', }, }, // Return URL where the customer should be redirected after the authorization. return_url: window.location.href, }) .then(function(result) { if (result.error) { // Inform the customer that there was an error. } }); ``` ```es_next const {error} = await stripe.confirmBancontactSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { billing_details: { name: 'Jenny Rosen', email: 'jenny@example.com', }, }, // Return URL where the customer should be redirected after the authorization. return_url: window.location.href, }, ); ``` ## Confirm an Cash App Pay setup Use `stripe.confirmCashappSetup` in the [Save payment details](/payments/cash-app-pay/set-up-payment.md) flow for the [Cash App Pay](/payments/cash-app-pay.md) payment method to record the customer’s authorization for future payments. When you confirm a [SetupIntent](/api/setup_intents.md), it needs to have an attached [PaymentMethod](/api/payment_methods.md). In addition to confirming the `SetupIntent`, this method can automatically create and attach a new `PaymentMethod` for you. If you have already attached a `PaymentMethod` you can call this method without needing to provide any additional data. These use cases are detailed in the sections that follow. > Note that `stripe.confirmCashappSetup` may take several seconds to complete. > During that time, you should disable your form from being resubmitted and show a waiting indicator like a spinner. > If you receive an error result, you should be sure to show that error to the customer, re-enable the form, and hide the waiting indicator. By default, `stripe.confirmCashappSetup` will display Cash App Pay QR code in desktop web app, or trigger a redirect in mobile web app. If there is an error, or when handling next actions manually by using the `handleActions: false` option, it will return a `Promise` which resolves with a `result` This object has either: * `result.setupIntent`: the successful [SetupIntent](/api/setup_intents). * `result.error`: an error. Refer to the [API reference](/api#errors) and our [integration guide](/payments/cash-app-pay/set-up-payment) for all possible errors. **Syntax:** `stripe.confirmCashappSetup(...)` - `clientSecret` (string) **required** The [client secret](/api/setup_intents/object.md#setup_intent_object-client_secret) of the `SetupIntent`. - `data` (object) Data to be sent with the request. Refer to the [Setup Intents API](/api/setup_intents/confirm.md) for a full list of parameters. - `payment_method` (object | string) The `id` of an existing PaymentMethod or an object of collected data. See use cases below for details. - `return_url` (string) **required** The url your customer will be directed to after they complete authentication. - `options` (object) An options object to control the behavior of this method. - `handleActions` (boolean) Set this to `false` if you would like to [handle displaying the Cash App Pay QR code or handle the authorization redirect](docs/payments/cash-app-pay/set-up-payment?platform=web&ui=API#web-create-setup-intent) yourself. ### Use case: Without an existing payment method If you have not already created a `PaymentMethod`, you can pass payment method parameters, and the newly created `PaymentMethod` will be used to confirm the `SetupIntent`. ### Data argument properties - `return_url` (string) **required** The url your customer will be directed to after they complete authentication. ### Confirm with bank account information ```js stripe.confirmCashappSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { type: 'cashapp', }, // Return URL where the customer should be redirected after the authorization. return_url: window.location.href } ).then(function(error, setupIntent) { if (error) { // Inform the customer that there was an error. console.log(result.error.message); } else if (setupIntent.status === 'succeeded') { // Inform the customer that the payment was successful } else if (setupIntent.status === 'requires_action'){ // Inform the customer that the payment did not go through } }); ``` ```es_next const {error, setupIntent} = await stripe.confirmCashappSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { type: 'cashapp', }, // Return URL where the customer should be redirected after the authorization. return_url: window.location.href } ); if (error) { // Inform the customer that there was an error. } else if (setupIntent.status === 'succeeded') { // Inform the customer that the payment was successful } else if (setupIntent.status === 'requires_action') { // Inform the customer that the payment did not go through } ``` ### Use case: with an existing PaymentMethod If you have already created a `PaymentMethod`, you can pass its `id` to `payment_method` when calling `stripe.confirmCashappSetup`. ### Data argument properties - `payment_method` (string) **required** The `id` of an existing [PaymentMethod](/api/payment_methods.md). - `return_url` (string) **required** The url your customer will be directed to after they complete authentication. ### Confirm with an existing PaymentMethod ```js stripe.confirmCashappSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: '{PAYMENT_METHOD_ID}', // Return URL where the customer should be redirected after the authorization. return_url: window.location.href } ).then(function({error, setupIntent}) { if (error) { // Inform the customer that there was an error. console.log(result.error.message); } else if (setupIntent.status === 'succeeded') { // Inform the customer that the payment was successful } else if (setupIntent.status === 'requires_action'){ // Inform the customer that the payment did not go through } }); ``` ```es_next const {setupIntent, error} = await stripe.confirmCashappSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: '{PAYMENT_METHOD_ID}', // Return URL where the customer should be redirected after the authorization. return_url: window.location.href } ); if (error) { // Inform the customer that there was an error. console.log(result.error.message); } else if (setupIntent.status === 'succeeded') { // Inform the customer that the payment was successful } else if (setupIntent.status === 'requires_action'){ // Inform the customer that the payment did not go through } ``` ### Use case: with an attached PaymentMethod If you have already attached a `return_url` and a `PaymentMethod` to this `SetupIntent`, then you can confirm without passing in any additional data. ### Confirm with an attached PaymentMethod ```js stripe.confirmCashappSetup( '{SETUP_INTENT_CLIENT_SECRET}' ).then(function({setupIntent, error}) { if (error) { // Inform the customer that there was an error. } else if (setupIntent.status === 'succeeded') { // Inform the customer that the payment was successful } else if (setupIntent.status === 'requires_action') { // Inform the customer that the payment did not go through } }); ``` ```es_next const {setupIntent, error} = await stripe.confirmCashappSetup( '{SETUP_INTENT_CLIENT_SECRET}' ); if (error) { // Inform the customer that there was an error. } else if (setupIntent.status === 'succeeded') { // Inform the customer that the payment was successful } else if (setupIntent.status === 'requires_action') { // Inform the customer that the payment did not go through } ``` ### Confirm a Cash App Pay setup ```js stripe.confirmCashappSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { type: 'cashapp', }, // Return URL where the customer should be redirected after the authorization. return_url: window.location.href } ).then(function(error, setupIntent) { if (error) { // Inform the customer that there was an error. console.log(result.error.message); } else if (setupIntent.status === 'succeeded') { // Inform the customer that the payment was successful } else if (setupIntent.status === 'requires_action'){ // Inform the customer that the payment did not go through } }); ``` ```es_next const {error, setupIntent} = await stripe.confirmCashappSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { type: 'cashapp', }, // Return URL where the customer should be redirected after the authorization. return_url: window.location.href } ); if (error) { // Inform the customer that there was an error. } else if (setupIntent.status === 'succeeded') { // Inform the customer that the payment was successful } else if (setupIntent.status === 'requires_action') { // Inform the customer that the payment did not go through } ``` ## Confirm Indonesia bank transfer setup Use `stripe.confirmIdBankTransferSetup` in the [Reusable virtual bank accounts](/payments/id-bank-transfer/accept-a-payment/reusable-virtual-bank-accounts.md) flow to set up an Indonesia bank transfer payment method for future payments. When called, it will confirm a `SetupIntent` with `data` you provide. Note that there are some additional recommendations to this flow on why you should collect the customer's name, email, and bank preference. Refer to our [integration guide](/payments/id-bank-transfer/accept-a-payment/reusable-virtual-bank-accounts.md) for more details. When you confirm a `SetupIntent`, it needs to have an attached [PaymentMethod](/api/payment_methods.md). In addition to confirming the `SetupIntent`, this method can automatically create and attach a new `PaymentMethod` for you. It can also be called with an existing `PaymentMethod`, or if you have already attached a `PaymentMethod` you can call this method without needing to provide any additional data. These use cases are detailed in the sections that follow. > Note that `stripe.confirmIdBankTransferSetup` may take several seconds to complete. > During that time, you should disable your form from being resubmitted and show a waiting indicator like a spinner. > If you receive an error result, you should be sure to show that error to the customer, re-enable the form, and hide the waiting indicator. `stripe.confirmIdBankTransferSetup` will return a `Promise` which resolves with a `result` object. This object has either: * `result.setupIntent`: the successful [SetupIntent](/api/setup_intents). * `result.error`: an error. Refer to the [API reference](/api/errors) for all possible errors. **Syntax:** `stripe.confirmIdBankTransferSetup(...)` - `clientSecret` (string) **required** The [client secret](/api/setup_intents/object.md#setup_intent_object-client_secret) of the `SetupIntent`. - `data` (object) Data to be sent with the request. Refer to the [Setup Intents API](/api/setup_intents/confirm.md) for a full list of parameters. - `payment_method` (object | string) The `id` of an existing PaymentMethod or an object of collected data. See use cases below for details. ### Use case: with a new PaymentMethod You can confirm the `SetupIntent` using `stripe.confirmIdBankTransferSetup` without passing in any additional data. This will automatically create and attach a new `PaymentMethod`. ### Data argument properties - `payment_method` (object) **required** Pass an object to confirm using collected data. - `id_bank_transfer` (object) **required** An object detailing the customer's bank. - `bank` (string) **required** The customer's [bank](/api/payment_methods/create.md#create_payment_method-id_bank_transfer-bank). - `billing_details` (object) **required** The customer's [billing_details](/api/payment_methods/create.md#create_payment_method-billing_details). `name` is required and `email` is recommended. - `name` (string) **required** The customer's name. - `email` (string) The customer's email. ### Confirm with a new PaymentMethod ```js stripe .confirmIdBankTransferSetup('{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { id_bank_transfer: { bank: 'bni', }, billing_details: { name: 'Fitri Sari', email: 'fitrisari@example.com', }, }, }) .then(function(result) { if (result.error) { // Inform the customer that there was an error. } }); ``` ```es_next const {setupIntent, error} = await stripe.confirmIdBankTransferSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { id_bank_transfer: { bank: 'bni', }, billing_details: { name: 'Fitri Sari', email: 'fitrisari@example.com', }, }, }, ); ``` ### Use case: with an existing payment method If you have already created a `PaymentMethod`, you can pass its `id` to `payment_method` when calling `stripe.confirmIdBankTransferSetup` and it will be used to confirm the `SetupIntent`. ### Data argument properties - `payment_method` (string) **required** The `id` of an existing `PaymentMethod`. ### Confirm with existing payment method ```js stripe .confirmIdBankTransferSetup('{SETUP_INTENT_CLIENT_SECRET}', { payment_method: '{PAYMENT_METHOD_ID}', }) .then(function(result) { if (result.error) { // Inform the customer that there was an error. } }); ``` ```es_next const {setupIntent, error} = await stripe.confirmIdBankTransferSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: '{PAYMENT_METHOD_ID}', }, ); ``` ### Use case: with an attached PaymentMethod If you have already attached a `PaymentMethod` to this `SetupIntent`, then you can confirm the `SetupIntent` using `stripe.confirmIdBankTransferSetup` without passing in any additional data. ### Confirm with an attached PaymentMethod ```js stripe .confirmIdBankTransferSetup('{SETUP_INTENT_CLIENT_SECRET}', {}) .then(function(result) { if (result.error) { // Inform the customer that there was an error. } }); ``` ```es_next const {setupIntent, error} = await stripe.confirmIdBankTransferSetup(); ``` ### Confirm Indonesia bank transfer setup ```js stripe .confirmIdBankTransferSetup('{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { id_bank_transfer: { bank: 'bni', }, billing_details: { name: 'Fitri Sari', email: 'fitrisari@example.com', }, }, }) .then(function(result) { if (result.error) { // Inform the customer that there was an error. } }); ``` ```es_next const {setupIntent, error} = await stripe.confirmIdBankTransferSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { id_bank_transfer: { bank: 'bni', }, billing_details: { name: 'Fitri Sari', email: 'fitrisari@example.com', }, }, }, ); ``` ## Confirm iDEAL setup Use `stripe.confirmIdealSetup` in the [Set up future payments](/payments/ideal/set-up-payment.md) flow to use iDEAL bank details to set up a SEPA Direct Debit payment method for future payments. When called, it will confirm a `SetupIntent` with `data` you provide, and it will automatically redirect the customer to authorize the transaction. Once authorization is complete, the customer will be redirected back to your specified `return_url`. Note that there are some additional requirements to this flow that are not covered in this reference. Refer to our [integration guide](/payments/ideal/set-up-payment.md) for more details. When you confirm a `SetupIntent`, it needs to have an attached [PaymentMethod](/api/payment_methods.md). In addition to confirming the `SetupIntent`, this method can automatically create and attach a new `PaymentMethod` for you. It can also be called with an existing `PaymentMethod`, or if you have already attached a `PaymentMethod` you can call this method without needing to provide any additional data. These use cases are detailed in the sections that follow. > Note that `stripe.confirmIdealSetup` may take several seconds to complete. > During that time, you should disable your form from being resubmitted and show a waiting indicator like a spinner. > If you receive an error result, you should be sure to show that error to the customer, re-enable the form, and hide the waiting indicator. `stripe.confirmIdealSetup` will return a `Promise` which resolves with a `result` object. This object has either: * `result.setupIntent`: the successful [SetupIntent](/api/setup_intents). * `result.error`: an error. Refer to the [API reference](/api/errors) for all possible errors. **Syntax:** `stripe.confirmIdealSetup(...)` - `clientSecret` (string) **required** The [client secret](/api/setup_intents/object.md#setup_intent_object-client_secret) of the `SetupIntent`. - `data` (object) Data to be sent with the request. Refer to the [Setup Intents API](/api/setup_intents/confirm.md) for a full list of parameters. - `payment_method` (object | string) The `id` of an existing PaymentMethod or an object of collected data. See use cases below for details. - `return_url` (string) The url your customer will be directed to after they complete authentication. - `options` (object) An options object to control the behavior of this method. - `handleActions` (boolean) Set this to `false` if you want to [manually handle the authorization redirect](/payments/ideal/accept-a-payment?platform=web.md#web-handle-redirect). Default is `true`. ### Use case: with payment data from an Element Create and attach a new SEPA Direct Debit `PaymentMethod` with `stripe.confirmIdealSetup` by passing an `idealBank` [Element](/js/element.md) to `payment_method[ideal]`. The new `PaymentMethod` will be created with the data collected by the `Element` and will be used to confirm the `SetupIntent`. Additionally, to create a SEPA Direct Debit `PaymentMethod`, you are required to collect and include the customer’s name and email address. ### Data argument properties - `payment_method` (object) **required** Pass an object to confirm using data collected by an `idealBank` Element. - `ideal` (Element) **required** An `idealBank` [Element](/js/element.md). - `billing_details` (object) **required** The customer's [billing_details](/api/payment_methods/create.md#create_payment_method-billing_details). `name` and `email` are required. - `name` (string) **required** The customer's name. - `email` (string) **required** The customer's email. - `return_url` (string) The url your customer will be directed to after they complete authentication. ### Confirm with an Element ```js stripe .confirmIdealSetup('{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { ideal: idealBankElement, billing_details: { name: 'Jenny Rosen', email: 'jenny@example.com', }, }, }) .then(function(result) { // Handle result.error or result.setupIntent }); ``` ```es_next const {error, setupIntent} = await stripe.confirmIdealSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { ideal: idealBankElement, billing_details: { name: 'Jenny Rosen', email: 'jenny@example.com', }, }, }, ); ``` ### Use case: with an existing payment method If you have already created a `PaymentMethod`, you can pass its `id` to `payment_method` when calling `stripe.confirmIdealSetup` and it will be used to confirm the `SetupIntent`. ### Data argument properties - `payment_method` (string) **required** The `id` of an existing `PaymentMethod`. - `return_url` (string) The url your customer will be directed to after they complete authentication. ### Confirm with existing payment method ```js stripe .confirmIdealSetup('{SETUP_INTENT_CLIENT_SECRET}', { payment_method: '{PAYMENT_METHOD_ID}', }) .then(function(result) { // Handle result.error or result.setupIntent }); ``` ```es_next const {error, setupIntent} = await stripe.confirmIdealSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: '{PAYMENT_METHOD_ID}', }, ); ``` ### Use case: with self collected data If you already know the customer’s bank or want to collect it yourself, then you do not need to use the `idealBank` [Element](/js/element.md). You can pass in the customer’s [bank code](/payments/ideal/accept-a-payment?platform=web&ui=element.md#bank-reference) directly to create a new `PaymentMethod` and confirm the `SetupIntent`. ### Data argument properties - `payment_method` (object) **required** Pass an object to confirm using data collected by an `idealBank` Element. - `ideal` (object) **required** An object detailing the customer's iDEAL bank. - `bank` (string) **required** The customer's [bank](/payments/ideal/accept-a-payment?platform=web&ui=element.md#bank-reference). - `billing_details` (object) **required** The customer's [billing_details](/api/payment_methods/create.md#create_payment_method-billing_details). `name` and `email` are required. - `name` (string) **required** The customer's name. - `email` (string) **required** The customer's email. - `return_url` (string) The url your customer will be directed to after they complete authentication. ### Confirm with self collected data ```js stripe .confirmIdealSetup('{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { ideal: { bank: 'abn_amro', }, billing_details: { name: 'Jenny Rosen', email: 'jenny@example.com', }, }, // Return URL where the customer should be redirected after the authorization. return_url: window.location.href, }) .then(function(result) { if (result.error) { // Inform the customer that there was an error. } }); ``` ```es_next const {error} = await stripe.confirmIdealSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { ideal: { bank: 'abn_amro', }, billing_details: { name: 'Jenny Rosen', email: 'jenny@example.com', }, }, // Return URL where the customer should be redirected after the authorization. return_url: window.location.href, }, ); ``` ### Confirm iDEAL setup ```js stripe .confirmIdealSetup('{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { ideal: idealBankElement, billing_details: { name: 'Jenny Rosen', email: 'jenny@example.com', }, }, }) .then(function(result) { // Handle result.error or result.setupIntent }); ``` ```es_next const {error, setupIntent} = await stripe.confirmIdealSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { ideal: idealBankElement, billing_details: { name: 'Jenny Rosen', email: 'jenny@example.com', }, }, }, ); ``` ## Confirm a Klarna setup Use `stripe.confirmKlarnaSetup` in the [Klarna Payments with Setup Intents](/payments/klarna/set-up-payment.md) flow when the customer submits your setup form. When called, it will confirm the `SetupIntent` with `data` you provide, and it will automatically redirect the customer to authorize the setup. Once authorization is complete, the customer will be redirected back to your specified `return_url`. > Note that `stripe.confirmKlarnaSetup` may take several seconds to complete. > During that time, you should disable your form from being resubmitted and show a waiting indicator like a spinner. > If you receive an error result, you should be sure to show that error to the customer, re-enable the form, and hide the waiting indicator. `stripe.confirmKlarnaSetup` will trigger a redirect when successful. If there is an error, it will return a `Promise` which resolves with a `result` object. This object has either: * `result.setupIntent`: the successful [SetupIntent](/api/setup_intents). * `result.error`: an error. Refer to the [API reference](/api/errors) for all possible errors. **Syntax:** `stripe.confirmKlarnaSetup(...)` - `clientSecret` (string) **required** The [client secret](/api/setup_intents/object.md#setup_intent_object-client_secret) of the `SetupIntent`. - `data` (object) Data to be sent with the request. Refer to the [Setup Intents API](/api/setup_intents/confirm.md) for a full list of parameters. - `payment_method` (string | object) The `id` of an existing [PaymentMethod](/api/payment_methods.md). See the use case sections below for details. - `return_url` (string) **required** The url your customer will be directed to after they complete authentication. ### Use case: with an existing payment method Use `stripe.confirmKlarnaSetup` with an existing `PaymentMethod` by passing its `id` to `payment_method`. The `PaymentMethod` will be used to confirm the `SetupIntent`. ### Data argument properties - `payment_method` (string) **required** The `id` of an existing `PaymentMethod`. - `return_url` (string) **required** The url your customer will be directed to after they complete authentication. ### Confirm with existing payment method ```js stripe .confirmKlarnaSetup('{PAYMENT_INTENT_CLIENT_SECRET}', { payment_method: '{PAYMENT_METHOD_ID}', // Return URL where the customer should be redirected after the authorization. return_url: "https://example.com/setup/complete", }) .then(function(result) { if (result.error) { // Inform the customer that there was an error. } }); ``` ```es_next const {error} = await stripe.confirmKlarnaSetup( '{PAYMENT_INTENT_CLIENT_SECRET}', { payment_method: '{PAYMENT_METHOD_ID}', // Return URL where the customer should be redirected after the authorization. return_url: "https://example.com/setup/complete", }, ); ``` ### Use case: with an attached PaymentMethod If you have already attached a `PaymentMethod` to this `SetupIntent`, then you can confirm the `SetupIntent` using `stripe.confirmKlarnaSetup` without passing in any additional data. ### Confirm with an attached PaymentMethod ```js stripe .confirmKlarnaSetup('{SETUP_INTENT_CLIENT_SECRET}', { // Return URL where the customer should be redirected after // the authorization. return_url: "https://example.com/setup/complete", }) .then(function(result) { if (result.error) { // Inform the customer that there was an error. } }); ``` ```es_next const {setupIntent, error} = await stripe.confirmKlarnaSetup( '{SETUP_INTENT_CLIENT_SECRET}', { // Return URL where the customer should be redirected after // the authorization. return_url: "https://example.com/setup/complete", }, ); ``` ### Use case: with self collected data Your customer's email and billing country are required for the Klarna authorization to succeed. You can pass in these properties directly to create a new `PaymentMethod` and confirm the `SetupIntent`. ### Data argument properties - `payment_method` (object) **required** Pass an object to confirm with the customer's email and billing country. - `billing_details` (object) **required** The customer's [billing_details](/api/payment_methods/create.md#create_payment_method-billing_details). `email` and `address.country` are required. - `email` (string) **required** The customer's email. - `address` (object) **required** The customer's billing address. - `country` (string) **required** The customer's billing country. - `return_url` (string) **required** The url your customer will be directed to after they complete authentication. ### Confirm with self collected data ```js stripe .confirmKlarnaSetup('{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { billing_details: { email: 'jenny@example.com', address: { country: 'DE', }, }, }, // Return URL where the customer should be redirected after // the authorization. return_url: "https://example.com/setup/complete", }) .then(function(result) { if (result.error) { // Inform the customer that there was an error. } }); ``` ```es_next const {error} = await stripe.confirmKlarnaSetup( '{SETUP_INTENT_CLIENT_SECRET}', { // Return URL where the customer should be redirected after // the authorization. return_url: "https://example.com/setup/complete", }, ); ``` ### Confirm a Klarna setup ```js stripe .confirmKlarnaSetup('{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { billing_details: { email: 'jenny@example.com', address: { country: 'DE', }, }, }, // Return URL where the customer should be redirected after // the authorization. return_url: "https://example.com/setup/complete", }) .then(function(result) { if (result.error) { // Inform the customer that there was an error. } }); ``` ```es_next const {error} = await stripe.confirmKlarnaSetup( '{SETUP_INTENT_CLIENT_SECRET}', { // Return URL where the customer should be redirected after // the authorization. return_url: "https://example.com/setup/complete", }, ); ``` ## Confirm a PayPal setup Use `stripe.confirmPayPalSetup` in the [PayPal Payments with Setup Intents](/payments/paypal/set-up-payment.md) flow when the customer submits your setup form. When called, it will confirm the `SetupIntent`, and it will automatically redirect the customer to authorize the setup. Once authorization is complete, the customer will be redirected back to your specified `return_url`. > Note that `stripe.confirmPayPalSetup` may take several seconds to complete. > During that time, you should disable your form from being resubmitted and show a waiting indicator like a spinner. > If you receive an error result, you should be sure to show that error to the customer, re-enable the form, and hide the waiting indicator. `stripe.confirmPayPalSetup` will trigger a redirect when successful. If there is an error, it will return a `Promise` which resolves with a `result` object. This object has either: * `result.setupIntent`: the successful [SetupIntent](/api/setup_intents). * `result.error`: an error. Refer to the [API reference](/api/errors) for all possible errors. **Syntax:** `stripe.confirmPayPalSetup(...)` - `clientSecret` (string) **required** The [client secret](/api/setup_intents/object.md#setup_intent_object-client_secret) of the `SetupIntent`. - `data` (object) Data to be sent with the request. Refer to the [Setup Intents API](/api/setup_intents/confirm.md) for a full list of parameters. - `payment_method` (string | object) The `id` of an existing [PaymentMethod](/api/payment_methods.md). See the use case sections below for details. - `return_url` (string) **required** The url your customer will be directed to after they complete authentication. ### Use case: with a new PaymentMethod You can confirm the `SetupIntent` using `stripe.confirmPayPalSetup` without passing in any additional data. This will automatically create and attach a new `PaymentMethod`. ### Data argument properties - `return_url` (string) **required** The url your customer will be directed to after they complete authentication. ### Confirm with a new PaymentMethod ```js stripe .confirmPayPalSetup('{SETUP_INTENT_CLIENT_SECRET}', { // Return URL where the customer should be redirected after // the authorization. return_url: "https://example.com/setup/complete", }) .then(function(result) { if (result.error) { // Inform the customer that there was an error. } }); ``` ```es_next const {error} = await stripe.confirmPayPalSetup( '{SETUP_INTENT_CLIENT_SECRET}', { // Return URL where the customer should be redirected after // the authorization. return_url: "https://example.com/setup/complete", }, ); ``` ### Use case: with an existing payment method Use `stripe.confirmPayPalSetup` with an existing `PaymentMethod` by passing its `id` to `payment_method`. The `PaymentMethod` will be used to confirm the `SetupIntent`. ### Data argument properties - `payment_method` (string) **required** The `id` of an existing `PaymentMethod`. - `return_url` (string) **required** The url your customer will be directed to after they complete authentication. ### Confirm with existing payment method ```js stripe .confirmPayPalPayment('{PAYMENT_INTENT_CLIENT_SECRET}', { payment_method: '{PAYMENT_METHOD_ID}', // Return URL where the customer should be redirected after the authorization. return_url: "https://example.com/setup/complete", }) .then(function(result) { if (result.error) { // Inform the customer that there was an error. } }); ``` ```es_next const {error} = await stripe.confirmPayPalPayment( '{PAYMENT_INTENT_CLIENT_SECRET}', { payment_method: '{PAYMENT_METHOD_ID}', // Return URL where the customer should be redirected after the authorization. return_url: "https://example.com/setup/complete", }, ); ``` ### Use case: with an attached PaymentMethod If you have already attached a `PaymentMethod` to this `SetupIntent`, then you can confirm the `SetupIntent` using `stripe.confirmPayPalSetup` without passing in any additional data. ### Confirm with an attached PaymentMethod ```js stripe .confirmPayPalSetup('{SETUP_INTENT_CLIENT_SECRET}', { // Return URL where the customer should be redirected after // the authorization. return_url: "https://example.com/setup/complete", }) .then(function(result) { if (result.error) { // Inform the customer that there was an error. } }); ``` ```es_next const {setupIntent, error} = await stripe.confirmPayPalSetup( '{SETUP_INTENT_CLIENT_SECRET}', { // Return URL where the customer should be redirected after // the authorization. return_url: "https://example.com/setup/complete", }, ); ``` ### Confirm a PayPal setup ```js stripe .confirmPayPalSetup('{SETUP_INTENT_CLIENT_SECRET}', { // Return URL where the customer should be redirected after // the authorization. return_url: "https://example.com/setup/complete", }) .then(function(result) { if (result.error) { // Inform the customer that there was an error. } }); ``` ```es_next const {error} = await stripe.confirmPayPalSetup( '{SETUP_INTENT_CLIENT_SECRET}', { // Return URL where the customer should be redirected after // the authorization. return_url: "https://example.com/setup/complete", }, ); ``` ## Confirm a PayTo setup Use `stripe.confirmPayToSetup` in the [PayTo Payments with Setup Intents](/payments/payto/set-up-payment.md) flow when the customer submits your setup form. When called, it will confirm the `SetupIntent`, and send a request for authorization to the customer. When you confirm a `SetupIntent`, it needs to have an attached [PaymentMethod](/api/payment_methods.md). In addition to confirming the `SetupIntent`, this method can automatically create and attach a new `PaymentMethod` for you. If you've already attached a `PaymentMethod`, you can call this method without needing to provide any additional data. These use cases are detailed in the sections that follow. > Note that `stripe.confirmPayToSetup` might take some time to complete while waiting for customers to authorize the PayTo agreement. > During that time, you should disable your form from being resubmitted and show a waiting indicator like a spinner. > If you receive an error result, you should be sure to show that error to the customer, re-enable the form, and hide the waiting indicator. By default, `stripe.confirmPayToSetup` will poll for updates to the `SetupIntent`. If there's an error, or when handling `next_action`s manually by using the `handleActions: false` option, it returns a `Promise` which resolves with a `result` object. This object has either: * `result.setupIntent`: the successful [SetupIntent](/api/setup_intents). * `result.error`: an error. Refer to the [API reference](/api/errors) for all possible errors. **Syntax:** `stripe.confirmPayToSetup(...)` - `clientSecret` (string) **required** The [client secret](/api/setup_intents/object.md#setup_intent_object-client_secret) of the `SetupIntent`. - `data` (object) Data to be sent with the request. Refer to the [Setup Intents API](/api/setup_intents/confirm.md) for a full list of parameters. - `payment_method` (string | object) Either the `id` of an existing [PaymentMethod](/api/payment_methods.md), or an object containing data to create a `PaymentMethod` with. See the use case sections below for details. - `options` (object) An options object to control the behavior of this method. - `handleActions` (boolean) Set this to `false` if you want to manually handle polling for SetupIntent updates. Default is `true`. ### Use case: with a new PaymentMethod You can confirm the `SetupIntent` using `stripe.confirmPayToSetup` without passing in any additional data. This will automatically create and attach a new `PaymentMethod`. ### Data argument properties - `payment_method` (object) **required** Pass payment method billing details. - `billing_details` (object) **required** The [billing_details](/api/payment_methods/create.md#create_payment_method-billing_details) associated with the payment. The email is required if the customer is paying with PayID. - `email` (string) - `name` (string) **required** - `payto` (object) **required** The [PayTo payment method details](/api/payment_methods/create.md#create_payment_method-payto) associated with the customer's bank account. Either `pay_id` or `account_number` and `bsb_number` must be provided. - `pay_id` (string) - `account_number` (string) - `bsb_number` (string) ### Confirm with a new PaymentMethod ```js stripe .confirmPayToSetup('{SETUP_INTENT_CLIENT_SECRET}', { { payment_method: { billing_details: { name: 'Jenny Rosen', // Email is only required if `pay_id` is used email: 'jenny@example.com' }, payto: { pay_id: 'jenny@example.com' // Alternatively, provide bank account details account_number: '000123456', bsb_number: '000000' } } } }) .then(function(result) { if (result.error) { // Inform the customer that there was an error. } }); ``` ```es_next const {setupIntent, error} = await stripe.confirmPayToSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { billing_details: { name: 'Jenny Rosen', // Email is only required if `pay_id` is used email: 'jenny@example.com' }, payto: { pay_id: 'jenny@example.com' // Alternatively, provide bank account details account_number: '000123456', bsb_number: '000000' } } } ); ``` ### Use case: with an existing payment method Use `stripe.confirmPayToSetup` with an existing `PaymentMethod` by passing its `id` to `payment_method`. The `PaymentMethod` will be used to confirm the `SetupIntent`. ### Data argument properties - `payment_method` (string) **required** The `id` of an existing `PaymentMethod`. ### Confirm with existing payment method ```js stripe .confirmPayToPayment('{PAYMENT_INTENT_CLIENT_SECRET}', { payment_method: '{PAYMENT_METHOD_ID}' }) .then(function(result) { if (result.error) { // Inform the customer that there was an error. } }); ``` ```es_next const {setupIntent, error} = await stripe.confirmPayToPayment( '{PAYMENT_INTENT_CLIENT_SECRET}', { payment_method: '{PAYMENT_METHOD_ID}' }, ); ``` ### Use case: with an attached PaymentMethod If you have already attached a `PaymentMethod` to this `SetupIntent`, then you can confirm the `SetupIntent` using `stripe.confirmPayToSetup` without passing in any additional data. ### Confirm with an attached PaymentMethod ```js stripe .confirmPayToSetup('{SETUP_INTENT_CLIENT_SECRET}') .then(function(result) { if (result.error) { // Inform the customer that there was an error. } }); ``` ```es_next const {setupIntent, error} = await stripe.confirmPayToSetup('{SETUP_INTENT_CLIENT_SECRET}'); ``` ### Confirm a PayTo setup ```js stripe .confirmPayToSetup('{SETUP_INTENT_CLIENT_SECRET}', { { payment_method: { billing_details: { name: 'Jenny Rosen', // Email is only required if `pay_id` is used email: 'jenny@example.com' }, payto: { pay_id: 'jenny@example.com' // Alternatively, provide bank account details account_number: '000123456', bsb_number: '000000' } } } }) .then(function(result) { if (result.error) { // Inform the customer that there was an error. } }); ``` ```es_next const {setupIntent, error} = await stripe.confirmPayToSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { billing_details: { name: 'Jenny Rosen', // Email is only required if `pay_id` is used email: 'jenny@example.com' }, payto: { pay_id: 'jenny@example.com' // Alternatively, provide bank account details account_number: '000123456', bsb_number: '000000' } } } ); ``` ## Confirm SEPA Debit setup Use `stripe.confirmSepaDebitSetup` in the [SEPA Direct Debit with Setup Intents](/payments/sepa-debit-setup-intents.md) flow when the customer submits your payment form. When called, it will confirm the `SetupIntent` with `data` you provide. Note that there are some additional requirements to this flow that are not covered in this reference. Refer to our [integration guide](/payments/sepa-debit-setup-intents.md) for more details. When you confirm a `SetupIntent`, it needs to have an attached [PaymentMethod](/api/payment_methods.md). In addition to confirming the `SetupIntent`, this method can automatically create and attach a new `PaymentMethod` for you. It can also be called with an existing `PaymentMethod`, or if you have already attached a `PaymentMethod` you can call this method without needing to provide any additional data. These use cases are detailed in the sections that follow. > Note that `stripe.confirmSepaDebitSetup` may take several seconds to complete. > During that time, you should disable your form from being resubmitted and show a waiting indicator like a spinner. > If you receive an error result, you should be sure to show that error to the customer, re-enable the form, and hide the waiting indicator. `stripe.confirmSepaDebitSetup` will return a `Promise` which resolves with a `result` object. This object has either: * `result.setupIntent`: the successful [SetupIntent](/api/setup_intents). * `result.error`: an error. Refer to the [API reference](/api/errors) for all possible errors. **Syntax:** `stripe.confirmSepaDebitSetup(...)` - `clientSecret` (string) **required** The [client secret](/api/setup_intents/object.md#setup_intent_object-client_secret) of the `SetupIntent`. - `data` (object) Data to be sent with the request. Refer to the [Setup Intents API](/api/setup_intents/confirm.md) for a full list of parameters. - `payment_method` (object | string) The `id` of an existing PaymentMethod or an object of collected data. See use cases below for details. ### Use case: with payment data from an Element Create and attach a new `PaymentMethod` with `stripe.confirmSepaDebitSetup` by passing an `iban` [Element](/js/element.md) to `payment_method[sepa_debit]`. The new `PaymentMethod` will be created with the data collected by the `Element` and will be used to confirm the `SetupIntent`. Additionally, to create a SEPA Direct Debit `PaymentMethod`, you are required to collect and include the customer’s name and email address. ### Data argument properties - `payment_method` (object) **required** Pass an `object` to confirm using data collected by an `iban` Element. - `sepa_debit` (Element) **required** An `iban` [Element](/js/element.md). - `billing_details` (Object) **required** The customer's [billing_details](/api/payment_methods/create.md#create_payment_method-billing_details). `name` and `email` are required. - `name` (string) **required** The customer's name. - `email` (string) **required** The customer's email. ### Confirm with an Element ```js stripe .confirmSepaDebitSetup('{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { sepa_debit: ibanElement, billing_details: { name: 'Jenny Rosen', email: 'jenny@example.com', }, }, }) .then(function(result) { // Handle result.error or result.setupIntent }); ``` ```es_next const {error, setupIntent} = await stripe.confirmSepaDebitSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { sepa_debit: ibanElement, billing_details: { name: 'Jenny Rosen', email: 'jenny@example.com', }, }, }, ); ``` ### Use case: with an existing payment method If you have already created a `PaymentMethod`, you can pass its `id` to `payment_method` when calling `stripe.confirmSepaDebitSetup` and it will be used to confirm the `SetupIntent`. ### Data argument properties - `payment_method` (string) **required** The `id` of an existing `PaymentMethod`. ### Confirm with existing payment method ```js stripe .confirmSepaDebitSetup('{SETUP_INTENT_CLIENT_SECRET}', { payment_method: '{PAYMENT_METHOD_ID}', }) .then(function(result) { // Handle result.error or result.setupIntent }); ``` ```es_next const {error, setupIntent} = await stripe.confirmSepaDebitSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: '{PAYMENT_METHOD_ID}', }, ); ``` ### Use case: with self collected data If you already know the customer’s IBAN account number or want to collect it yourself, then you do not need to use the `iban` [Element](/js/element.md). You can pass in the customer’s account number directly to create a new `PaymentMethod` and confirm the `SetupIntent`. Additionally, to create a SEPA Direct Debit `PaymentMethod`, you are required to collect and include the customer’s name and email address. ### Data argument properties - `payment_method` (object) **required** Pass an `object` to confirm using data collected by an `iban` Element. - `sepa_debit` (object) **required** An object of self-collected IBAN data. - `iban` (string) **required** An IBAN account number. - `billing_details` (object) **required** The customer's [billing_details](/api/payment_methods/create.md#create_payment_method-billing_details). `name` and `email` are required. - `name` (string) **required** The customer's name. - `email` (string) **required** The customer's email. ### Confirm with self collected data ```js stripe .confirmSepaDebitSetup('{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { sepa_debit: { iban: 'DE89370400440532013000', }, billing_details: { name: 'Jenny Rosen', email: 'jenny@example.com', }, }, }) .then(function(result) { // Handle result.error or result.setupIntent }); ``` ```es_next const {setupIntent, error} = await stripe.confirmSepaDebitSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { sepa_debit: { iban: 'DE89370400440532013000', }, billing_details: { name: 'Jenny Rosen', email: 'jenny@example.com', }, }, }, ); ``` ### Confirm SEPA Debit setup ```js stripe .confirmSepaDebitSetup('{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { sepa_debit: ibanElement, billing_details: { name: 'Jenny Rosen', email: 'jenny@example.com', }, }, }) .then(function(result) { // Handle result.error or result.setupIntent }); ``` ```es_next const {error, setupIntent} = await stripe.confirmSepaDebitSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { sepa_debit: ibanElement, billing_details: { name: 'Jenny Rosen', email: 'jenny@example.com', }, }, }, ); ``` ## Confirm Sofort setup Use `stripe.confirmSofortSetup` in the [Set up future payments](/payments/sofort/set-up-payment.md) flow to use SOFORT bank details to set up a SEPA Direct Debit payment method for future payments. When called, it will confirm a `SetupIntent` with `data` you provide, and it will automatically redirect the customer to authorize the transaction. Once authorization is complete, the customer will be redirected back to your specified `return_url`. Note that there are some additional requirements to this flow that are not covered in this reference. Refer to our [integration guide](/payments/sofort/set-up-payment.md) for more details. When you confirm a `SetupIntent`, it needs to have an attached [PaymentMethod](/api/payment_methods.md). In addition to confirming the `SetupIntent`, this method can automatically create and attach a new `PaymentMethod` for you. It can also be called with an existing `PaymentMethod`, or if you have already attached a `PaymentMethod` you can call this method without needing to provide any additional data. These use cases are detailed in the sections that follow. > Note that `stripe.confirmSofortSetup` may take several seconds to complete. > During that time, you should disable your form from being resubmitted and show a waiting indicator like a spinner. > If you receive an error result, you should be sure to show that error to the customer, re-enable the form, and hide the waiting indicator. `stripe.confirmSofortSetup` will return a `Promise` which resolves with a `result` object. This object has either: * `result.setupIntent`: the successful [SetupIntent](/api/setup_intents). * `result.error`: an error. Refer to the [API reference](/api#errors) for all possible errors. **Syntax:** `stripe.confirmSofortSetup(...)` - `clientSecret` (string) **required** The [client secret](/api/setup_intents/object.md#setup_intent_object-client_secret) of the `SetupIntent`. - `data` (object) Data to be sent with the request. Refer to the [Setup Intents API](/api/setup_intents/confirm.md) for a full list of parameters. - `payment_method` (object | string) The `id` of an existing PaymentMethod or an object of collected data. See use cases below for details. - `return_url` (string) The url your customer will be directed to after they complete authentication. - `options` (object) An options object to control the behavior of this method. - `handleActions` (boolean) Set this to `false` if you want to [manually handle the authorization redirect](/payments/sofort/accept-a-payment?platform=web.md#handle-redirect). Default is `true`. ### Use case: with an existing payment method If you have already created a `PaymentMethod`, you can pass its `id` to `payment_method` when calling `stripe.confirmSofortSetup` and it will be used to confirm the `SetupIntent`. ### Data argument properties - `payment_method` (string) **required** The `id` of an existing `PaymentMethod`. - `return_url` (string) The url your customer will be directed to after they complete authentication. ### Confirm with existing payment method ```js stripe .confirmSofortSetup('{SETUP_INTENT_CLIENT_SECRET}', { payment_method: '{PAYMENT_METHOD_ID}', }) .then(function(result) { // Handle result.error or result.setupIntent }); ``` ```es_next const {error, setupIntent} = await stripe.confirmSofortSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: '{PAYMENT_METHOD_ID}', }, ); ``` ### Use case: with self collected data Your customer's name, email and the country of their bank are required for the SOFORT authorization to succeed. You can pass in these properties directly to create a new `PaymentMethod` and confirm the `SetupIntent`. ### Data argument properties - `payment_method` (object) **required** Pass an object to confirm with the customer's name and email. - `country` (string) **required** The country code where customer's bank is located. - `billing_details` (object) **required** The customer's [billing_details](/api/payment_methods/create.md#create_payment_method-billing_details). `name` and `email` are required. - `name` (string) **required** The customer's name. - `email` (string) **required** The customer's email. - `return_url` (string) The url your customer will be directed to after they complete authentication. ### Confirm with self collected data ```js stripe .confirmSofortSetup('{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { sofort: { country: 'DE' }, billing_details: { name: 'Jenny Rosen', email: 'jenny@example.com', }, }, // Return URL where the customer should be redirected after the authorization. return_url: window.location.href, }) .then(function(result) { if (result.error) { // Inform the customer that there was an error. } }); ``` ```es_next const {error} = await stripe.confirmSofortSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { sofort: { country: 'DE' }, billing_details: { name: 'Jenny Rosen', email: 'jenny@example.com', }, }, // Return URL where the customer should be redirected after the authorization. return_url: window.location.href, }, ); ``` ### Confirm SOFORT setup ```js stripe .confirmSofortSetup('{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { sofort: { country: 'DE' }, billing_details: { name: 'Jenny Rosen', email: 'jenny@example.com', }, }, // Return URL where the customer should be redirected after the authorization. return_url: window.location.href, }) .then(function(result) { if (result.error) { // Inform the customer that there was an error. } }); ``` ```es_next const {error} = await stripe.confirmSofortSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { sofort: { country: 'DE' }, billing_details: { name: 'Jenny Rosen', email: 'jenny@example.com', }, }, // Return URL where the customer should be redirected after the authorization. return_url: window.location.href, }, ); ``` ## Confirm TWINT setup Use `stripe.confirmTwintSetup` in the [TWINT Payments with Setup Intents](/payments/twint/set-up-future-payments.md) flow when the customer submits your setup form. When called, it confirms the `SetupIntent`, and automatically redirects the customer to authorize the setup. After authorization is complete, the customer is redirected back to your specified `return_url`. > Note that `stripe.confirmTwintSetup` might take some time to complete while waiting for customers to authorize the setup. > During that time, disable your form from being resubmitted and show a waiting indicator like a spinner. > If you receive an error result, make sure to show the error to the customer, re-enable the form, and hide the waiting indicator. `stripe.confirmTwintSetup` will return a `Promise` which resolves with a `result` object. This object has either: * `result.setupIntent`: the successful [SetupIntent](/api/setup_intents). * `result.error`: an error. Refer to the [API reference](/api/errors) for all possible errors. **Syntax:** `stripe.confirmTwintSetup(...)` - `clientSecret` (string) **required** The [client secret](/api/setup_intents/object.md#setup_intent_object-client_secret) of the `SetupIntent`. - `data` (object) Data to be sent with the request. Refer to the [Setup Intents API](/api/setup_intents/confirm.md) for a full list of parameters. - `payment_method` (object | string) An object of collected data or an `id` of an existing [PaymentMethod](/api/payment_methods.md). See the use cases below for details. - `return_url` (string) **required** The URL your customer is redirected to after they complete authorization. - `options` (object) An options object to control the behavior of this method. - `handleActions` (boolean) Set this to `false` if you want to manually handle the authorization redirect. Default is `true`. ### Use case: with a new PaymentMethod If you haven't already created a `PaymentMethod`, you can pass payment method parameters, and the newly created `PaymentMethod` will be used to confirm the `SetupIntent`. ### Data argument properties - `payment_method` (object) **required** Pass an object to confirm using collected data. - `type` (string) **required** A `twint` type. - `return_url` (string) **required** The URL your customer is redirected to after they complete authorization. ### Confirm with a new PaymentMethod ```js stripe .confirmTwintSetup('{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { type: 'twint', }, // Return URL where the customer is redirected after // the authorization. return_url: "https://example.com/setup/complete", }) .then(function(result) { if (result.error) { // Inform the customer that there was an error. } }); ``` ```es_next const {error} = await stripe.confirmTwintSetup( '{SETUP_INTENT_CLIENT_SECRET}', { // Return URL where the customer is redirected after // the authorization. return_url: "https://example.com/setup/complete", }, ); ``` ### Use case: with an existing payment method Use `stripe.confirmTwintSetup` with an existing `PaymentMethod` by passing its `id` to `payment_method`. The `PaymentMethod` will be used to confirm the `SetupIntent`. ### Data argument properties - `payment_method` (string) **required** The `id` of an existing `PaymentMethod`. - `return_url` (string) **required** The URL your customer is redirected to after they complete authorization. ### Confirm with existing payment method ```js stripe .confirmTwintSetup('{SETUP_INTENT_CLIENT_SECRET}', { payment_method: '{PAYMENT_METHOD_ID}', // Return URL where the customer is redirected after // the authorization. return_url: "https://example.com/setup/complete", }) .then(function(result) { if (result.error) { // Inform the customer that there was an error. } }); ``` ```es_next const {error} = await stripe.confirmTwintSetup( '{SETUP_INTENT_CLIENT_SECRET}', { payment_method: '{PAYMENT_METHOD_ID}', // Return URL where the customer is redirected after // the authorization. return_url: "https://example.com/setup/complete", }, ); ``` ### Use case: with an attached PaymentMethod If you've already attached a `PaymentMethod` to this `SetupIntent`, then you can confirm the `SetupIntent` using `stripe.confirmTwintSetup` by passing a `return_url`. ### Data argument properties - `return_url` (string) **required** The URL your customer is redirected to after they complete authorization. ### Confirm with an attached PaymentMethod ```js stripe .confirmTwintSetup('{SETUP_INTENT_CLIENT_SECRET}', { // Return URL where the customer is redirected after // the authorization. return_url: "https://example.com/setup/complete", }) .then(function(result) { if (result.error) { // Inform the customer that there was an error. } }); ``` ```es_next const {setupIntent, error} = await stripe.confirmTwintSetup( '{SETUP_INTENT_CLIENT_SECRET}', { // Return URL where the customer is redirected after // the authorization. return_url: "https://example.com/setup/complete", }, ); ``` ### Confirm TWINT setup ```js stripe .confirmTwintSetup('{SETUP_INTENT_CLIENT_SECRET}', { payment_method: { type: 'twint', }, // Return URL where the customer is redirected after // the authorization. return_url: "https://example.com/setup/complete", }) .then(function(result) { if (result.error) { // Inform the customer that there was an error. } }); ``` ```es_next const {error} = await stripe.confirmTwintSetup( '{SETUP_INTENT_CLIENT_SECRET}', { // Return URL where the customer is redirected after // the authorization. return_url: "https://example.com/setup/complete", }, ); ``` ## Retrieve a SetupIntent Retrieve a [SetupIntent](/api/setup_intents.md) using its client secret. This method returns a `Promise` which resolves with a `result` object. This object has either: * `result.setupIntent`: a [SetupIntent](/api/setup_intents) was retrieved successfully. * `result.error`: an error. Refer to the [API reference](/api/errors) for all possible errors. **Syntax:** `stripe.retrieveSetupIntent(...)` - `clientSecret` (string) **required** The [client secret](/api/setup_intents/object.md#setup_intent_object-client_secret) of the `SetupIntent` to retrieve. ### Retrieve a SetupIntent ```js stripe .retrieveSetupIntent( '{SETUP_INTENT_CLIENT_SECRET}', ) .then(function(result) { // Handle result.error or result.setupIntent }); ``` ```es_next const {setupIntent, error} = await stripe.retrieveSetupIntent( '{SETUP_INTENT_CLIENT_SECRET}', ); // Handle result.error or result.setupIntent ``` ## Verify with micro-deposits for setup Use `stripe.verifyMicrodepositsForSetup` in the [Save details for future payments with pre-authorized debit in Canada](/payments/acss-debit/set-up-payment.md) or [Save details for future payments with ACH Direct Debit](/payments/ach-direct-debit/set-up-payment.md) flow to verify a customer's bank account with micro-deposits. It should be only called when [SetupIntent](/api/setup_intents.md) is in the `requires_action` state, and contains a `next_action` field that has a `type` equal to `verify_with_microdeposits`. Refer to our [integration guide](/payments/acss-debit/set-up-payment.md) for more details. > Verification can fail for several reasons. The failure may happen synchronously as a direct error response, or asynchronously through a `payment_intent.payment_failed` webhook event. > Refer to our [integration guide](/payments/acss-debit/accept-a-payment.md) for more details. `stripe.verifyMicrodepositsForSetup` will return a `Promise` which resolves with a result object. This object has either: * `result.setupIntent`: the [SetupIntent](/api/setup_intents) with a `status` of `succeeded`. * `result.error`: an error. Refer to the [API reference](/api#errors) and our [integration guide](/payments/acss-debit/set-up-payment) for all possible errors. **Syntax:** `stripe.verifyMicrodepositsForSetup(...)` - `clientSecret` (string) **required** The [client secret](/api/setup_intents/object.md#setup_intent_object-client_secret) of the `SetupIntent`. - `data` (object) Data to be sent with the request. - `amounts` (array) An array of two positive integers, in *cents*, equal to the values of the micro-deposits sent to the bank account. - `descriptor_code` (string) A six-character code starting with SM present in the microdeposit sent to the bank account. ### Verify with micro-deposits for setup ```js stripe.verifyMicrodepositsForSetup( '{SETUP_INTENT_CLIENT_SECRET}', { amounts: [32, 45], } ).then(function(result) { // Handle result.error or result.setupIntent }); ``` ```es_next const {setupIntent, error} = await stripe.verifyMicrodepositsForSetup( '{SETUP_INTENT_CLIENT_SECRET}', { amounts: [32, 45], } ); // Handle the setupIntent or error ``` ## Handle a next action Use `stripe.handleNextAction` in the [finalizing payments on the server](/payments/finalize-payments-on-the-server.md#next-actions) flow to finish confirmation of a [SetupIntent](/api/setup_intents.md) with the `requires_action` status. It will throw an error if the SetupIntent has a different status. Depending on the payment method and required action, the customer may be temporarily redirected from your site and brought back to the `return_url` [parameter](/api/setup_intents/confirm.md#confirm_setup_intent-return_url) provided when the SetupIntent is confirmed. > Note that `stripe.handleNextAction` may take several seconds to complete. > During that time, you should disable your form from being resubmitted and show a waiting indicator like a spinner. > If you receive an error result, you should be sure to show that error to the customer, re-enable the form, and hide the waiting indicator. > > Additionally, `stripe.handleNextAction` may trigger a [3D Secure](/payments/3d-secure.md) authentication challenge. > The authentication challenge requires a context switch that can be hard to follow on a screen-reader. > Ensure that your form is accessible by ensuring that success or error messages are clearly read out. This method returns a `Promise` which resolves with a `result` object. This object has either: * `result.setupIntent`: a [SetupIntent](/api/setup_intents) with the `processing` or `succeeded` status. * `result.error`: an error. Refer to the [API reference](/api/errors) for all possible errors. **Syntax:** `stripe.handleNextAction(...)` - `options` (object) **required** - `clientSecret` (string) The [client secret](/api/setup_intents/object.md#setup_intent_object-client_secret) of the `SetupIntent`. ### Handle a next action ```js stripe.handleNextAction({ clientSecret: '{SETUP_INTENT_CLIENT_SECRET}' }).then(function(result) { // Handle result.error or result.setupIntent }); ``` ```es_next const { setupIntent, error } = await stripe.handleNextAction({ clientSecret: '{SETUP_INTENT_CLIENT_SECRET}', }); // Handle the setupIntent or error ``` ## Collect bank account details for setup Use `stripe.collectBankAccountForSetup` in the [Save bank details](/payments/ach-direct-debit/set-up-payment.md) flow for the [ACH Direct Debit](/payments/ach-direct-debit.md) payment method to collect the customer’s bank account in your payment form. When called, it will automatically load an on-page modal UI to collect bank account details and verification, and attach the [PaymentMethod](/api/payment_methods.md) to the [SetupIntent](/api/setup_intents.md). When the `stripe.collectBankAccountForSetup` completes successfully, it returns a SetupIntent. If the customer provided their account, the SetupIntent is in the `requires_confirmation` state. If the customer closed the dialog without providing their account, the SetupIntent is in the `requires_payment_method` state. Use [stripe.confirmUsBankAccountSetup](/js/setup_intents/confirm_us_bank_account_setup) to complete the process. **Syntax:** `stripe.collectBankAccountForSetup(...)` - `options` (object) **required** Data to be sent with the request. - `clientSecret` (string) **required** The [client secret](/api/setup_intents/object.md#setup_intent_object-client_secret) of the `SetupIntent`. - `params` (object) **required** - `payment_method_type` (string) **required** The payment method type for the bank account details (e.g. `us_bank_account`) - `payment_method_data` (object) **required** Payment method specific data to be sent with the request - `billing_details` (Object) **required** The customer's [billing_details](/api/payment_methods/create.md#create_payment_method-billing_details). `name` is required. Providing `email` allows your customer to receive [ACH Direct Debit mandate and microdeposit emails](/payments/ach-direct-debit.md#mandate-and-microdeposit-emails). - `name` (string) **required** The customer's name. The first and last name must be at minimum 2 characters each. - `email` (string) The customer's email. - `address` (Object) The customer's billing address. - `city` (string) City, district, suburb, town, or village. - `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` (string) Address line 2 (e.g., apartment, suite, unit, or building). - `postal_code` (string) ZIP or postal code. - `state` (string) State, county, province, or region. ### Collect bank account details for setup ```js stripe.collectBankAccountForSetup( { clientSecret: '{SETUP_INTENT_CLIENT_SECRET}', params: { payment_method_type: 'us_bank_account', payment_method_data: { billing_details: {name: 'Jenny Rosen', email: 'jenny@example.com'}, }, }, } ).then(function(result) { // Handle result.error or result.setupIntent }); ``` ```es_next const {setupIntent, error} = await stripe.collectBankAccountForSetup( { clientSecret: '{SETUP_INTENT_CLIENT_SECRET}', params: { payment_method_type: 'us_bank_account', payment_method_data: { billing_details: {name: 'Jenny Rosen', email: 'jenny@example.com'}, }, }, } ); // Handle the setupIntent or error ```