In my application users are subscribed (and billed) each month for 24 months. Is there any way to have Stripe automatically end the subscription after the 24th month when I initially create the subscription?
3 Answers
What you describe is possible in Stripe, but not as an out-of-the-box solution (as of August 2014). You'll need a little bit of programming logic on your end, too.
First, you'll need to have a web hooks endpoint:
https://stripe.com/docs/webhooks
Next, you'll want to subscribe the customer to a plan like normal. We'll notify your site, via the web hooks, of when payments are made on a recurring subscription. Specifically, you'll want to watch for invoice.payment_succeeded
events:
https://stripe.com/docs/api#event_types
Once a specific customer has hit the right number of payments (which you'll track on your end), you'd then issue a cancel subscription request:
https://stripe.com/docs/api#cancel_subscription
Hope that helps! Larry
PS I work on Support at Stripe.

- 2,161
- 18
- 10
-
6Larry, really appreciate the answer. I'm a huge fan or your books and your blog. – Tyler McGinnis Aug 05 '14 at 16:39
-
Thanks, Tyler! Nice of you to say. – Larry Ullman Aug 14 '14 at 15:53
-
1Out of interest, are there any plans to pull this into the stripe dashboard out of the box? Along with the "trial ends" and "coupon" fields etc. when adding a subscription. A 'no. of payments', or 'end date' would be very useful. I'm currently using the API as you describe which is great but for those whose online payment has failed we do it over the phone in stripe itself. – kimberley_p Feb 02 '15 at 14:13
-
Good question! It is something we discuss supporting directly, in the API at first and then later via the Dashboard. There's no set plan or timeline for it, however. – Larry Ullman Feb 19 '15 at 01:58
-
7The problem with this solution is that it doesn't guarantee that the customer will not be overcharged. If the webhook service goes down or has any other problems the subscription will not get cancelled. I know how to make a webhook, but I'm not comfortable with hacking something together that's difficult to test and could possibly result in a customer being overcharged. – Ben Davis Nov 10 '15 at 19:29
-
Is it still not possible to set an end date? – user754730 Nov 23 '15 at 11:03
-
2@BenDavis Although not built in, you could also set an end data field against your user, and have a scheduled task checking expired users each night. It would be nice if it happened within Stripe, but I am guessing there is other business logic that your app has to respond to on your end too - sending a "sorry to see you go email", etc, etc. In which case, you would need to respond to either a stripe webhook or have your own schedule anyway. – Chris Dec 12 '15 at 09:27
-
10I can't believe how many hours I've spent trying to figure out how to schedule future Stripe payments (but not with an unending subscription). I really wish Stripe would allow something like "2 months from now, charge this card $400 on the 25th of each month lasting for 4 months and then stop." I'd think Stripe would offer this functionality. And I can't even find a 3rd party tool to do it either! I REALLY don't want to try to build my own. I want to focus on my business. – Ryan Jun 30 '16 at 16:34
-
1Hi @LarryUllman - Is it still not possible to do this? Could you push for this in Stripe? If you guys have no plan of implementing this in the near future we will have to implement the logic you mentioned in our code. – David Dehghan Oct 25 '16 at 21:27
-
I'd like to have all my subscriptions renew at a specific calendar date (Oct 1st). Is it possible to define the end_date for a subscription? – damienbrz Dec 20 '16 at 23:19
-
1Setting up specific dates for charges can be achieved using trial periods in a subscription. You can set it up for a random number of days and charges will start after that. You can also end the trial period prematurely in order to create "aproval processes". You can also add trial periods in a currently running subscription. – Matías Halles Jun 05 '17 at 23:52
-
Just curious, cant we use stripe schedule methods and give end_behaviour as cancel. This will cancel the subscription once all schedule. What is the difference? – jones May 13 '20 at 12:43
2020 Update
It is possible by setting up "cancel_at" date when creating subscription. More info Create a subscription with Stripe

- 2,137
- 23
- 24
Ya it can be done simply by passing "cancel_at_period_end" is true while creating subscription . Then subscription will automatically get cancelled on subscription end date

- 21
-
-
3That [parameter](https://stripe.com/docs/api#update_subscription-cancel_at_period_end) causes the subscription to be cancelled at the end of the current billing cycle(i.e. if it's a monthly subscription and you call it mid-month, the subscription will stay active for the rest of the month instead of being immediately cancelled when you call the API). It's not the same thing as setting an explicit end date for the subscription. – karllekko Aug 28 '18 at 20:50