#Charmon

1 messages · Page 1 of 1 (latest)

shell pelicanBOT
winter maple
#

Hello, are you using redirectToCheckout on the client side to redirect your users to the checkout page?

#

This usually happens if you us stripeAccount server side when creating the Checkout Sessions but don't use it when initializing stripe.js client side

#

To mitigate it, we typically recommend doing away with redirectToCheckout altogether. You can just do a server side 303 redirect to the checkout session's URL, or send the URL client side and do a normal javascript redirect

finite shadow
#

one sec

#
const stripe = await getStripe();
      stripe?.redirectToCheckout({ sessionId });
#

what would I need to change

winter maple
#

My second and third message there are what you would need to change

This usually happens if you us stripeAccount server side when creating the Checkout Sessions but don't use it when initializing stripe.js client side
To mitigate it, we typically recommend doing away with redirectToCheckout altogether. You can just do a server side 303 redirect to the checkout session's URL, or send the URL client side and do a normal javascript redirect

#

So either you can change your stripe.js code to properly include the stripe account parameter when initializing:

#

Or you would change your server side code to do a 303 HTTP redirect

finite shadow
#

what is "doing away with redirectToCheckout "?

winter maple
#

A colloquial way of saying you can remove redirectToCheckout from your code and redirect using another method like the ones I listed

finite shadow
#

oh ok

#

so 303 http redirect is done server side?

#

which generates url

#

and returns to the client

winter maple
#

So you will get that back in the response when your server makes the request to create the new Checkout Session

finite shadow
winter maple
#

Correct

finite shadow
# winter maple Correct

and then I would use that url on the client with window.location.replace()? or how does that 303 redirect work?

winter maple
#

Yes you can definitely use that URL with window.location.replace()

The 303 redirect would depend on what you use server side. If you search your server framework and "303 redirect" there will likely be a good doc on it

finite shadow
#

Ok, thanks I will check