Reputation: 868
Hey I am new to express.js and these days I am working on a project. its like a shop owner created a shop with different plans, each plan has different price, what I want is that, when user pay for that plan then only he will get subscription, how can i do this using express.js, MongoDB and a payment gateway, can anyone help please.
Upvotes: 0
Views: 1566
Reputation: 7419
I suggest reading how Stripe subscriptions work and then working through the end to end guide to creating subscriptions, making sure you select the "Node" code snippet tab. The underlying database is up to you, anything will work.
Upvotes: 1
Reputation: 970
I would suggest having 2 collections for this.
The first one is a users
collection where you will save the user information (id, username, encrypted password, etc.).
The second collection will be a payments
collection which will have the plan, the id of the user that paid for it and the time it was paid.
Then in order to check the active subscriptions, all you need to do is query all the payments the user paid in the last month (if the subscriptions are monthly) and check what plans they paid for.
This way you will be able to check when they need to pay again (a month after the paid time) and what plan they paid for.
Upvotes: 2