Create subscription with Add-Ons
A subscription can optionally be created with a number of subscription Add-Ons. In this case, we create a subscription for an existing customer by using the parameter customer
. A subscription and customer can also be created in one atomic call by using the parameter create_customer
.
To create subscription, Add-Ons for a subscription a number of Create subscription with Add-Ons objects must be provided.
Please find an example below:
curl -X POST "https://api.reepay.com/v1/subscription" -u "priv_dbd002cf1313cb4213efcfb3afebfb66:" \
-H "Accept: application/json" -H "Content-Type: application/json" -d \
'{
"handle": "leasing_00425",
"plan": "leasing_gold",
"signup_method": "email",
"customer": "cust-0059",
"add_ons": [
{
"add_on": "super_laptop_x2",
"handle": "sn764654216"
},
{
"add_on": "extended_laptop_support",
"quantity": 1
}
]
}'
Response:
{
"handle": "leasing_00425",
"customer": "cust-0059",
"plan": "leasing_gold",
"state": "active",
...,
"subscription_add_ons": [
"sn764654216",
"extended_laptop_support"
]
}
When creating a subscription Add-On, the following can be defined:
- Add_On: · The Add-On for this subscription Add-On.
- Handle: · This is an optional reference that can be provided if a reference to the specific subscription Add-On is required. In this use-case, the laptop serial number is used, as this allows looking up subscriptions involving the specific laptop. If no handle is provided, the Add-On handle is used. As a
handle
must be unique, this means that only one instance of each Add-On can be attached to a subscription, in the case a custom handle is not provided. - Quantity: · For
quantity
type Add-Ons, it is possible to define a quantity of the Add-On for the subscription. The default is 1. - Fixed_amount: · By default, the subscription Add-On has a fixed amount. This means that the amount is defined for the subscription Add-On at creation, either by the Add-On amount or using the
amount
parameter to define a custom fixed amount.
If the amount on the Add-On is changed later, it does not affect the subscription Add-Ons tied to this Add-On.
Iffixed_amount
is set tofalse
, the pricing for the subscription add-on follows the Add-On amount. This can be used in a consumable scenario where the price for the subscription add-on is the price of the add-on at billing time.
Updated 9 months ago