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:
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.
If we have a few products, we should create and manage them via Dashboard.
Let's start creating product in
test mode via Dashboard:
Enter the product details along with
Monthly standard plan pricing details as
shown below and save them:
Now, let's see how we can add
Yearly standard plan pricing in the
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.
Enter the pricing details as shown below and save them:
Monthly pro plan and
Year pro plan pricing in the
follow the same steps as mentioned above.
After creating the product and prices successfully in Stripe, store the
price IDs for later use. We can get it by navigating to the
product page in Stripe Dashboard as shown below:
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
Now, let's see how we can send a
POST request to create a
product with name
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
create price API with the product
prod_JJex2jDvjE1FT5, price amount as
1900, currency as
usd, and billing
or recurring period as
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"