Subscriptions
POST /subscriptions/subscribe
Generates subscription for customer and returns a link to checkout session where user can review payment details, provides payment information, and purchase a subscription.
Body params -
Parameter | type | Description |
---|---|---|
priceId | string | Id of the price for subscription |
Returns checkoutLink
url with checkout form.
Stripe call snippet -
Parameters description -
Parameter | type | Description |
---|---|---|
mode | string | The mode of the Checkout Session. For subscription it should be set to subscription |
customer | string | id of the stripe customer. if undefined , stripe will ask for the user’s email and create a new customer upon purchasing |
line_items | array | Array with information about items that will be included in checkout session |
|
|
|
success_url | string | The URL to which Stripe should send customers when payment or setup is complete |
cancel_url | string | The URL the customer will be directed to if they decide to cancel payment and return to your website |
More information about stripe checkout object - link
POST /subscriptions/cancel-subscription
Cancels prolongation of a customer’s subscription. The customer will not be charged again for the subscription.
Stripe call snippet -
Parameters description -
Parameter | type | Description |
---|---|---|
customer | string | id of the stripe customer |
cancel_at_period_end | boolean | Indicating whether this subscription should cancel at the end of the current period. |
More information about subscription update - link
POST /subscriptions/upgrade
Changes customer’s subscription plan (billing period or subscription plan)
Body params -
Parameter | type | Description |
---|---|---|
priceId | string | Id of the price for subscription |
Stripe call snippet -
Parameters description -
Parameter | type | Description |
---|---|---|
subscriptionId | string | id of the customer’s active subscription |
proration_behavior | string | Determines how to handle prorations when the billing cycle changes (switching plan in this case). parameter Always_invoice is used to charge the customer immediately |
cancel_at_period_end | string | Boolean indicating whether this subscription should cancel at the end of the current period. |
items | array | array with information about subscription items |
|
|
|
More information about subscription update - link
GET /subscriptions/current
Returns detailes subscription information along with pending invoice
Stripe call snippet -
Parameter | type | Description |
---|---|---|
productId | string | id of the product (subscription) |
More information about products - link
Parameter | type | Description |
---|---|---|
subscription | string | id of the customer’s active subscription |
More information about invoices - link
GET /subscriptions/preview-upgrade
Returns invoice with billing information of subscription upgrade/downgrade
Query params -
Parameter | type | Description |
---|---|---|
priceId | string | Id of the price for subscription |
Returns invoice with payment details
Code snippet -
Parameters description -
Parameter | type | Description |
---|---|---|
customer | string | id of the stripe customer |
subscription | string | id of customer’s active subscription |
subscription_proration_behavior | string | Determines how to handle prorations when the billing cycle changes (e.g., when switching plans, resetting billing_cycle_anchor=now, or starting a trial), or if an item’s quantity changes. |
subscription_items | array | array with information about subscription items |
|
|
|
In case the customer chooses free plan, we need to send a custom price object to stripe with unit_amount set to 0 in order to receive invoice with empty products and information about a refund for canceled subscription
Price data parameters -
Parameter | type | Description |
---|---|---|
currency | string | Three-letter ISO currency code, in lowercase. |
product | string | id of subscription product |
recurring | object | The recurring components of a price such as interval and interval_count |
|
|
|
unit_amount | number | A positive integer in cents (or 0 for a free price) representing how much to charge. |
More information about previewing upcoming invoices - link