Handling Stripe Subscriptions

Modelling our product and prices in Stripe

Modelling our product and prices in Stripe

Let's say we have a product called FitDiet which includes customized meal plans and exercises. We want to sell following subscription plans to our 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. Because of the way Stripe works we will create a single product called "FitDiet" and this single product will have four pricing plans.

Creating a product

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

Log into stripe Dashboard. Then click products link 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: Here we will enter the product name and product description and we will also provide information about the first pricing plan which is "Standard pricing" of $19 per month.

Create a product

Next we will add Yearly standard plan. 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

If we want to create products and prices using API then we need Stripe API key or Secret Key from the Stripe Dashboard. For our case the API key is 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 the response will contain product ID. For our case the product ID is prod_JJex2jDvjE1FT5. Now we will create a Monthly standard plan of price $19 via create price API.

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