ruby-on-railsrubystripe-payments

How can I accept bank account payments using Stripe API for ACH payment


The application that i am working on is accepting payments via card. The requiremnt is to acccept payment via bank accounts(ACH payments)

I tried using the payment method option as us_bank_account, but the parameters seems to incorrect here

Stripe::PaymentIntent.create(
  {
    amount: 1099,
    currency: 'usd',
    setup_future_usage: 'off_session',
    payment_method_types: ['us_bank_account'],
    payment_method_options: {
      us_bank_account: {
        routing_number: 110000000,
        account_number: 123456789,
        account_holder_type:'individual',
      },
    },
  },
)

The error I get is

Stripe::InvalidRequestError: Received unknown parameters: account_holder_type, account_number, routing_number
from /home/admin1/.rvm/gems/ruby-2.6.7/gems/stripe-5.33.0/lib/stripe/stripe_client.rb:650:in `handle_error_response'```

I am unsure which API and parameters are required here. Also, can I use Transfer API instead of PaymentIntent. I am avoiding Charge API since it is depreciated.

My goal is to test the API with mt sandbox account (acct_testXXXXXXXXXX) and make payments different account and routing numbers

Test account and routing number


Solution

  • Values for account_holder_type, account_number, and routing_number parameters should be sent as part of payment_method_data.us_bank_account: https://stripe.com/docs/api/payment_intents/create#create_payment_intent-payment_method_data-us_bank_account

    The payment_method_data dictionary also requires type and US bank accounts require an account holder name. Your creation request should look something like this:

    Stripe::PaymentIntent.create(
      {
        amount: 1099,
        currency: 'usd',
        setup_future_usage: 'off_session',
        payment_method_types: ['us_bank_account'],
        payment_method_data: {
          type: 'us_bank_account',
          billing_details: {
            name: 'Test Name'
          },
          us_bank_account: {
            routing_number: '110000000',
            account_number: '000123456789',
            account_holder_type: 'individual'
          }
        }
      }
    )
    

    The above will create a PaymentIntent but that PaymentIntent will still need to be confirmed. Confirming a PaymentIntent requires your customer to accept a mandate. I recommend following this guide as you test since you'll ultimately have your customer share bank account information on the frontend instead: https://stripe.com/docs/payments/ach-debit/accept-a-payment?platform=web&ui=API