#Drewdan-connect

1 messages ยท Page 1 of 1 (latest)

magic goblet
#

Hi, which stripe-account header you removed?

#

client side or serverside?

subtle relic
#

client side, I am using the PHP client

#

so I pass a second array with ['stripe_account', 'acct_foo']

magic goblet
#

I am confused. PHP is a server language. Client side I meant JS

subtle relic
#

sorry, I meant serverside

magic goblet
#

Okie so in server, PHP, you created a Checkout Session with stripe-account header, correct? Then the Checkout Session belongs to that Connected Account

#

How do you redirect in client side?

subtle relic
#

correct, I then pass the payment intent and use the JS to redirect.

something like:

const stripePromise = loadStripe('{{ $stripeKey }}');
                const stripe = await stripePromise;
                await stripe.redirectToCheckout({ sessionId: event.detail.sessionId });
magic goblet
#

Okie, this $stripeKey here is a Publishable Key, correct?

subtle relic
#

that is correct

magic goblet
#

I bet it's the Platform Publishable Key, so this stripePromise will only know what is belongs to the Platform

#

You need to pass the stripe account header here, in client side, too

subtle relic
#

ah sweet, I didn't realise that was a thing

#

I will try that now. Thank you very much ๐Ÿ™‚

#

out of interest, I was just inspect the returned session, and it includes a URL, which I have not seen before. Can I just redirect to that serverside? I thought the redirect had to happen on the front end, which is why I have done it this way

magic goblet
#

Yes ๐Ÿ˜„ serverside redirect is newer approach and it will save you all of this headache ๐Ÿ˜„

#

Something like

return $response->withHeader('Location', $session->url)->withStatus(303);
subtle relic
#

oh that is amazing! That should make things a lot simpler in my code. Thank you very much for your time ๐Ÿ˜„