I'm designing a subscription framework for my application. The subscription is based on "credits". Each month, any subscribed user will receive x amount of credits depending on their plan. They will receive the credits upon payment for that month's invoice.
These are my tables:
account(id,name, credits, plan)
plan(id,name,credits per month, cost per month)
invoices(name, account id, paid/unpaid, credits given, plan at the time)
Okay so with this setup I will run a daily cron job to send out invoices for the month. When people come to the website to pay the invoice, upon payment the invoice status is set to paid, and then the credits are then added to their account, and updated in the invoices table.
I suspect this would work alright for a monthly plan, however, I want to give them the option of paying for 6 months or a year. In that case, what do you recommend I do to allow them to pay upfront but credit them each month?
Does anyone have suitable examples or tutorials on similar subscription services - something that would guide me on the best way to build it?
I'd also take suggestions for improvements or warnings of common pitfalls with my method.
Thanks
Jason
Notes: LAMP Setup.
I haven't worked with these guys http://recurly.com/ but I saw a presentation from one of the founders and looks like they implemented all the features you are looking for and more.