How to add an external bank account with customer in stripe using laravel?

648 Views Asked by At

How can I add an external bank account for a customer in stripe using laravel. I am able to generate some output but not as required for me.

{
  "id": "ba_1MI3bbF23J5kz1XAe7HfLvuN",
  "object": "bank_account",
  "account": "acct_1MHoBlF23J5kz1XA",
  "account_holder_name": "Jane Austen",
  "account_holder_type": "individual",
  "account_type": null,
  "available_payout_methods": [
    "standard"
  ],
  "bank_name": "STRIPE TEST BANK",
  "country": "US",
  "currency": "usd",
  "fingerprint": "1JWtPxqbdX5Gamtz",
  "last4": "6789",
  "metadata": {},
  "routing_number": "110000000",
  "status": "new"
}

I am able to generate the below given response, using the code above

 $account = \Stripe\Account::create(array(
            "type" => "custom",
            "country" => "US",
            "email" => auth()->user()->email,
            'capabilities' => [
                'card_payments' => ['requested' => true],
                'transfers' => ['requested' => true],
            ],
        ));
        $account_id = $account->id;
        $external_account =  $stripe->accounts->createExternalAccount(
            $account_id,
            $user->stripe_customer_id,
            [
                'external_account' => $token->id,
            ]
        );

How to generate the response as given below :

{
  "id": "ba_1MI35QF23J5kz1XAwIvJPWa0",
  "object": "bank_account",
  "account_holder_name": "girish",
  "account_holder_type": "individual",
  "account_type": null,
  "bank_name": "STRIPE TEST BANK",
  "country": "US",
  "currency": "usd",
  "customer": "cus_N27I4C187MRZac",
  "fingerprint": "wrigOuKxXT4GeRSr",
  "last4": "6789",
  "metadata": {},
  "routing_number": "110000000",
  "status": "verified"
}

How to "customer": "cus_N27I4C187MRZac" store when I create external account.

1

There are 1 best solutions below

0
qichuan On

An external account is basically a bank account for your connected account to create payout to. You can follow the API reference and pass all the necessary information (i.e., account_number and currency) to create an external account.

If you have a frontend integration, you can also create a token in the frontend, and pass the token ID to backend and call the external account creation API to create a external account.