skip to Main Content

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


  1. It depends on how you are checking out. With Stripe.js you can send your desired return URL when creating the payment intent:

    stripe.confirmPayment({
      elements,
      confirmParams: {
        // Return URL where the customer should be redirected after the PaymentIntent is confirmed.
        return_url: 'https://example.com',
      },
    })
    .then(function(result) {
      if (result.error) {
        // Inform the customer that there was an error.
      }
    });
    

    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.

    Login or Signup to reply.
  2. Checkout Session doesn’t support multiple URLs in success_url parameter.

    Two possible ways to redirect to success_url of corresponding plan.

    1. When you create the Checkout Session, set the success_url to the URL of the price plan since you would have known the plan in line_items at this time
    2. Append session_id={CHECKOUT_SESSION_ID}" in the query parameter of success_url. When the customer is redirected to the success_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.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search