Adding, Managing, and Keeping track of Subscription Payments using Stripe and Mongo

Languages | Tools Used | Time Saved

Node.js, HTML Stripe, Mongo 3 weeks → 40 mins


Every SaaS app needs subscription payments - a recurring payment. Users need to be able to change or cancel their plans, go through a trial phase to see if they even would like to pay for premium features.

What we will be building:

  1. Subscribe to the Trial Period of a paid plan
  2. Have multiple options of paid plan - Basic and Pro
  3. Allow users to upgrade and/or cancel their current plans
  4. Access access to premium content based on the plan type

Stripe does a great job of managing resources: Subscriptions, Customers, Payments, Invoices but the responsibility of keeping the users' information up-to-date falls on the application itself.

Clone the project

git clone 

Rename the .env.example to .env. We will replace the variables in the file one-by-one.

Set up Stripe

Create a new Stripe account here.

Add a name for your account by clicking the `Add a name` button on the top left.


Copy Secret Key under Developers > API Keys and paste in .env file as the STRIPE_SECRET_KEY.

Add products: Basic and Pro

Add a new product by clicking on the `Product` button on the left side. Call the first one, Product – Basic. Set the Pricing to $10.00 CAD and `Recurring`. Set the Billing period to `Monthly`.


Copy the Price API ID and assign it to PRODUCT_BASIC in the .env file.

Repeat the process above for Product – Pro at $12.00 CAD, `Recurring`, and `Monthly`.

Copy the Price API ID and assign it to PRODUCT_PRO in the .env file.

Set a Trial Period with the TRIAL_DAYS in the .env file.

Start the MongoDB

Install MongoDB Community Edition from here. Run it by using,


The Mongo Server will start running at mongodb://localhost: 27017. We will use the `users` collection to save the customer information.

If you have an external Mongo server running, replace the default connection string referenced in the MONGODB in .env file.

Set up the Stripe Webhook

Download Stripe CLI.

stripe listen --forward-to localhost:4242/webhook

Copy the webhook secret and assign it to STRIPE_WEBHOOK_SECRET in .env file.


npm start