Hey There,
This tutorial will take you step-by-step through building a fully functional subscription-based platform. Along the way, you’ll learn about Express.js a web application framework for Node.js.
What we are building.
We want to build a subscription-based platform, where customers will need to subscribe to one of our plans to access our content some of our plans include Weekly, monthly plans.
This article will be broken into Modules.
1:Overview of dependencies, project setup, and server setups.
2:Authentication
3:Cron job setup
Main Dependencies
1:Nodejs must be installed
2:MongoDB database
3:Momentjs
4:node-cron
5:v-response
So guy's let get our hands dirty
Server.js file
Where we will be starting our development server,
On a successful server setup in your console, you should have
this logged.
Now let's create our plan model file
Now let's create our plan controller file
Now let's create our plan route file
Now we need to create our helper file for payment and calculating user next payment date
Now let's create our Signup model file
Now let's create our Signup controller file where we will write our logic to register a user as well as charge the user
for the payment, we will be using paystack but feel free to use any payment gateway.
So we need to configure our login to only allow subscribed users
At this point, we need to set up a cron job to deactivate account once the subscription ends
Other Features that can be added to this includes but not limited to :
Auto-renewal
Notification
And if you will like to Have this in part two of this article do let me know in the comment section
Top comments (7)
When you do
You can just do
This will help avoid deeply nested condition ie if (condition1) { if (condition2) { ...
Nice one by the way 👍
Thanks
Really good read bro..Very nice I must say. thanks for the insight
Thanks man good to know it's helped
thanks
well done! bro nice read
Nice, Thanks a lot bro this one really helped me out.