Handling Stripe Subscriptions

Modelling our product and prices in Stripe

Modelling our product and prices in Stripe

Let's say, we have an application called FitifyMe, and we have a product called FitDiet which includes customized meal plans and exercises. We want to sell following subscription plans to customers:

  • Monthly standard plan worth $19
  • Monthly pro plan worth $39
  • Yearly standard plan worth $190
  • Yearly pro plan worth $390

To model the above subscription plans in Stripe we will first need to create a product. Each product can have multiple prices that track how much and how often we want to charge a customer. Products and prices are the primary entities used to model subscriptions.

Let's see how we can create a product in Stripe.

Creating a product

We can create a product and prices in Stripe via Dashboard or Product API. For our application, we will need to create a single product with 4 different prices in Stripe.

If we have a few products, we should create and manage them via Dashboard.

Let's start creating product in test mode via Dashboard:

Log into stripe Dashboard. Then, navigate to products page and click on the Add a test product or Add product button.


Enter the product details along with Monthly standard plan pricing details as shown below and save them:

Create a product

Now, let's see how we can add Yearly standard plan pricing in the FitDiet product.

Creating prices

Like products, we can also create prices via Dashboard or Prices API

Let's navigate to the products dashboard and click on the FitDiet product. Now, to add a new price, click on the Add another price button.

Add a price

Enter the pricing details as shown below and save them:

Create a price

To add Monthly pro plan and Year pro plan pricing in the FitDiet product follow the same steps as mentioned above.

After creating the product and prices successfully in Stripe, store the product and price IDs for later use. We can get it by navigating to the product page in Stripe Dashboard as shown below:

Product Details

Creating a product and prices via Stripe API

Before diving deep, we will need to get Stripe's API key or Secret Key from the Stripe Dashboard. For example, our account has API key or Secret Key with value sk_test_51IUPamDdkrcdQOlhs2b...VV2OQeFjRe1004Oahe9N3.

Now, let's see how we can send a POST request to create a product with name FitDiet and active status.

1$ curl https://api.stripe.com/v1/products \
2> -u sk_test_51IUPamDdkrcdQOlhs2b...VV2OQeFjRe1004Oahe9N3: \
3> -d "name"="FitDiet" \
4> -d "active"="true"

Once the product is created successfully, copy product ID like prod_JJex2jDvjE1FT5 from the above API response. After this, we will create a Monthly standard plan of price $19 via create price API with the product as prod_JJex2jDvjE1FT5, price amount as 1900, currency as usd, and billing or recurring period as month.

1$ curl https://api.stripe.com/v1/prices \
2> -u sk_test_51IUPamDdkrcdQOlhs2b...VV2OQeFjRe1004Oahe9N3: \
3> -d "product"="prod_JJex2jDvjE1FT5" \
4> -d "unit_amount"=1900 \
5> -d "currency"="usd" \
6> -d "recurring[interval]=month"
    to navigateEnterto select Escto close