1
votes

I'm trying to use Stripe Checkout with a connected account. Where I would be able to create a subscription with transfer_data["destination"] and application_fee_percent.

The flow expected:

  1. Create checkout Session (server side)
checkout_session = stripe.checkout.Session.create(
            success_url=domain_url + "/success.html",
            cancel_url=domain_url + "/canceled.html",
            payment_method_types=["card"],
            mode="subscription",
            line_items=[
                {
                    "price": priceId,
                    "quantity": 1
                }
            ],
            customer=customerId)
  1. Redirect the user to Stripe checkout page
  2. User enters his card details and subscribe

I tried with subscription_data["application_fee_percent"] and with Stripe-Account set. But this is not working because customer is not found. Because I guess all customers are created on the platform account, not the connected account (that I want to conserve)

So my question: What's the way to do this with Checkout?

My other choice would be:

  1. Collect card information to create a payment method
  2. Create a subscription with application_fee_percent and transfer_data[destination].

But I would prefer to use Checkout for collecting card details which seems to me a better and easier user flow...

All advices will be appreciated. Thanks.

1

1 Answers

2
votes

I thought this was possible exactly as you hypothesized, but encountered the error:

Error: Can only apply a subscription application_fee_percent when the Checkout Session is made on behalf of another account (using an OAuth key or the Stripe-Account header).

which is what I assume you ran into. Undeterred I reviewed the docs and then the changelog (for stripe-node, which I use), and found the hint I needed:

Add transfer_data[amount_percent] on Subscription

After I testing, I can confirm you can do this, you just need to use amount_percent (API ref) using say 95% transferred instead of a 5% application fee (though be aware of how fees affect the funds flow).

Bottom line, you can do this instead:

checkout_session = stripe.checkout.Session.create(
        success_url=domain_url + "/success.html",
        cancel_url=domain_url + "/canceled.html",
        payment_method_types=["card"],
        mode="subscription",
        line_items=[
            {
                "price": priceId,
                "quantity": 1
            }
        ],
        customer=customerId),
        subscription_data={
          transfer_data={
            destination='acct_1234',
            amount_percent=95
          }
        }