I'm facing a challenge with my SaaS app regarding credit resets for yearly subscriptions using Stripe. Typically, when a user on a monthly plan pays their invoice, I reset their credits — for example, they get 500 AI task executions per month, so I reset it to 500 with each `invoice.paid` event.
However, for yearly subscribers, Stripe only sends that payment event once a year, which complicates things. I could give users a lump sum of 6000 credits upfront for the year, but I'm concerned that a user might use more than 500 credits in a single month, which could lead to abuse.
I'm considering using a cron job to reset credits every month for those on the yearly plan. Is there a better or more efficient way to manage this? Also, if anyone knows of good open-source SaaS projects with similar payment setups, I'd love to check out their code. I've found one project, cal[.]com, but they don't have yearly plans.
3 Answers
It might be beneficial to keep track of credits paid, credits issued, and credits consumed separately. While cron jobs are a valid approach, they do carry a risk if something goes wrong with them. As long as you maintain accurate records of all relevant data, and ensure your cron jobs have a solid retry mechanism, you should be fine.
I've managed both yearly and monthly credits using cron jobs for the annual ones while utilizing Stripe's webhook events for monthly subscriptions. I just reset credits for yearly users each month to keep it balanced.
I’m curious about this too! It’s definitely a tricky situation.
Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically