Abhay Maurya
Abhay Maurya

Reputation: 12277

In stripe connect, is there any way to schedule a transfer to happen when the charged amount actually gets available in stripe account

First of all, thank you for helping me out so far.

I have one more question related to stripe transfers. So my scope is to charge a customer and then transfer a portion of money to one associated user and another portion to another user. I am using following script:

$charge = \Stripe\Charge::create([
    "amount" => $cost,
    "currency" => "usd",
    "customer" => $customerId,
    "transfer_group" => $transferGroupToken
]);

// Create a Transfer to a connected account - Area Dev (later):
$transfer = \Stripe\Transfer::create([
    "amount" => $costPercentage1,
    "currency" => "usd",
    "destination" => $userAccountId1,
    "transfer_group" => $transferGroupToken
]);

// Create a second Transfer to another connected account - Guide (later):
$transfer = \Stripe\Transfer::create([
    "amount" => $costPercentage2,
    "currency" => "usd",
    "destination" => $userAccountId2,
    "transfer_group" => $transferGroupToken
]);

Now this code works, but there is one issue.

When I charge the customer, the money does not come into stripe account right away, however the transfer does happen right away so I need to have sufficient fund in my stripe account otherwise script fails giving "Insufficient funds" error which totally makes sense.

But I would prefer a solution in which I could somehow schedule the transfer and it happens when I receive the original payment (the cost with which I charged the customer), that way I will always have sufficient fund as I only transfer a part of received cost.

Any idea how can I achieve that?

To conclude, the question is:

In stripe connect, is there any way to schedule a transfer to happen when the charged amount actually gets available in stripe account?

Thanks in advance

Upvotes: 1

Views: 1406

Answers (1)

Oscar Sortland Kolsrud
Oscar Sortland Kolsrud

Reputation: 448

Maybe this could help you on your way? https://stripe.com/docs/connect/charges-transfers#transfer-availability

What is described there is basically a method where stripe takes and "schedules" the transfer to happen when the funds is in your account. This automatically creates the transfer group and is possible because when initializing you link it with the charge ID.

$transfer = \Stripe\Transfer::create([
  "amount" => 1000,
  "currency" => "usd",
  "source_transaction" => "{CHARGE_ID}",
  "destination" => "{CONNECTED_STRIPE_ACCOUNT_ID}",
]);

Stripes description of the flow when using this: When using this parameter:

The amount of the transfer must not exceed the amount of the source charge

You may create multiple transfers with the same source_transaction, as long as the sum of the transfers doesn’t exceed the source charge

The transfer takes on the pending status of the associated charge: if the funds from the charge become available in N days, the payment that the destination Stripe account receives from the transfer also becomes available in N days

Stripe automatically creates a transfer_group for you

Upvotes: 3

Related Questions