I am moving from Credits-based billing system to Subscription-based billing system. Till now, I used to check the number of credits a user had and based on that; I used to E-mail user whether the renewal has been done or not. In the event of a first purchase, I used to activate a plan that user has selected.
I am now shifting to the subscription-based billing system in which I will store subscriptions with validity
and I want to eliminate the credits part from the root. Here is the database schema for my new billing system. The issue with this schema is I can't process first purchase event as there is no solid way to know if a user is purchasing for the first time and if a user has paid the full amount or not. I am getting confused at each and every step of the change.
Let me explain what issue I am facing. While the transaction is being processed, the is_active
flag in subscriptions
remains null
which means a user can't perform any action on my software. But when a transaction is processed, User will return to my website and my website will mark the transaction paid
which means a user has paid but as there is no connection between transactions and subscriptions, How would I know when to mark a subscription paid. In TransactionController, Transactions will be processed and in SubscriptionController, Subscription will be processed.
I haven't created the connection between subscription and transaction because in that case, I'll have to allow nullable foreign keys
in a transaction because transactions can be for extra services too!
I am getting more confused by thinking more about it. I don't know what's the issue here but I know there is some issue with database design. Any help is appreciated!