I'm trying to figure out the best way to keep track of whether my users are on a paid subscription or using the free version. I've got users signed up through Stripe or a similar payment processor, but I want to make sure I document their subscription status without holding onto any sensitive financial details. Should I host my own database with regular backups, or would it be better to use a third-party database service? Also, what kind of disaster recovery strategies do you recommend? I'm concerned about losing data, especially if a crash occurs right after someone pays for a subscription.
5 Answers
You'll definitely want to store a 'subscribed' boolean flag alongside the user's info in your database. It's a straightforward approach and makes it easy to query their subscription status. Just keep in mind that this isn’t foolproof, since any database can crash. Having a backup system in place helps mitigate the risk.
One solid approach is to use two or more databases in a read/write configuration. If one goes down, the other can take over. It’s like having a backup kidney – you just need to ensure regular backups to avoid data loss.
Creating a database entry for payments with all relevant details (like time and amount) is smart. Plus, using a managed database service often provides continuous backups, which is great for quick recovery in case something goes wrong.
If you're comfortable with AWS, consider using DynamoDB – they handle backups nicely and it'll save you some headaches. It's also scalable, which is a plus.
Storing tokens in your database is key, and make sure to back them up daily. Also, keep transaction records with your payment processor like Stripe. If your system fails, you can at least retrieve payment information from there.
Yeah, I think using an enum for subscription status is more modern and flexible. It can represent various states like 'free', 'paid', or even 'trial'. Just makes querying even easier.