Destination charges work great, direct charges fail

Question

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

25
goorpy:Stripe:•

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.

3
BlueFaceMonsterOP•

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!

1
varunSidhwani•

u/BlueFaceMonster I am facing the same issue, can you please explain the steps to fix the issue?? Thanks

1
BlueFaceMonsterOP•

It's different now, I think, my friend. Most recently I just added a stripe_account to every request like it says here https://stripe.com/docs/api/connected_accounts?lang=python - no need to use connected SK any more.

1
varunSidhwani•

Hey, thanks for replying, can you please elaborate how to go about to fix this. I visited the above like but couldn't figure out the solution(I'm using this for the first time), Can you explain what changes I need to make to my code? thanks

1