I have a subscription system on my project and everything works fine, but one thing is confusing me. Right now the user is selecting a plan and choosing his billing cycle that would be OK for him. I'm storing this data in my database as a relationship between plans table, users table and a third table that is containing setup information for the account - things like the billing cycle I was talking about and more stuff. Everything works fine but Stripe requires the plans (products) to be created from their dashboard and stored manually in my database. My question is when I have for example 3 plans with 3 billing cycles - monthly, 6months, yearly how do I store them in my database so I don't create a new row for each billing cycle. Visualization of what I wanted to say:
My question is when I have for example 3 plans with 3 billing cycles - monthly, 6months, yearly how do I store them in my database so I don't create a new row for each billing cycle.
@crypt.001111101 Why? They are individual plans though. They’ll have their own record in Stripe. So store them as such.
@martinbean Because the table is specified to store the available plans that users can choose from, and the billing cycle they have chosen is recorded in a separate table. My idea is to somehow combine these 2 things as I have done at the moment and take from them the necessary product_id from Stripe. But I still need to store these product_ids somewhere so I'll probably create another table with relationship to the plans table and I'll store the product_id and billing cycle from Stripe inside.
@crypt.001111101 You need to store the two models. A product defines something a customer can subscribe to, and then a plan (price) determines the amount and interval (monthly, 6-monthly, yearly, etc).