[API GUIDE] Combine a Usage Data Upgrade with an Early Custom Price Renewal
Overview
This guide shows you how to implement the Update Subscription Item API endpoint to upgrade and renew the customer's subscription immediately.
Use case
-
The customer reaches the data limit of their current Cloudify plan.
-
Cloudify offers an upgrade with an early renewal at a custom price, and the customer accepts after reviewing the updated subscription details.
-
Cloudify uses the Update Subscription Item API endpoint to upgrade and renew the subscription immediately.
Result:
The new billing interval starts right away, and the customer regains access on the upgraded plan.
Implement Update Subscription Item
Before you start
ImportantGet the customer's consent before making changes to a subscription.
To avoid chargebacks and customer inquiries, it is also essential that you coordinate all price increases with Client Experience.
In the European Economic Area (EEA), Strong Customer Authentication (SCA) is required for recurring electronic payments when the amount changes. This means that some of your customers will have to authenticate their payment, which in turn might impact the renewal success rate.
For more information, see Best Practices: Obtain Customer Consent.
Make sure that:
- The current billing interval has started and the next billing date has not been reached yet.
- Any changes made, including the price and/or quantity, apply to all future billing events unless modified later.
- The renewal is not combined with an alignment of the subscription.
- The
AlignmentSettingsparameter for the subscription in the API response is required.
Before doing so, see Get Started with Subscriptions > Alignment Settings.
Parameters
Parameter | Type | Required | Example | Notes |
|---|---|---|---|---|
AlignmentSettings | obj | Yes |
| The subscription is changed as requested in the API call. |
CustomerPrice | obj | Yes |
| Pricing information shown to the customer during checkout. |
ProductId | int | Yes | 293103 | Product ID of the subscription item. |
RunningNumber | int | Yes | 1 | Running number of the item in the subscription. |
Quantity | int | Yes | 1 | Total number of items after the update. |
SubscriptionId | str | Yes | S67632293 | The unique identifier of the subscription. |
UpdateAction | str | No | upgrade | The value set does not affect transaction processing. |
NoteThe
UpdateActionparameter is currently used for documentation and tracking only. The value set does not affect transaction processing.The supported values are as follows:
- For upgrades, set the parameter to
upgrade(or 1 for JSON)- For downgrades, set the parameter to
downgrade, (or 2 for JSON)- For all other changes, set the parameter to
update(or 0 for JSON)
Request
curl --location 'https://rest.cleverbridge.com/subscription/updatesubscriptionitem' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Basic YOUR_BASE64_ENCODED_CREDENTIALS' \
--data '{
"ProductId": 293103,
"Quantity": 1,
"RunningNumber": 1,
"SubscriptionId": "S67632293",
"UpdateAction": "Update",
"AlignmentSettings": {
"AlignToCurrentInterval": false,
"GetCustomerPricePreviewOnly": false
},
"CustomerPrice": {
"CurrencyId": "USD",
"IsGross": true,
"Value": 70.00
}
}'import http.client
import json
conn = http.client.HTTPSConnection("rest.cleverbridge.com")
payload = json.dumps({
"ProductId": 293103,
"Quantity": 1,
"RunningNumber": 1,
"SubscriptionId": "S67632293",
"UpdateAction": "Update",
"AlignmentSettings": {
"AlignToCurrentInterval": False,
"GetCustomerPricePreviewOnly": False
},
"CustomerPrice": {
"CurrencyId": "USD",
"IsGross": True,
"Value": 70
}
})
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Basic YOUR_BASE64_ENCODED_CREDENTIALS',
}
conn.request("POST", "/subscription/updatesubscriptionitem", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))import http.client
import json
conn = http.client.HTTPSConnection("rest.cleverbridge.com")
payload = json.dumps({
"ProductId": 293103,
"Quantity": 1,
"RunningNumber": 1,
"SubscriptionId": "S67632293",
"UpdateAction": "Update",
"AlignmentSettings": {
"AlignToCurrentInterval": False,
"GetCustomerPricePreviewOnly": False
},
"CustomerPrice": {
"CurrencyId": "USD",
"IsGross": True,
"Value": 70
}
})
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Basic YOUR_BASE64_ENCODED_CREDENTIALS',
}
conn.request("POST", "/subscription/updatesubscriptionitem", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.post("https://rest.cleverbridge.com/subscription/updatesubscriptionitem")
.header("Content-Type", "application/json")
.header("Accept", "application/json")
.header("Authorization", "Basic YOUR_BASE64_ENCODED_CREDENTIALS")
.body("{\n \"ProductId\": 293103,\n \"Quantity\": 1,\n \"RunningNumber\": 1,\n \"SubscriptionId\": \"S67632293\",\n \"UpdateAction\": \"Update\",\n \"AlignmentSettings\": {\n \"AlignToCurrentInterval\": false,\n \"GetCustomerPricePreviewOnly\": false\n },\n \"CustomerPrice\": {\n \"CurrencyId\": \"USD\",\n \"IsGross\": true,\n \"Value\": 70.00\n }\n}")
.asString();
JSON body
{
"ProductId": 293103,
"Quantity": 1,
"RunningNumber": 1,
"SubscriptionId": "S67632293",
"UpdateAction": "Update",
"AlignmentSettings": {
"AlignToCurrentInterval": false,
"GetCustomerPricePreviewOnly": false
},
"CustomerPrice": {
"CurrencyId": "USD",
"IsGross": true,
"Value": 70.00
}
}Response
{
"AlignmentCustomerGrossPrice": 0.0,
"AlignmentCustomerNetPrice": 0.0,
"AlignmentCustomerVatPrice": 0.0,
"NextBillingCustomerGrossPrice": 70.00,
"NextBillingCustomerNetPrice": 58.82,
"NextBillingCustomerVatPrice": 11.18,
"NextRenewalCustomerGrossPrice": 70.00,
"NextRenewalCustomerNetPrice": 58.82,
"NextRenewalCustomerVatPrice": 11.18,
"PriceCurrencyId": "USD",
"ResultMessage": "OK"
}Diagram
flowchart LR
classDef mainColor fill:#ffffff,color:#555555,stroke:#96C34B,stroke-width:2px;
A([" <br/><b>Data limit reached</b><br/>The customer reaches the data limit <br/> "]):::mainColor
--> B([" <br/><b>Upgrade offered</b><br/>Cloudify offers an upgrade with an early renewal at a custom price <br/> "]):::mainColor
--> C([" <br/><b>New billing starts</b><br/>Cloudify uses the <i>Update Subscription Item</i> API endpoint to upgrade and renew the subscription immediately <br/> "]):::mainColor
Updated about 2 hours ago