How to transfer Charged Amount from one connected Stripe Account to Another Connected Stripe Account

Viewed 3869

Is it possible to transfer an amount from one Connected-Account to another Connected-Account? both are connected under one Stripe account. I know i can split the transfer between both accounts like

$transfer = \Stripe\Transfer::create(array(
 "amount" => 7000,
 "currency" => "usd",
 "destination" => "{CONNECTED_STRIPE_ACCOUNT_ID1}",
));


$transfer = \Stripe\Transfer::create(array(
 "amount" => 2000,
 "currency" => "usd",
 "destination" => "{CONNECTED_STRIPE_ACCOUNT_ID2}",
));

But i want to transfer 9000 in 1st account and then from 1st Account to another. i had try to transfer using CONNECTED_STRIPE_ACCOUNT_ID1 secret key to transfer in CONNECTED_STRIPE_ACCOUNT_ID2 but got error like no such account available.

individual transfer are working perfect but want it from one account to another.

please Help.

2 Answers

You can't transfer from connected accounts -

Better way is to take all amount in your main stripe account and then you can transfer from your main account to CONNECTED_STRIPE_ACCOUNT_ID1 and CONNECTED_STRIPE_ACCOUNT_ID2 etc

When you redirect to stripe to connect account - stripe redirect back to your page with "code" value -

App::import('Vendor', 'StripeOAuth/StripeOAuth');
$oauth = new StripeOAuth(YOUR_CLIENT_ID, YOUR_SECRET_KEY);
$access_token = $oauth->getAccessToken($_GET['code']);
$publishable_key = $oauth->getPublishableKey($_GET['code']);
$refresh_token = $oauth->getRefreshToken($_GET['code']); 
$stripe_account_id = $oauth->getUserId($_GET['code']);

This $stripe_account_id is CONNECTED_STRIPE_ACCOUNT_ID1 (Your were using secret key of connected account but instead of that $stripe_account_id will work)

Now you can take all charge on main stripe account and transfer to connected account as you wish -

\Stripe\Stripe::setApiKey(YOUR_SECRET_KEY[![enter image description here][1]][1]);

// Create a Charge:
$charge = \Stripe\Charge::create(array(
  "amount" => 10000,
  "currency" => "usd",
  "source" => "tok_visa",
  "transfer_group" => "{ORDER10}",
));

// Create a Transfer to a connected account (later):
$transfer = \Stripe\Transfer::create(array(
  "amount" => 7000,
  "currency" => "usd",
  "destination" => "{CONNECTED_STRIPE_ACCOUNT_ID}",
  "transfer_group" => "{ORDER10}",
));

// Create a second Transfer to another connected account (later):
$transfer = \Stripe\Transfer::create(array(
  "amount" => 2000,
  "currency" => "usd",
  "destination" => "{OTHER_CONNECTED_STRIPE_ACCOUNT_ID}",
  "transfer_group" => "{ORDER10}",
));

Amount flow will work like showing in this diagram

Related