CurlyHead
CurlyHead

Reputation: 21

Have one stripe connect checkout session with multiple products trigger correct payouts to multiple different connected accounts

I am building a marketplace for people to sell digital products with nextjs, firebase and firebase cloud functions. I am able to credit one account with a cart of one or multiple products by following the documentation here https://stripe.com/docs/connect/collect-then-transfer-guide. But I would say it would be important to be able to put items from different authors into your cart.

This is my code that works well for one or multiple products and one connected account.

export const checkoutSessionSingular = functions.https.onCall(async (data, context) => {
  const session:any = await stripe.checkout.sessions.create({
    line_items: data.line_items,
    mode: "payment",
    success_url: "***",
    cancel_url: "***",
    payment_intent_data: {
      application_fee_amount: data.fee_amount,
      transfer_data: {
        destination: data.connectId,
      },
    },
  });
  return session;
});

I have tried putting payment data, transfer data or destination into an array, but that always breaks it. I tried using transfers and transfer groups, but I seem to lose all the valuable data in the stripe dashboard about which product the money comes from and I can't manage to make it work properly with the very limited documentation. I also tried using destination charges but couldn't make it work. If something like transfer groups are the solution, I would welcome a link to a proper example implementation or something more helpful.

What should I do to just have a normal working cart for a multi vendor marketplace? I already looked at every page of their documentation 30 times. Thanks.

Upvotes: 2

Views: 1116

Answers (1)

soma
soma

Reputation: 2219

If you want to send the money to multiple connected accounts, then you have to use Separate Charges & Transfers. So in your case you need to:

  1. Create the Checkout Session and collect the payment, without any application_fee_amount or transfer_data
  2. Then manually create Transfers between your main Stripe account and the connected accounts, with this endpoint

Upvotes: 1

Related Questions