Set end date when setting up Stripe subscription

Tyler McGinnis picture Tyler McGinnis · Aug 5, 2014 · Viewed 13.2k times · Source

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?

Answer

Larry Ullman picture Larry Ullman · Aug 5, 2014

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.