## 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 } ```