Destination charges work great, direct charges fail
I've got a Connect app, and I was hoping to use direct charges.
Currently using destination charges with the Python SDK and this works perfectly...
session = stripe.checkout.Session.create(
payment_method_types=['card'],
line_items=[{{blah}}],
mode='payment',
...
payment_intent_data={
'application_fee_amount': fee,
'transfer_data': {
'destination': owner_stripe
}
}
)
But when I change it to try and use direct charges (with the below code) there's an error...
session = stripe.checkout.Session.create(
payment_method_types=['card'],
line_items=[{{blah}}],
mode='payment',
...
payment_intent_data={
'application_fee_amount': fee,
},
stripe_account=owner_stripe
)
and the Checkout session redirect says
"The specified Checkout Session could not be found. This error is usually caused by using the wrong API key. Please make sure the API keys used to initialize Stripe.js and create the Checkout Session are test mode keys from the same account."
Support so far has been useless (is there a way to skip first line entirely, they just cut and paste the same trash) so I was hoping somebody here could tell me where I'm going wrong? API keys haven't changed, I'm getting the code from the official repo here, so I either I'm missing something (likely) or this is a bug (much less likely!)...
Posted Jul 28, 2020, 8:46 AM UTC
This sounds like you need to initialize Stripe.js with the connected account as well. https://stripe.com/docs/connect/authentication#adding-the-connected-account-id-to-a-client-side-application
Because the session "belongs to" the connected account, you have to also include the header when retrieving it for redirecting.
Makes perfect sense. I hadn't even saved the PK for the connected account so at least I know what to do now. Thank you so much!