#patrick-subscription-schedules
1 messages · Page 1 of 1 (latest)
Hi there 👋 it is expected for Subscriptions to start immediately, you would need to use a Subscription Schedule to start one in the future.
However, I'm curious to hear more about why you've elected to have the customer first pay via a Payment Intent and then create a Subscription for them? Typically with Subscription integrations, you create a Subscription, which creates an Invoice immediately for the first payment, and then use the Payment Intent from that first Invoice to process the initial payment. You definitely don't have to do things that way if you have a good reason not to, but it is likely easier than incorporating Subscription Schedules into your flow.
I found it a bit easier and more convinient, since the customer have to make the first payment before an EC2 instance will be opened on their behalf. I could listen to a webhook but that would add more complexity to it...
How do I attach the subscription schedule? Can I specify everything like before and only add a schedule paremeter to the object for subscriptions.create?
Nope, the other way around, you need to create a Subscription Schedule and pass it everything you would have passed to the Subscription creation request.
The Subscription Schedule will then create the Subscription in the future, based on what you set for start_date :
https://stripe.com/docs/api/subscription_schedules/create#create_subscription_schedule-start_date
A sample of that, in several languages, can be found here:
https://stripe.com/docs/billing/subscriptions/subscription-schedules/use-cases#start-subscription-future
I'll try it out, thanks @lilac quail !
Any time! Let me know if it gives you any trouble.
Sorry to bother you again, I am not following the iterations part. I want the scheduler to trigger an invoice for two items, once per month. Is it possible to also make it to run infinetly as long as the customer doesnt cancle the subscription?
The Subscription will do that, you don't need the Subscription Schedule to run indefinitely. Set the end_behavior on the Subscription Schedule to release (as shown in the sample) and the Subscription Schedule will release the Subscription at the end of it's lifecycle. The Subscription will then continue indefinitely until canceled.
Subscription Schedules are used to wrap Subscriptions and allow you to schedule changes that will automatically be applied to the Subscription in the future.
But the Subscription is actually the indefinitely recurring object.
So what should I specify in iterations? Does 1 suffice?
Yup, 1 will work
Thank you very much!
While you're playing around with those, I'd also recommend using Test Clocks:
https://stripe.com/docs/billing/testing/test-clocks
They let you put customers and subscriptions inside of small sandboxes where you can advance time, so you can see exactly how those objects will behave throughout their lifecycle.
Ok I'll do that, thanks for that tip as well. But now that I have the subscription_schedule created, how do I create a subscription with that schedule?
You don't, that happens automatically.
Really? That's it? So I dont have to make a subscription.create call and attach the scheduler?
If that is the case, then I wont be able to get the subscription_id until the we have reached the start_date I guess?
Exactly, there won't be an active Subscription until the start_date (part of why starting with a Subscription from the beginning may be easier if you're planning to use the state of the Subscription to determine whether a customer should have access to your service)
Ahh ok I understand, thanks for the help Toby!
Happy to help!
Last thing, so it gives me an error on start_date, how should I pass currentdate + 1 month to that key in javascript? I thought it used UNIX time?
Yup, second-precise unix timestamp is right. What is the error?
This value must be less than or equal to 9999999999 (it currently is '1705941490000').
Ah, I think that's a millisecond-precise timestamp, can you try dividing by 1000?
Awesome! Any time!
Hey toby, I found an easier solution, I simply kept the billing_cycle_anchor to the same timestamp, and then added proration_behavior: 'none'
to subscriptions.create().
In the events it seems to be correct so far, are you aware of this solution?
Yup, but at that point, you're creating a Subscription up front, so I'd go back to suggesting you create a Subscription initially instead of a one-off Payment Intent followed by a Subscription.