#essakrishnachaitanya - Checkout Subscription duration

1 messages · Page 1 of 1 (latest)

soft dawn
#

Hello, good question. Checking in to whether Checkout can set this automatically

#

It looks like Checkout can't specify this from the start but you can listen to the checkout.session.succeeded event or the customer.subscription.created event and update the subscription's cancel_at timestamp to tell stripe when to end the subscription.

orchid marsh
#

can you please send me sample example of checkout.session.succeeded and customer.subscription.created event in javascript

soft dawn
orchid marsh
#

How to create a subscription schedule with iterations on stripe checkout..?

soft dawn
orchid marsh
#

okay from plain javascript how to create a schedule subscription..?

soft dawn
#

That doc has a snippet for how to make that call in Node.js

  from_subscription: 'sub_GB98WOvaRAWPl6'
});```
orchid marsh
#

okay our requirement is we need to create a subscription for user for a specified duration in javascript

soft dawn
#

Makes sense, in your scenario, that would mean that you create the Checkout Session, listen for the appropriate webhook, and then when you get that webhook you can either:

  1. Calculate when you want the subscription to end and make and API call to set the cancels_at timestamp on your subscriptions
  2. Make an API call to create a subscription schedule from the subscription that your Checkout Session created and then another API call to set how many iterations you want the subscription to last for