Subscription Life Cycle
Stripe is used for subscription management.
All endpoints on the ecommerce side contact stripe.
Every app should have a subscription method.
In order to integrate the applications with stripe and start the default subscription, a request must be initiated during application login.
Migrate Endpoint
- Endpoint : subscriptions/apps//migrate
- Method : Post
- Response : NoContent
Every SaaS application has a classic package management. The following endpoints should be used to get packages and prices.
Package Endpoint
- Endpoint : subscriptions/products
- Method : Get
- Response;
{
"success": true,
"data": {
"object": "list",
"data": [
{
"id": "prod_MNTThIpbqw0ueX",
"object": "product",
"active": true,
"attributes": [],
"created": 1662396727,
"default_price": "price_1LeiWqIsizHclLZ4bgh9vG7L",
"images": [],
"livemode": false,
"metadata": {},
"name": "Free",
"tax_code": null,
"type": "service",
"updated": 1662396729
},
{
"id": "prod_MNTN7kywpGvAUd",
"object": "product",
"active": true,
"attributes": [],
"created": 1662396370,
"default_price": "price_1LeiR5IsizHclLZ4taOkgeor",
"images": [],
"livemode": false,
"metadata": {},
"name": "Eco",
"tax_code": null,
"type": "service",
"updated": 1662396372
},
{
"id": "prod_MJ0Kac7x7dgcTh",
"object": "product",
"active": false,
"attributes": [],
"created": 1661365742,
"default_price": "price_1LaOK2IsizHclLZ4OyZcU5ue",
"images": [],
"livemode": false,
"metadata": {
"coupon_Active": "false",
"product_Limit": "5000"
},
"name": "Business",
"tax_code": null,
"type": "service",
"updated": 1662396657
}
],
"has_more": false,
"url": "/v1/products"
}
}
Note Products with active:true should be displayed on the client side.
Price of Package Endpoint
- Endpoint : /subscriptions/products//prices
- Method : Get
- Response;
{
"success": true,
"data": {
"object": "search_result",
"data": [
{
"id": "price_1LeiR5IsizHclLZ4cTJuDQqp",
"object": "price",
"active": true,
"billing_scheme": "per_unit",
"created": 1662396371,
"currency": "usd",
"currency_options": {
"try": {
"tax_behavior": "unspecified",
"unit_amount": 180000,
"unit_amount_decimal": 180000
},
"usd": {
"tax_behavior": "unspecified",
"unit_amount": 10000,
"unit_amount_decimal": 10000
}
},
"livemode": false,
"metadata": {},
"product": "prod_MNTN7kywpGvAUd",
"recurring": {
"interval": "year",
"interval_count": 1,
"usage_type": "licensed"
},
"tax_behavior": "unspecified",
"type": "recurring",
"unit_amount": 10000,
"unit_amount_decimal": 10000
},
{
"id": "price_1LeiR5IsizHclLZ4taOkgeor",
"object": "price",
"active": true,
"billing_scheme": "per_unit",
"created": 1662396371,
"currency": "usd",
"currency_options": {
"try": {
"tax_behavior": "unspecified",
"unit_amount": 18000,
"unit_amount_decimal": 18000
},
"usd": {
"tax_behavior": "unspecified",
"unit_amount": 1000,
"unit_amount_decimal": 1000
}
},
"livemode": false,
"metadata": {},
"product": "prod_MNTN7kywpGvAUd",
"recurring": {
"interval": "month",
"interval_count": 1,
"usage_type": "licensed"
},
"tax_behavior": "unspecified",
"type": "recurring",
"unit_amount": 1000,
"unit_amount_decimal": 1000
}
],
"has_more": false,
"url": "/v1/prices/search"
}
}
Note Variables such as Amount or price should be displayed correctly with some operations on the client side.
For example;
The value of 1000 should be set to 10.00. The value 100000 should be set to 1000.00.
That is, two digits should be separated from the end backwards.
Pay
The /pay endpoint should be used when the user wants to start a subscription to any of the packages. This endpoint returns a payment url as a response. The user should be redirected to this urly.
- Endpoint : subscriptions/apps//pay
- Method : Post
- Request Payload;
[
{
"price": "{The_id_of_the_pricing_method_chosen_by_the_user}",
"quantity": 1
}
]
- Response;
{
"success": true,
"data": "https://checkout.stripe.com/pay/cs_test_a1Aae48sl6a0prICeIwKZeNmCRu3uLknSlSSqP3v6L09ISQqWgZbjMaWhk#fidkdWxOYHwnPyd1blpxYHZxWjA0TnA0RH1Mdmx%2FTWZpSV8xN3VvYWpsdDNITT18cDBSaEZqX249ajE0S2FBaVJBcGhjVXRJakhAZzRkajBsa01ub28yTkZ3VktqXGZzbUpLMG9RQEhIckZ3NTVDPTBRQGIyNScpJ2N3amhWYHdzYHcnP3F3cGApJ2lkfGpwcVF8dWAnPyd2bGtiaWBabHFgaCcpJ2BrZGdpYFVpZGZgbWppYWB3dic%2FcXdwYHgl"
}
Subscription of App
Use the following endpoint to get the package information the application has.
- Endpoint : subscriptions/apps/
- Method : GET
- Response;
{
"success": true,~~~~
"data": [
"Eco"
]
}
Permission of Package
A package-based permission can be defined. Applications can operate package limitations with these permissions. Use the following endpoint to get these limitations.
- Endpoint : subscriptions/apps//permissions
- Method : GET
- Response;
{
"success": true,
"data": {
"category_Active": "true",
"coupon_Active": "false",
"product_Limit": "1000"
}
}
Get Card
For now each app can be a card. For card of app will be use GetCard endpoint.
Endpoint : subscriptions/apps//cards Method : Get
Empty Result
{
"success": true,
"data": {},
"message": "Data is empty"
}
If app have card
{
"success": true,
"data": {
"email": "furkanappsumo1@furkan.com",
"creditCard": "4242",
"brand": "visa",
"expMonth": 9,
"expYear": 2026
}
}
Note : Card number show last4 digit
Set Card
Each application can have a card.
To add a card the following items are required.
These items;
- Card Number
- Cvc
- ExpMonth
- ExpYear
Sample Request
Endpoint : subscriptions/apps//cards Method : POST
{
"card": "4242424242424242",
"expMonth": 9,
"expYear": 2026,
"cvc" : "313"
}
Response
{
"success": true,
"data": {
"email": "furkanappsumo1@furkan.com",
"creditCard": "4242",
"brand": "visa",
"expMonth": 9,
"expYear": 2026
}
}
Note : This endpoint execute add or update scenario.
Note : This endpoint execute add or update scenario but update scenario contains the following items;
- ExpMonth
- ExpYear
other fields not included update scenario.
Delete Card
When users set to wrong card information this card can be delete.
Endpoint : subscriptions/apps//cards Method : DELETE
This endpoint return NoContentResult(204)