Home > other >  How to pass existing subscription details on stripe during checkout
How to pass existing subscription details on stripe during checkout

Time:11-23

I’ve different subscription plan on stripe starting from Zero. When customer sign up, I’m creating a subscription with free plan by default.

In the future, customer want to upgrade the plan through checkout session, how can I pass my existing subscription details to the checkout session to update the plan tagged to the subscription ID instead of creating multiple subscriptions.

I gone through the stripe create checkout session Doc but I couldn’t find a way to pass subscription ID in checkout session.

Any help would be much appreciated

CodePudding user response:

You are trying to update an existing Subscription through a CheckoutSession, that is not supported.

If a customer uses Checkout to sign up for a new Price, that creates a completely new Subscription object. You cannot pass an existing Subscription ID as Checkout cannot modify that.

You should use Checkout in mode: setup to collect card details from your customer. This setup mode only collects card details but does not charge or create a Subscription on that Customer.

Then in your server-side code after you receive the checkout.session.completed webhook event, update the existing Subscription to switch from the "free" Price to the "paid" Price: https://stripe.com/docs/api/subscriptions/update

  • Related