简体   繁体   中英

Transfer amount into customer's bank account using Stripe Payout API

I am working on an implementation of REST API for a mobile application which encapsulates feature of redemption of earned points in form of money equivalent to points using Stripe as a payment gateway . To accomplish it I have used Stripe payout API to transfer amount directly into destination bank account.

Following is code snippet of call to payout API of Stripe

$payout=\Stripe\Payout::create(array(
  "amount" => 400,
  "currency" => "usd",
  "destination"=>$ID,/* ID of customer bank account ba_1CIZEOCHXaXPEwZByNehIJrY  */
  "source_type"=>'bank_account'
));

Upon execution of above code snippet I receive error message as response to call of payout API

The bank account ba_1CIZEOCHXaXPEwZByNehIJrY is not attached to this Stripe account. External accounts can only be attached to Standard accounts via the dashboard.

According to above error message it seems that same bank account needs to be attached to both customer and connected stripe account but I am unable to find appropriate solution to attach customer's bank account to merchant as an external account.

Please suggest me an appropriate solution to it.

Actually you can use the Stripe payout API to initiate a payout to either a bank account or debit card of a connected Stripe account.However you can create a transfer , To send funds from your Stripe account to a connected account.

https://stripe.com/docs/api/transfers/create

Below is the php code :

\Stripe\Stripe::setApiKey("sk_test_AjtBCFvy8Ah0x5vLmd5Ntemi");

\Stripe\Transfer::create([
  "amount" => 400,
  "currency" => "usd",
  "destination" => "acct_1CPuerJ18us5u9z6",
  "transfer_group" => "ORDER_95"
]);

I have also searched stripe documentation , to directly transfer the payment in the third party card / bank account, but did not find anything.

With Stripe Connect, you can make API requests on behalf of connected accounts using the Stripe-Account header as documented here . This applies to any API requests from creating a Charge or a Payout to listing all Refunds.

This obviously assumes that you use Stripe Connect and that the person receiving funds from you has their own connected accounts. You also have to use Custom or Express accounts if you want to be able to control their Payouts. This is not allowed with Standard accounts.

The code would look like this:

$payout=\Stripe\Payout::create(array(
  "amount" => 400,
  "currency" => "usd",
  "destination"=> "ba_XXXX" // bank account id
),
array(
  "stripe_account" => "acct_XXXX" // id of the connected account
));

This obviously assumes that you are familiar with Stripe Connect and are actively using it. It would be the only way to handle this and you can read more about this feature here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM