## Confirm an ACH Direct Debit payment Use `stripe.confirmUsBankAccountPayment` in the [Accept a payment flow](/payments/ach-direct-debit/accept-a-payment.md) for the [ACH Direct Debit](/payments/ach-direct-debit.md) payment method to record the customer’s authorization for payment. When you confirm a [PaymentIntent](/api/payment_intents.md), it needs to have an attached [PaymentMethod](/api/payment_methods.md). We suggest using `stripe.collectBankAccountForPayment`, which automatically collects bank account details and attaches a `PaymentMethod`. 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.confirmUsBankAccountPayment` will return a `Promise` which resolves with a result object. This object has either: * `result.paymentIntent`: the successfully confirmed [PaymentIntent](/api/payment_intents). * `result.error`: an error. Refer to the [API reference](/api#errors) and our [integration guide](/payments/ach-direct-debit/accept-a-payment) for all possible errors. **Syntax:** `stripe.confirmUsBankAccountPayment(...)` - `clientSecret` (string) **required** The [client secret](/api/payment_intents/object.md#payment_intent_object-client_secret) of the `PaymentIntent`. - `data` (object) Data to be sent with the request. Refer to the [Payment Intents API](/api/payment_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.confirmUsBankAccountPayment`. ### Data argument properties - `payment_method` (string) **required** The `id` of an existing [PaymentMethod](/api/payment_methods.md). ### Confirm with an existing PaymentMethod ```js stripe.confirmUsBankAccountPayment( '{PAYMENT_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 PaymentIntent's status. console.log("PaymentIntent ID: " + result.paymentIntent.id); console.log("PaymentIntent status: " + result.paymentIntent.status); } }); ``` ```es_next const {paymentIntent, error} = await stripe.confirmUsBankAccountPayment( '{PAYMENT_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 PaymentIntent's status. console.log("PaymentIntent ID: " + paymentIntent.id); console.log("PaymentIntent status: " + paymentIntent.status); } ``` ### Use case: with an attached PaymentMethod If you have successfully called `stripe.collectBankAccountForPayment` or attached a `PaymentMethod` to this `PaymentIntent` already, then you can confirm the `PaymentIntent` without passing in any additional data. ### Confirm with an attached PaymentMethod ```js stripe.confirmUsBankAccountPayment( '{PAYMENT_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 PaymentIntent's status. console.log("PaymentIntent ID: " + result.paymentIntent.id); console.log("PaymentIntent status: " + result.paymentIntent.status); } }); ``` ```es_next const {paymentIntent, error} = await stripe.confirmUsBankAccountPayment( '{PAYMENT_INTENT_CLIENT_SECRET}', {} ); if (error) { // Inform the customer that there was an error. console.log(error.message); } else { // Handle next step based on PaymentIntent's status. console.log("PaymentIntent ID: " + paymentIntent.id); console.log("PaymentIntent status: " + paymentIntent.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 `PaymentIntent`. ### 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.confirmUsBankAccountPayment( '{PAYMENT_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 PaymentIntent's status. console.log("PaymentIntent ID: " + result.paymentIntent.id); console.log("PaymentIntent status: " + result.paymentIntent.status); } }); ``` ```es_next const {paymentIntent, error} = await stripe.confirmUsBankAccountPayment( '{PAYMENT_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 PaymentIntent's status. console.log("PaymentIntent ID: " + paymentIntent.id); console.log("PaymentIntent status: " + paymentIntent.status); } ``` ### Confirm an ACH Direct Debit payment ```js stripe.confirmUsBankAccountPayment( '{PAYMENT_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 PaymentIntent's status. console.log("PaymentIntent ID: " + result.paymentIntent.id); console.log("PaymentIntent status: " + result.paymentIntent.status); } }); ``` ```es_next const {paymentIntent, error} = await stripe.confirmUsBankAccountPayment( '{PAYMENT_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 PaymentIntent's status. console.log("PaymentIntent ID: " + paymentIntent.id); console.log("PaymentIntent status: " + paymentIntent.status); } ```