Link to home
Start Free TrialLog in
Avatar of Member_2_8205939
Member_2_8205939

asked on

Stripe subscription handling

Hello,
I am working on the Stripe integration for the subscription based service. So far, after the successful payment (either monthly or annual based defined in Stripe plans), I handle checkout.session.complete event and out of that data create in local database subscription for the user. That part is working fine.
However, what would be best approach for checking the subscription statuses? In case of the hundreds of users, it seems that cron job that will fetch them daily and test the expiration date doesn't sound very efficient.

I was wondering if setting up a webhook that will listen to invoice.upcoming, invoice.payment_succeeded and incomplete_expired (and effectively canceling user subscription) would be a better option, but considering that I have very little experience in the life cycles of subscriptions, I am not sure. (not trying to create XY Problem here, just trying to explain)

Basically, my question is, what would be the best option to check Stripe subscription statuses and according to the responses handle local subscriptions?
Avatar of lenamtl
lenamtl
Flag of Canada image

Hi,

That may depend of the service you offering...
That should be mentioned when the subscription will end with the timezone that will be used, when user set an account.
 I would check for expiration during the night let say at 1 am and if expired it set the user account to expired, so when user will login he will be aware that the account is expire and you can offer to renew.

If it's end to a specific time then you will need a cron job that run let's say every hour or every half hour.

You can also set renewal email using a cron job one month before the subscription end as a remember and mention what will happen with the user account.
Let say limited access to specific features , no longer access and you may want to specify what will happen to data if any etc..

You should save the expiration date to your DB in the user account  and if expired then check to see if Stripe is still renewed or not, this all depend on how your application is set.
This can reduce the calls..
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.