vercel / nextjs-subscription-payments

Clone, deploy, and fully customize a SaaS subscription application with Next.js.
https://subscription-payments.vercel.app/
MIT License
6.08k stars 1.23k forks source link

How does the subscription status change after the `current_period` ends? #163

Closed TimDev9492 closed 1 year ago

TimDev9492 commented 1 year ago

In the database subscriptions, every row has a property status that's used to query the currently active plans on the /account page. When you cancel a subscription through Stripe, the status doesn't get updated. Instead, the cancel_at_period_end property of the database entry in subscriptions gets changed to true. I was wondering if the status property changes "automatically" after the current_period_end date or if I have to implement that logic myself.

thorwebdev commented 1 year ago

The status is automatically updated via the webhook: https://github.com/vercel/nextjs-subscription-payments/blob/main/pages/api/webhooks.ts#L65-L89