Search code examples
stripe-paymentsstripe-connect

Stripe Connect - How to charge multiple users to 1 customer


I use Stripe Connect to charge users credit card and transfer to a customer with a commission. I'd like to implement a 'Ride-sharing' functionality type on my app. The idea is to split the amount charged among a number of N people and still transfer to one customer, i.e. a many-to-one transaction.

What is the best way to implement that ? I didn't find any tutorial or docs for many-to-one transactions (only the other way around)

  • One way is to create as many transfers as charges but it is not ideal for the customer because it can split the payout for one business transaction
  • The other way, it seems, is to use 'Creating Separate Charges and Transfers' with several charges and one transfer thanks to a transfer_group.

But when I tried :

    $charge1 = \Stripe\Charge::create(array(
        "amount" => 500, "currency" => "eur", "customer" => "cus_1",
        "transfer_group" => "mytransfergroup_1"
     ));
    $charge2 = \Stripe\Charge::create(array(
        "amount" => 500, "currency" => "eur", "customer" => "cus_2",
        "transfer_group" => "mytransfergroup_1"
     ));  

    $transfer = \Stripe\Transfer::create(array(
       "amount" => 800,  "currency" => "eur", "destination" => "{CONNECTED_STRIPE_ACCOUNT_ID}",
       "transfer_group" => "mytransfergroup_1",
    ));

I got the message

"Insufficient funds in Stripe account. In test mode, you can add funds to your available balance (bypassing your pending balance) by creating a charge with 4000 0000 0000 0077 as the card number."

Ok I am on test mode but in live, should I run a cron job every day to launch the transfer of my untransfered charges, so way after the time of the transaction ?

And even if the balance is enough, I am going to transfer money from older transactions for a more recent one. The problem is when the payout is due for the older transactions, I will not have enough on my balance to payout the right amount for my old transactions.

Hope I am clear.

Thanks for your help.


Solution

  • According to what you've said, it sounds like using separate charges & transfers is the best choice. As explained in the documentation, with this flow your platform "can only transfer up to the platform’s available account balance". In other words, this flow is most suited for platforms that process enough transactions so that their available balance can cover the transfers they need to create. If necessary, you can pre-fund your account's balance to get started.

    That said, as this is less of a technical question and more of a payment flow one, I'd recommend reaching out to Stripe's support at https://support.stripe.com/email to ask about this. They will be able to advise you on which flow would be most appropriate for your business.