I am new to stripe integration and I’m looking for a way to have multiple success_url for the subscriptions. Currently I have like 3 subscriptions with the names, Plan-A, Plan-B & Plan-C. And when an user proceeds with stripe payment for Plan-A, then success_url should show a thank you page saying the user now has Plan-A subscriptions and its features and so on for Plan-B & Plan-C. Can anyone help me to understand on how I can achieve the multiple success_url with reactjs.
Need to add multiple success_url for the stripe subscriptions
2
Answers
It depends on how you are checking out. With Stripe.js you can send your desired return URL when creating the payment intent:
If you using the Stripe hosted Checkout you can modify the success URL to include the session ID which you can use to then retrieve the session data.
Ex:
http://yoursite.com/order/success?session_id={CHECKOUT_SESSION_ID}
That being said it depends on what you are doing/showing on success. If you simply want to say "thanks for buying plan A (or B)" then you could store that in the state. But if you are doing more complex stuff then fetching the session data is prob the way to go.
Checkout Session doesn’t support multiple URLs in
success_url
parameter.Two possible ways to redirect to
success_url
of corresponding plan.success_url
to the URL of the price plan since you would have known the plan inline_items
at this timesession_id={CHECKOUT_SESSION_ID}"
in the query parameter ofsuccess_url
. When the customer is redirected to thesuccess_url
, check the Checkout Session ID and find out the plan that is set this Checkout Session in your database, then display the success page of the plan.