lundi 23 février 2015

Architecture tip on how to deal with Premium accounts, plan duration and renewal

I'm creating a website which has a premium user feature. I'm thinking on how to design the database to store the premium user plan, and how to check it..


My main idea so far is:



  • Having 2 fields on the user table: premium (boolean) and expires (date)

  • When user does payment, it will calculate the plan duration, set premium to 1, and the expire date to the end of the duration

  • Every time I check if user->isPremium(), it will also check if it's expired.. if so, set it back to zero and offer a renewal

  • Aside from this, all payments /transactions will be recorded in a logs table for record keeping.


This is a simple design I thought, but since this is a common feature on many websites, I thought of asking you guys.. how do the pros do this?


This probably won't make much difference on the design but I'll use Stripe for handling payments.


Aucun commentaire:

Enregistrer un commentaire