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