## 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', }, }, }, ); ```