## Confirm a payment Use `stripe.confirmPayment` to confirm a [PaymentIntent](/api/payment_intents.md) using data collected by the [Payment Element](/js/element/payment_element.md), or with manually provided data via `confirmParams`. When called, `stripe.confirmPayment` 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 confirmation is complete. > The `stripe.confirmPayment` 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.confirmPayment` will return a `Promise`. After a successful confirmation, Stripe redirects your user to the `return_url` you provide before the `Promise` resolves. For payments that don't require a redirect, the `Promise` resolves to the updated Intent. If the confirmation fails, the `Promise` will resolve with an `{error}` object that describes the failure. If the error 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 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 PaymentIntent has a `status` of `requires_payment_method`. In this case, attempt to recollect payment from the user. **Syntax:** `stripe.confirmPayment(...)` - `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=payment). It's always required if you don't provide a `clientSecret`. - `clientSecret` (string) **required** The PaymentIntent's client secret. Required if you [collect payment details before creating an Intent](/payments/accept-a-payment-deferred.md?platform=web&type=payment). It's always required if you don't provide an `elements` instance containing a [client secret](/api/payment_intents/object.md#payment_intent_object-client_secret). - `confirmParams` (object) Parameters that will be passed on to the Stripe API. You can also use the parameters from the [Payment Intents API](/api/payment_intents/confirm.md), except for setup_future_usage. - `return_url` (string) **required** The URL that Stripe redirects your customer to after they complete the payment. You can use the following query parameters, `payment_intent` (the PaymentIntent's ID) or `payment_intent_client_secret` (the PaymentIntent's client secret), to retrieve the PaymentIntent's [status](/api/payment_intents/object.md#payment_intent_object-status). When Stripe redirects your customer, the resulting URL has these query parameters appended. You can also append your own query parameters to the `return_url`, which persist through the redirect process. If you don't want to redirect for card payments after payment completion, set [redirect](/js/payment_intents/confirm_payment.md#confirm_payment_intent-options-redirect) to `if_required`. - `shipping` (object) The [shipping details](/api/payment_intents/confirm.md#confirm_payment_intent-shipping) for the payment, if collected. **Note**: When the [Address Element](/js/element/address_element.md) in shipping mode is being used, shipping address details are collected from the Address Element and passed to the PaymentIntents [confirm endpoint](/api/payment_intents/confirm.md) as the [shipping](/api/payment_intents/confirm.md#confirm_payment_intent-shipping) parameter. You can also include additional `shipping` fields, which will be merged with the data collected from the Element. Values passed here will override details collected by Elements. - `confirmation_token` (string) If collected previously, the ID of the ConfirmationToken to use to confirm this PaymentIntent. This is mutually exclusive with the `elements` parameter. - `payment_method` (string) If collected previously, the ID of the payment method to attach to this PaymentIntent. This is mutually exclusive with the `elements` parameter. - `payment_method_data` (object) When you call `stripe.confirmPayment`, payment details are collected from the Element and passed to the PaymentIntents [confirm endpoint](/api/payment_intents/confirm.md) as the [payment_method_data](/api/payment_intents/confirm.md#confirm_payment_intent-payment_method_data) 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. **Note**: When the [Address Element](/js/element/address_element.md) in billing mode is being used, billing address details are collected from the Address Element and passed to the PaymentIntents [confirm endpoint](/api/payment_intents/confirm.md) as the [billing_details](/api/payment_methods/create.md#create_payment_method-billing_details) parameter. The values collected from the Address Element will take precedence. - `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 [PaymentIntent](/api/payment_intents/object.md) expansion parameters ([learn more](/api/expanding_objects.md)). - `redirect` ('always' | 'if_required') By default, `stripe.confirmPayment` will always redirect to your `return_url` after a successful confirmation. If you set `redirect: "if_required"`, then `stripe.confirmPayment` 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.confirmPayment` will resolve with a `{paymentIntent}` object. ### Confirm a payment intent ```js stripe.confirmPayment({ elements, confirmParams: { // Return URL where the customer should be redirected after the PaymentIntent 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.confirmPayment( { elements, confirmParams: { // Return URL where the customer should be redirected after the PaymentIntent is confirmed. return_url: 'https://example.com', }, } ); if (error) { // Inform the customer that there was an error. } ```