Skip to content

Subscription API

curl --location --request GET 'http://{api-domain}/api/web/user/{userId}/orders' \
--header 'Accept: application/json;v=3' \
--header 'Authorization: Bearer {bearerToken}'

Example response

{
"active": [
{
"uri": "/api/web/order/8047",
"autorenewStatus": "ACTIVE",
"earliestEndDate": "2020-01-15T15:04:36Z",
"endDate": "2020-01-16T15:04:36Z",
"accessEndDate": "2020-01-16T21:04:36Z",
"id": 8047,
"price": 414.1,
"initPrice": 10.0,
"productName": "Product group 1 subscription-20-days",
"productId": 2,
"productUri": {
"uri": "/api/web/productgroup/3/products/2"
},
"productGroupId": 3,
"productGroupUri": {
"uri": "/api/web/productgroup/3"
},
"startDate": "2020-01-15T15:04:36Z",
"userId": 10014,
"ip": "127.0.0.1",
"platformId": 1,
"productPaymentId": 10141,
"productPaymentUri": {
"uri": "/api/web/productgroup/3/products/2/productPayments/10141"
},
"status": "ACTIVE",
"currency": "SEK",
"paymentInfo": "378282******0005",
"paymentInfoExpiryDate": "2021-12-01T00:00:00Z",
"userPaymentMethod": {
"id": "64848290-edd0-4145-8747-1a0262059fe3",
"userId": 10014,
"extAgreementRef": "37x7k5g",
"paymentInfo": "378282******0005",
"expireDate": "2021-12-01T00:00:00Z",
"registered": "2020-01-15T13:02:11Z",
"userPaymentMethodStatus": "ACTIVE",
"userPaymentMethodType": "CREDIT_CARD",
"allowOneClickBuy": true,
"captureAttemptLog": "UserPaymentMethod updated.",
"paymentProviderId": 61,
"expirationDate": "2021-12-01T00:00:00Z"
},
"autorenewErrors": 0,
"statusText": "Purchase sucessfull",
"externalOrderRef": "37x7k5g",
"registered": "2020-01-15T15:04:36Z",
"activePeriods": 1,
"trialOverride": "DEFAULT",
"period": "P20D"
}
],
"future": [
{
"uri": "/api/web/order/8045",
"autorenewStatus": "ACTIVE",
"earliestEndDate": "2018-01-15T14:57:30Z",
"endDate": "2021-01-16T14:57:30Z",
"accessEndDate": "2021-01-16T20:57:30Z",
"id": 8045,
"price": 414.1,
"initPrice": 10.0,
"productName": "Product group 1 subscription-20-days",
"productId": 2,
"productUri": {
"uri": "/api/web/productgroup/3/products/2"
},
"productGroupId": 3,
"productGroupUri": {
"uri": "/api/web/productgroup/3"
},
"startDate": "2021-01-15T14:57:30Z",
"userId": 10014,
"ip": "127.0.0.1",
"platformId": 1,
"productPaymentId": 10141,
"productPaymentUri": {
"uri": "/api/web/productgroup/3/products/2/productPayments/10141"
},
"status": "ACTIVE",
"currency": "SEK",
"paymentInfo": "378282******0005",
"paymentInfoExpiryDate": "2021-12-01T00:00:00Z",
"userPaymentMethod": {
"id": "64848290-edd0-4145-8747-1a0262059fe3",
"userId": 10014,
"extAgreementRef": "37x7k5g",
"paymentInfo": "378282******0005",
"expireDate": "2021-12-01T00:00:00Z",
"registered": "2020-01-15T13:02:11Z",
"userPaymentMethodStatus": "ACTIVE",
"userPaymentMethodType": "CREDIT_CARD",
"allowOneClickBuy": true,
"captureAttemptLog": "UserPaymentMethod updated.",
"paymentProviderId": 61,
"expirationDate": "2021-12-01T00:00:00Z"
},
"autorenewErrors": 0,
"statusText": "Purchase sucessfull",
"externalOrderRef": "76954kg",
"registered": "2020-01-15T14:57:30Z",
"activePeriods": 1,
"trialOverride": "DEFAULT",
"period": "P20D"
}
]
}
curl --location --request GET 'http://{api-domain}/api/web/user/{userId}/orders/history' \
--header 'Accept: application/json;v=3' \
--header 'Authorization: Bearer {bearerToken}'

Example response

[
{
"uri": "/api/web/order/8036",
"autorenewStatus": "STOPPED",
"earliestEndDate": "2020-01-15T13:01:59Z",
"endDate": "2018-01-16T13:01:59Z",
"accessEndDate": "2018-01-16T19:01:59Z",
"id": 8036,
"price": 414.1,
"initPrice": 10.0,
"productName": "Product group 1 subscription-20-days",
"productId": 2,
"productUri": {
"uri": "/api/web/productgroup/3/products/2"
},
"productGroupId": 3,
"productGroupUri": {
"uri": "/api/web/productgroup/3"
},
"startDate": "2018-01-15T13:01:59Z",
"userId": 10014,
"ip": "127.0.0.1",
"platformId": 1,
"productPaymentId": 10141,
"productPaymentUri": {
"uri": "/api/web/productgroup/3/products/2/productPayments/10141"
},
"status": "ACTIVE",
"currency": "USD",
"paymentInfo": "378282******0005",
"paymentInfoExpiryDate": "2021-12-01T00:00:00Z",
"userPaymentMethod": {
"id": "64848290-edd0-4145-8747-1a0262059fe3",
"userId": 10014,
"extAgreementRef": "37x7k5g",
"paymentInfo": "378282******0005",
"expireDate": "2021-12-01T00:00:00Z",
"registered": "2020-01-15T13:02:11Z",
"userPaymentMethodStatus": "ACTIVE",
"userPaymentMethodType": "CREDIT_CARD",
"allowOneClickBuy": true,
"paymentProviderId": 61,
"expirationDate": "2021-12-01T00:00:00Z"
},
"autorenewErrors": 0,
"statusText": "Order stopped",
"externalOrderRef": "mx8nqqg",
"registered": "2020-01-15T13:01:59Z",
"activePeriods": 1,
"trialOverride": "DEFAULT",
"period": "P20D"
}
]
curl --location --request GET 'http://{api-domain}/api/web/order/{orderId}' \
--header 'Accept: application/json;v=3' \
--header 'Authorization: Bearer {bearerToken}'

Example response

{
"uri": "/api/web/order/8047",
"autorenewStatus": "ACTIVE",
"earliestEndDate": "2020-01-15T15:04:36Z",
"endDate": "2020-01-16T15:04:36Z",
"accessEndDate": "2020-01-16T21:04:36Z",
"id": 8047,
"price": 414.1,
"initPrice": 10.0,
"productName": "Product group 1 subscription-20-days",
"productId": 2,
"productUri": {
"uri": "/api/web/productgroup/3/products/2"
},
"productGroupId": 3,
"productGroupUri": {
"uri": "/api/web/productgroup/3"
},
"startDate": "2020-01-15T15:04:36Z",
"userId": 10014,
"ip": "127.0.0.1",
"platformId": 1,
"productPaymentId": 10141,
"productPaymentUri": {
"uri": "/api/web/productgroup/3/products/2/productPayments/10141"
},
"status": "ACTIVE",
"currency": "SEK",
"paymentInfo": "378282******0005",
"paymentInfoExpiryDate": "2021-12-01T00:00:00Z",
"userPaymentMethod": {
"id": "64848290-edd0-4145-8747-1a0262059fe3",
"userId": 10014,
"extAgreementRef": "37x7k5g",
"paymentInfo": "378282******0005",
"expireDate": "2021-12-01T00:00:00Z",
"registered": "2020-01-15T13:02:11Z",
"userPaymentMethodStatus": "ACTIVE",
"userPaymentMethodType": "CREDIT_CARD",
"allowOneClickBuy": true,
"paymentProviderId": 61,
"expirationDate": "2021-12-01T00:00:00Z"
},
"autorenewErrors": 0,
"statusText": "Purchase sucessfull",
"externalOrderRef": "37x7k5g",
"registered": "2020-01-15T15:04:36Z",
"activePeriods": 1,
"trialOverride": "DEFAULT",
"period": "P20D"
}

Get payment transactions for a given subscription

Section titled “Get payment transactions for a given subscription”
curl --location --request GET 'http://{api-domain}/api/web/user/{userId}/orders/{orderId}/transactions' \
--header 'Accept: application/json;v=3' \
--header 'Authorization: Bearer {bearerToken}'

Example response

[
{
"uri": "/api/web/user/10028/orders/8074/transactions/9084",
"id": 9084,
"paymentProviderId": 41,
"price": 122.45,
"registered": "2020-01-17T11:58:36Z",
"status": "SUCCESS",
"transactionNumber": 0,
"type": "AUTORENEW",
"orderId": 8074,
"vat": 0.0,
"startDate": "2020-01-16T11:57:10Z",
"endDate": "2020-01-31T11:57:10Z",
"userPaymentMethodId": "64848290-edd0-4145-8747-1a0262059fe3"
},
{
"uri": "/api/web/user/10028/orders/8074/transactions/9082",
"id": 9082,
"paymentProviderId": 41,
"price": 46.79,
"registered": "2020-01-31T11:57:10Z",
"status": "SUCCESS",
"transactionNumber": 0,
"type": "PURCHASE",
"orderId": 8074,
"currency": "EUR",
"vat": 0.0,
"startDate": "2020-01-31T11:57:10Z",
"endDate": "2020-02-27T11:57:10Z",
"userPaymentMethodId": "64848290-edd0-4145-8747-1a0262059fe3"
}
]
curl --location --request PUT 'http://{api-domain}/api/web/order/{orderId}/terminate' \
--header 'Accept: application/json;v=3' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {bearerToken}'

Optional queryParams

  • notifyUser - Should the user get a notification about the termination. Accepted values are EMAIL, SIGNUP_2STEP and NONE (default)
  • instantly - Should the user lose access instantly. Accepted values are true and false (default)
  • stopReason - Stop reason

Example response

{
"uri": "/api/web/order/8047",
"autorenewStatus": "STOPPED",
"earliestEndDate": "2020-01-15T15:04:36Z",
"endDate": "2020-01-16T15:04:36Z",
"accessEndDate": "2020-01-16T21:04:36Z",
"id": 8047,
"price": 414.1,
"initPrice": 10.0,
"productName": "Product group 1 subscription-20-days",
"productId": 2,
"productUri": {
"uri": "/api/web/productgroup/3/products/2"
},
"productGroupId": 3,
"productGroupUri": {
"uri": "/api/web/productgroup/3"
},
"startDate": "2020-01-15T15:04:36Z",
"userId": 10014,
"ip": "127.0.0.1",
"platformId": 1,
"productPaymentId": 10141,
"productPaymentUri": {
"uri": "/api/web/productgroup/3/products/2/productPayments/10141"
},
"status": "ACTIVE",
"currency": "SEK",
"paymentInfo": "378282******0005",
"paymentInfoExpiryDate": "2021-12-01T00:00:00Z",
"userPaymentMethod": {
"id": "64848290-edd0-4145-8747-1a0262059fe3",
"userId": 10014,
"extAgreementRef": "37x7k5g",
"paymentInfo": "378282******0005",
"expireDate": "2021-12-01T00:00:00Z",
"registered": "2020-01-15T13:02:11Z",
"userPaymentMethodStatus": "ACTIVE",
"userPaymentMethodType": "CREDIT_CARD",
"allowOneClickBuy": true,
"paymentProviderId": 61,
"expirationDate": "2021-12-01T00:00:00Z"
},
"autorenewErrors": 0,
"statusText": "Order stopped",
"externalOrderRef": "37x7k5g",
"registered": "2020-01-15T15:04:36Z",
"activePeriods": 1,
"trialOverride": "DEFAULT",
"period": "P20D"
}
curl --location --request PUT 'http://{api-domain}/api/web/order/{orderId}/reactivate' \
--header 'Accept: application/json;v=3' \
--header 'Authorization: Bearer {bearerToken}'

Example response

{
"autorenewStatus": "ACTIVE",
"earliestEndDate": "2020-01-17T11:57:10Z",
"endDate": "2020-01-31T11:57:10Z",
"accessEndDate": "2020-01-31T17:57:10Z",
"id": 8074,
"price": 122.45,
"initPrice": 46.79,
"productName": "Product group 1 subscription-15-days",
"productId": 1,
"productGroupId": 3,
"productGroupUri": {},
"startDate": "2020-01-17T11:57:10Z",
"userId": 10028,
"ip": "127.0.0.1",
"platformId": 1,
"productPaymentId": 10081,
"orderRef": "8074",
"status": "ACTIVE",
"currency": "EUR",
"userPaymentMethod": {
"id": "8be838f6-129b-4a49-a070-699fa9953ff5",
"userId": 10028,
"extAgreementRef": "random",
"paymentInfo": "1111 11** **** 1111",
"expireDate": "2020-12-20T00:00:00Z",
"registered": "2020-01-17T11:57:10Z",
"userPaymentMethodStatus": "ACTIVE",
"userPaymentMethodType": "CREDIT_CARD",
"allowOneClickBuy": true,
"captureAttemptLog": "Capture ok.",
"paymentProviderId": 41,
"expirationDate": "2020-12-20T00:00:00Z"
},
"autorenewErrors": 0,
"statusText": "Order reactivated",
"registered": "2020-01-17T11:57:10Z",
"activePeriods": 2,
"trialOverride": "DEFAULT",
"period": "P15D"
}

This endpoint can be used by end user to change the payment method of a running subscription (for instance if the credit card is expired). It can also be used by admin users to change dates, prices and other values.

Note: Patching is not supported, so all order fields must be passed on the body. If null values are set, they will override existing values.

curl --location --request PUT 'http://{api-domain}/api/web/order/{orderId}' \
--header 'Accept: application/json;v=3' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {bearerToken}' \
--data-raw '{
"order": {
"userId": {userId},
"orderId": {id of order to be updated}
// order info
}
}'
curl --location --request GET 'https://{api-domain}/api/web/user/{userId}/orders/conversions?orderId=8074&withinCurrentPaymentProviderOnly=true' \
--header 'Accept: application/json;v=3' \
--header 'Authorization: Bearer {bearerToken}'

Example response

{
"restOrderConversionList": [
{
"restOrderConversionProductGroupList": [
{
"restProductGroup": {
"uri": "/api/web/productgroup/3",
"description": "Product group 1 description",
"id": 3,
"name": "Product group 1",
"sortIndex": 0,
"categoriesUri": {
"uri": "/api/web/productgroup/3/categories"
},
"metadata": {
"uri": "/api/metadata/productgroup/3",
"entries": {},
"empty": true
},
"productsUri": {
"uri": "/api/web/productgroup/3/products",
"products": []
},
"productGroupAccessesUri": {},
"saleStatus": "ENABLED",
"checkAccessForProgramRelations": false
},
"restOrderConversionProductList": [
{
"restProduct": {
"uri": "/api/web/productgroup/3/products/2",
"paymentPlan": {
"id": 21,
"name": "subscription-20-days",
"paymentType": "SUBSCRIPTION",
"period": "P20D"
},
"description": "Subscription product",
"enabled": true,
"minimumPeriods": 0,
"price": 414.1,
"productGroupId": 3,
"productPaymentsUri": {
"uri": "/api/web/productgroup/3/products/2/productPayments"
},
"id": 2,
"currency": "NOK",
"productStatus": "ENABLED"
},
"orderConversionProductPaymentList": [
{
"restProductPayment": {
"uri": "/api/web/productgroup/3/products/2/productPayments/10082",
"description": "comcast",
"enabled": true,
"id": 10082,
"initPrice": 74.12,
"paymentProviderId": 41,
"productId": 2,
"sortIndex": 1,
"productPaymentStatus": "ENABLED",
"paymentObjectUri": {
"uri": "/api/web/productgroup/3/products/2/productPayments/10082/payment"
},
"autorenewWarningChannel": "EMAIL",
"autoRenewWarningEnabled": false,
"initPeriod": "P10D"
},
"originalPrice": 74.12,
"price": 29.548,
"discount": 44.572,
"time": 864000,
"extendedTime": 519566,
"discountAvailable": true,
"convertOrderCapabilities": "Supported",
"oneClickBuyCapabilities": "Supported",
"purchaseWithoutPaymentInfoCapabilities": "Supported",
"changeAction": "CROSSGRADE",
"orderConversionWithinSamePeriod": {
"capabilities": "Supported",
"remainingSecondsOfCurrentPeriodFromEndOfToday": 823048,
"priceForRemainingOfCurrentPeriodWithoutDiscount": 70.607,
"discount": 44.572,
"numberOfFullPeriodsAdded": 0,
"priceToPay": 26.035,
"endDate": "2020-01-27T12:37:28Z",
"initPeriodInSeconds": 823048
},
"trialOverride": "DEFAULT"
}
]
}
]
}
],
"orderId": 8078
},
{
"restOrderConversionProductGroupList": [
{
"restProductGroup": {
"uri": "/api/web/productgroup/3",
"description": "Product group 1 description",
"id": 3,
"name": "Product group 1",
"sortIndex": 0,
"categoriesUri": {
"uri": "/api/web/productgroup/3/categories"
},
"metadata": {
"uri": "/api/metadata/productgroup/3",
"entries": {},
"empty": true
},
"productsUri": {
"uri": "/api/web/productgroup/3/products",
"products": []
},
"productGroupAccessesUri": {},
"saleStatus": "ENABLED",
"checkAccessForProgramRelations": false
},
"restOrderConversionProductList": [
{
"restProduct": {
"uri": "/api/web/productgroup/3/products/2",
"paymentPlan": {
"id": 21,
"name": "subscription-20-days",
"paymentType": "SUBSCRIPTION",
"period": "P20D"
},
"description": "Subscription product",
"enabled": true,
"minimumPeriods": 0,
"price": 414.1,
"productGroupId": 3,
"productPaymentsUri": {
"uri": "/api/web/productgroup/3/products/2/productPayments"
},
"id": 2,
"currency": "NOK",
"productStatus": "ENABLED"
},
"orderConversionProductPaymentList": [
{
"restProductPayment": {
"uri": "/api/web/productgroup/3/products/2/productPayments/10082",
"description": "comcast",
"enabled": true,
"id": 10082,
"initPrice": 74.12,
"paymentProviderId": 41,
"productId": 2,
"sortIndex": 1,
"productPaymentStatus": "ENABLED",
"paymentObjectUri": {
"uri": "/api/web/productgroup/3/products/2/productPayments/10082/payment"
},
"autorenewWarningChannel": "EMAIL",
"autoRenewWarningEnabled": false,
"initPeriod": "P10D"
},
"originalPrice": 74.12,
"price": 29.548,
"discount": 44.572,
"time": 864000,
"extendedTime": 519566,
"discountAvailable": true,
"convertOrderCapabilities": "Supported",
"oneClickBuyCapabilities": "Supported",
"purchaseWithoutPaymentInfoCapabilities": "Supported",
"changeAction": "CROSSGRADE",
"orderConversionWithinSamePeriod": {
"capabilities": "Supported",
"remainingSecondsOfCurrentPeriodFromEndOfToday": 823048,
"priceForRemainingOfCurrentPeriodWithoutDiscount": 70.607,
"discount": 44.572,
"numberOfFullPeriodsAdded": 0,
"priceToPay": 26.035,
"endDate": "2020-01-27T12:37:28Z",
"initPeriodInSeconds": 823048
},
"trialOverride": "DEFAULT"
}
]
}
]
}
],
"orderId": 8077
}
]
}

A simplified representation of the structure:

{
"restOrderConversionList": [
{
"restOrderConversionProductGroupList": [ //list of elements
{
"restProductGroup": {
//info about the productGroup
},
"restOrderConversionProductList": [ //list of elements
{
"restProduct": {
//info about the product
},
"orderConversionProductPaymentList": [ //list of elements
{
"restProductPayment": {
//info about the productPayment
},
"originalPrice": ,
"price": ,
"discount": ,
"time": ,
"extendedTime": ,
"discountAvailable": "",
"convertOrderCapabilities": "",
"oneClickBuyCapabilities": "",
"purchaseWithoutPaymentInfoCapabilities": "",
"changeAction": "",
"orderConversionWithinSamePeriod": {
"capabilities": "",
"remainingSecondsOfCurrentPeriodFromEndOfToday": "",
"priceForRemainingOfCurrentPeriodWithoutDiscount": ,
"discount": ,
"numberOfFullPeriodsAdded": ,
"priceToPay": ,
"endDate": "",
"initPeriodInSeconds":
},
"trialOverride": ""
}
]
}
]
}
],
"orderId": ""
}
]
}

Explanation of the values

originalPrice: The original initial price of the product
price: The price to pay for the upgrade if upgrade option is DISCOUNT
discount: The discount earned from the original subscription
time: The initial period of the product
extendedTime: The extended time earned from the original subscription
discountAvailable: True if discount is lower than the initial price of the product
convertOrderCapabilities: Supported if the payment method used in the original subscription supports re usage in a new subscription. NotSupported if not
oneClickBuyCapabilities: Supported if the payment provider used to purchase the original subscription supports one click buy. NotSupported if not
purchaseWithoutPaymentInfoCapabilities: Supported if a payment method is not used during purchase of the original subscription
changeAction: UPGRADE if the initial price of the product is higher than price of the subscription
DOWNGRADE if the initial price of the product is lower than price of the subscription
CROSSGRADE if the prices match or the product is connected to the same productgroup as the original subscription
PRODUCT_AND_CURRENCY_CHANGE if the currency of the product differs from the currency of the original subscription
orderConversionWithinSamePeriod.capabilities: Supported if conversion within same period is supported. NotSupported if not
orderConversionWithinSamePeriod.remainingSecondsOfCurrentPeriodFromEndOfToday: The remaining time of the current period of the original subscription
orderConversionWithinSamePeriod.priceForRemainingOfCurrentPeriodWithoutDiscount: The price for the remaining time of the current period of the original subscription of the new product
orderConversionWithinSamePeriod.discount: Discount
orderConversionWithinSamePeriod.numberOfFullPeriodsAdded: The number of full periods added to the new subscription. Maximum is 1.
orderConversionWithinSamePeriod.priceToPay: The price to pay for the new subscription
orderConversionWithinSamePeriod.endDate: The endDate of the new subscription
orderConversionWithinSamePeriod.initPeriodInSeconds: The initial period of the new subscription
trialOverride: TRIAL_FORCED
TRIAL_BYPASS_FORCED
FREE_TRIAL_BYPASSED
DEFAULT
(See further explanation in Trial override.)

Instant upgrade/downgrade with extended time

Section titled “Instant upgrade/downgrade with extended time”

A new subscription is purchased where the initial period is set to the initial period of the product + the extended time earned from the original subscription. Can be performed using all purchase flows (initialize and capture, one click buy)

Allowed if changeAction is not PRODUCT_AND_CURRENCY_CHANGE

curl --location --request PUT 'http://{api-domain}/api/web/order' \
--header 'Accept: application/json;v=3' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {bearerToken}' \
--data-raw '{
"order": {
"userId": {userId},
"productPaymentId": {productPaymentId},
"payment": {
"paymentMethod": "ONE_CLICK_BUY"
},
"userPaymentMethod": {
"id": {userPaymentMethodId}
},
"upgradeOrderId": {original order id},
"upgradeOption": "EXTENDED_TIME"
}
}'

Example response

{
"autorenewStatus": "ACTIVE",
"earliestEndDate": "2020-01-15T10:45:09Z",
"endDate": "2020-01-25T10:45:09Z",
"accessEndDate": "2020-01-25T16:45:09Z",
"id": 8023,
"price": 122.45,
"initPrice": 46.79,
"productName": "Product group 1 subscription-15-days",
"productId": 1,
"productGroupId": 3,
"productGroupUri": {},
"startDate": "2020-01-15T10:45:09Z",
"userId": 10012,
"ip": "127.0.0.1",
"platformId": 1,
"productPaymentId": 10081,
"status": "ACTIVE",
"currency": "EUR",
"userPaymentMethod": {
"id": "2b641b95-ed9a-47a5-afaf-017d5d50c273",
"userId": 10012,
"extAgreementRef": "random",
"paymentInfo": "1111 11** **** 1111",
"expireDate": "2020-12-20T00:00:00Z",
"registered": "2020-01-15T10:45:08Z",
"userPaymentMethodStatus": "ACTIVE",
"userPaymentMethodType": "CREDIT_CARD",
"allowOneClickBuy": true,
"captureAttemptLog": "Auth ok.",
"paymentProviderId": 41
},
"autorenewErrors": 0,
"statusText": "Purchase sucessfull",
"registered": "2020-01-15T10:45:09Z",
"activePeriods": 1,
"vat": 0.0,
"changeAction": "UPGRADE",
"trialOverride": "DEFAULT",
"period": "P15D",
"upgradeOrderId": "8022",
"upgradeOption": "EXTENDED_TIME",
"upgradeExtendedTime": 10
}

A new subscription is purchased and the initial price is set to the initial price of the product subtracted by the discount earned from the original subscription. Can be performed using all purchase flows (initialize and capture, one click buy).

Allowed if changeAction is not PRODUCT_AND_CURRENCY_CHANGE and discountAvailable is true.

curl --location --request PUT 'http://{api-domain}/api/web/order' \
--header 'Accept: application/json;v=3' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {bearerToken}' \
--data-raw '{
"order": {
"userId": {userId},
"productPaymentId": {productPaymentId},
"payment": {
"paymentMethod": "ONE_CLICK_BUY"
},
"userPaymentMethod": {
"id": {userPaymentMethodId}
},
"upgradeOrderId": {original order id},
"upgradeOption": "DISCOUNT"
}
}'

Example response

{
"autorenewStatus": "ACTIVE",
"earliestEndDate": "2020-01-15T10:45:09Z",
"endDate": "2020-01-25T10:45:09Z",
"accessEndDate": "2020-01-25T16:45:09Z",
"id": 8023,
"price": 122.45,
"initPrice": 36.79,
"productName": "Product group 1 subscription-15-days",
"productId": 1,
"productGroupId": 3,
"productGroupUri": {},
"startDate": "2020-01-15T10:45:09Z",
"userId": 10012,
"ip": "127.0.0.1",
"platformId": 1,
"productPaymentId": 10081,
"status": "ACTIVE",
"currency": "EUR",
"userPaymentMethod": {
"id": "2b641b95-ed9a-47a5-afaf-017d5d50c273",
"userId": 10012,
"extAgreementRef": "random",
"paymentInfo": "1111 11** **** 1111",
"expireDate": "2020-12-20T00:00:00Z",
"registered": "2020-01-15T10:45:08Z",
"userPaymentMethodStatus": "ACTIVE",
"userPaymentMethodType": "CREDIT_CARD",
"allowOneClickBuy": true,
"captureAttemptLog": "Auth ok.",
"paymentProviderId": 41
},
"autorenewErrors": 0,
"statusText": "Purchase sucessfull",
"registered": "2020-01-15T10:45:09Z",
"activePeriods": 1,
"vat": 0.0,
"changeAction": "UPGRADE",
"trialOverride": "DEFAULT",
"period": "P15D",
"upgradeOrderId": "8022",
"upgradeOption": "DISCOUNT",
"upgradeDiscount": 10
}

No purchase is made, but the initial period of the new subscription is set to the extended time earned from the original subscription.

Allowed if changeAction is not PRODUCT_AND_CURRENCY_CHANGE and convertOrderCapabilities is Supported.

curl --location --request PUT 'http://{api-domain}/api/web/order' \
--header 'Accept: application/json;v=3' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {bearerToken}' \
--data-raw '{
"order": {
"userId": {userId},
"productPaymentId": {productPaymentId},
"payment": {
"paymentMethod": "CONVERT_ORDER_INSTANTLY",
"orderId": {original order id}
},
"upgradeOrderId": {original order id}
}
}'

Example response

{
"autorenewStatus": "ACTIVE",
"earliestEndDate": "2020-01-15T10:45:09Z",
"endDate": "2020-01-25T10:45:09Z",
"accessEndDate": "2020-01-25T16:45:09Z",
"id": 8023,
"price": 122.45,
"initPrice": 36.79,
"productName": "Product group 1 subscription-15-days",
"productId": 1,
"productGroupId": 3,
"productGroupUri": {},
"startDate": "2020-01-15T10:45:09Z",
"userId": 10012,
"ip": "127.0.0.1",
"platformId": 1,
"productPaymentId": 10081,
"status": "ACTIVE",
"currency": "EUR",
"userPaymentMethod": {
"id": "2b641b95-ed9a-47a5-afaf-017d5d50c273",
"userId": 10012,
"extAgreementRef": "random",
"paymentInfo": "1111 11** **** 1111",
"expireDate": "2020-12-20T00:00:00Z",
"registered": "2020-01-15T10:45:08Z",
"userPaymentMethodStatus": "ACTIVE",
"userPaymentMethodType": "CREDIT_CARD",
"allowOneClickBuy": true,
"captureAttemptLog": "Auth ok.",
"paymentProviderId": 41
},
"autorenewErrors": 0,
"statusText": "Instant conversion from 8022",
"registered": "2020-01-15T10:45:09Z",
"activePeriods": 1,
"vat": 0.0,
"changeAction": "DOWNGRADE",
"trialOverride": "DEFAULT",
"period": "P15D",
"upgradeOrderId": "8022",
"upgradeOption": "EXTENDED_TIME",
"upgradeDiscount": 10
}

No purchase is made, but the new subscription will be renewed when the original ends.

Allowed if convertOrderCapabilities is Supported.

curl --location --request PUT 'http://{api-domain}/api/web/order' \
--header 'Accept: application/json;v=3' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {bearerToken}' \
--data-raw '{
"order": {
"userId": {userId},
"productPaymentId": {productPaymentId},
"payment": {
"paymentMethod": "CONVERT_ORDER_FOR_NEXT_RENEWAL",
"orderId": {original order id}
}
}
}'

Example response

{
"autorenewStatus": "ACTIVE",
"earliestEndDate": "2020-01-15T10:45:09Z",
"endDate": "2020-01-15T10:45:09Z",
"accessEndDate": "2020-01-15T10:45:09Z",
"id": 8023,
"price": 122.45,
"initPrice": 36.79,
"productName": "Product group 1 subscription-15-days",
"productId": 1,
"productGroupId": 3,
"productGroupUri": {},
"startDate": "2020-01-15T10:45:09Z",
"userId": 10012,
"ip": "127.0.0.1",
"platformId": 1,
"productPaymentId": 10081,
"status": "ACTIVE",
"currency": "EUR",
"userPaymentMethod": {
"id": "2b641b95-ed9a-47a5-afaf-017d5d50c273",
"userId": 10012,
"extAgreementRef": "random",
"paymentInfo": "1111 11** **** 1111",
"expireDate": "2020-12-20T00:00:00Z",
"registered": "2020-01-15T10:45:08Z",
"userPaymentMethodStatus": "ACTIVE",
"userPaymentMethodType": "CREDIT_CARD",
"allowOneClickBuy": true,
"captureAttemptLog": "Auth ok.",
"paymentProviderId": 41
},
"autorenewErrors": 0,
"statusText": "Conversion on renewal from 8022",
"registered": "2020-01-15T10:45:09Z",
"activePeriods": 1,
"vat": 0.0,
"changeAction": "CONVERSION_AT_RENEWAL",
"trialOverride": "DEFAULT",
"period": "P15D",
"upgradeOrderId": "8022"
}

A new subscription is purchased where the enddate is set to the enddate of the original subscription. The end user will pay for the remaining of the period with the new products initial price (subtracted by the discount earned from the original subscription). If price to pay is negative, a full period is added. And the price to pay will be corrected thereafter. Can be performed using all purchase flows (initialize and capture, one click buy).

Allowed if orderConversionWithinSamePeriod.capabilities is Supported.

curl --location --request PUT 'http://{api-domain}/api/web/order' \
--header 'Accept: application/json;v=3' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {bearerToken}' \
--data-raw '{
"order": {
"userId": {userId},
"productPaymentId": {productPaymentId},
"payment": {
"paymentMethod": "ONE_CLICK_BUY"
},
"userPaymentMethod": {
"id": {userPaymentMethodId}
},
"upgradeOrderId": {original order id},
"upgradeOption": "CONVERT_WITHIN_SAME_PERIOD"
}
}'

Example response

{
"autorenewStatus": "ACTIVE",
"earliestEndDate": "2020-01-15T10:45:09Z",
"endDate": "2020-01-25T10:45:09Z",
"accessEndDate": "2020-01-25T16:45:09Z",
"id": 8023,
"price": 122.45,
"initPrice": 36.79,
"productName": "Product group 1 subscription-15-days",
"productId": 1,
"productGroupId": 3,
"productGroupUri": {},
"startDate": "2020-01-15T10:45:09Z",
"userId": 10012,
"ip": "127.0.0.1",
"platformId": 1,
"productPaymentId": 10081,
"status": "ACTIVE",
"currency": "EUR",
"userPaymentMethod": {
"id": "2b641b95-ed9a-47a5-afaf-017d5d50c273",
"userId": 10012,
"extAgreementRef": "random",
"paymentInfo": "1111 11** **** 1111",
"expireDate": "2020-12-20T00:00:00Z",
"registered": "2020-01-15T10:45:08Z",
"userPaymentMethodStatus": "ACTIVE",
"userPaymentMethodType": "CREDIT_CARD",
"allowOneClickBuy": true,
"captureAttemptLog": "Auth ok.",
"paymentProviderId": 41
},
"autorenewErrors": 0,
"statusText": "Purchase sucessfull",
"registered": "2020-01-15T10:45:09Z",
"activePeriods": 1,
"vat": 0.0,
"changeAction": "UPGRADE",
"trialOverride": "DEFAULT",
"period": "P15D",
"upgradeOrderId": "8022",
"upgradeOption": "CONVERT_WITHIN_SAME_PERIOD",
"upgradeDiscount": 10
}

When purchasing a subscription in a regular manner, the initial price of the product is amount that is charged. This can however be bypassed by the following:

This property can be enabled on both product -and productgroup level. The following rules apply:

  • Given that property is enabled on product level and the initial price is 0,-, the recurring price is the amount that the user will be charged (and the initial period of the subscription will be set to the recurring period) if the user already has an active subscription of the same product
  • Given that property is enabled on productgroup level and the initial price is 0,-, the recurring price is the amount that the user will be charged (and the initial period of the subscription will be set to the recurring period) if the user already has an active subscription of the same productgroup

TrialOverride works in the following manner:

  • By passing queryParam trialOverride=FORCE_TRIAL_BYPASS, the customer will be charged the recurring price of product during purchase (and the initial period of the subscription will be set to the recurring period)
  • By passing queryParam trialOverride=FORCE_TRIAL, the customer will be charged the initial price of the product regardless of free trial limit toggle rules applying or not (and the initial period of the subscription will be set to the initial period specified in the productProvider) .
  • By not passing queryParam trialOverride, default (or free trial limit) rules will apply

Example request

curl --location --request PUT 'http://{api-domain}/api/web/order?trialOverrid=FORCE_TRIAL_BYPASS' \
--header 'Accept: application/json;v=3' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {bearerToken}' \
--data-raw '{
"order": {
"userId": {userId},
"productPaymentId": {productPaymentId},
"payment": {
"paymentMethod": "ONE_CLICK_BUY"
},
"userPaymentMethod": {
"id": {userPaymentMethodId}
}
}
}'

The resulting order will have a field called trialOverride which can have the following values:

  • TRIAL_FORCED - purchase made with queryParam trialOverride=FORCE_TRIAL
  • TRIAL_BYPASS_FORCED - purchase made with queryParam trialOverride=FORCE_TRIAL_BYPASS
  • FREE_TRIAL_BYPASSED - purchase made without queryParam trialOverride and free trial limit applied
  • DEFAULT - no trial or trial bypass forced/bypassed

Example response

{
"uri": "/api/web/order/8047",
"autorenewStatus": "ACTIVE",
"earliestEndDate": "2020-01-20T15:04:36Z",
"endDate": "2020-01-20T15:04:36Z",
"accessEndDate": "2020-01-16T21:04:36Z",
"id": 8047,
"price": 414.1,
"initPrice": 414.1,
"productName": "Product group 1 subscription-20-days",
"productId": 2,
"productUri": {
"uri": "/api/web/productgroup/3/products/2"
},
"productGroupId": 3,
"productGroupUri": {
"uri": "/api/web/productgroup/3"
},
"startDate": "2020-01-01T15:04:36Z",
"userId": 10014,
"ip": "127.0.0.1",
"platformId": 1,
"productPaymentId": 10141,
"productPaymentUri": {
"uri": "/api/web/productgroup/3/products/2/productPayments/10141"
},
"status": "ACTIVE",
"currency": "SEK",
"paymentInfo": "378282******0005",
"paymentInfoExpiryDate": "2021-12-01T00:00:00Z",
"userPaymentMethod": {
"id": "64848290-edd0-4145-8747-1a0262059fe3",
"userId": 10014,
"extAgreementRef": "37x7k5g",
"paymentInfo": "378282******0005",
"expireDate": "2021-12-01T00:00:00Z",
"registered": "2020-01-01T13:02:11Z",
"userPaymentMethodStatus": "ACTIVE",
"userPaymentMethodType": "CREDIT_CARD",
"allowOneClickBuy": true,
"paymentProviderId": 61
},
"autorenewErrors": 0,
"statusText": "Purchase sucessfull",
"externalOrderRef": "37x7k5g",
"registered": "2020-01-01T15:04:36Z",
"activePeriods": 1,
"trialOverride": "TRIAL_BYPASS_FORCED",
"period": "P20D"
}

By freezing a subscription, the recurring payments will be put on hold until the subscription is unfrozen again. When frozen, the end user will have access throughout the current period, and will gain access again when unfrozen.

The freeze capabilities for a given order, can be examined using the following:

curl --location --request GET 'http://{api-domain}/api/{platform}/order/{orderId}/freeze/capabilities' \
--header 'Accept: application/json;v=3' \
--header 'Authorization: Bearer {bearerToken}'

Example response

{
"freezeCapability": "Supported || PeriodicallySupported || NotSupported",
"freezePeriod": {
"freezeDate": "{The date which the subscription will be frozen. Only present if freezeCapability is PeriodicallySupported}",
"unfreezeDate": "{The date which the frozen subscription will be unfreezed. Only present if freezeCapability is PeriodicallySupported}"
}
}

A subscription can only be frozen if freezeCapability is either Supported or PeriodicallySupported. If PeriodicallySupported, the subscription can be in frozen state between the freezeDate and the unfreezeDate.

A subscription can be frozen using the following endpoint:

curl --location --request PUT 'http://{api-domain}/api/{platform}/order/{orderId}/freeze' \
--header 'Accept: application/json;v=3' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {bearerToken}' \
--data-raw '{
"freezeDates": {
"unfreezeDate": "{The date which subscription the should be automatically unfrozen and renewed for a new period}"
}
}'

The unfreezeDate can be set to any future date if the /capabilities endpoint returns freezeCapability=Supported. If PeriodicallySupported, it must be set to a date <= the unfreezeDate specified by the capabilities. The endDate of the resulting subscription, indicates when the order will be automatically unfrozen.

Example response

{
"uri": "/api/web/order/8047",
"autorenewStatus": "FROZEN",
"earliestEndDate": "2020-01-20T15:04:36Z",
"endDate": "2020-03-01T15:04:36Z",
"accessEndDate": "2020-01-16T21:04:36Z",
"id": 8047,
"price": 414.1,
"initPrice": 414.1,
"productName": "Product group 1 subscription-20-days",
"productId": 2,
"productUri": {
"uri": "/api/web/productgroup/3/products/2"
},
"productGroupId": 3,
"productGroupUri": {
"uri": "/api/web/productgroup/3"
},
"startDate": "2020-01-01T15:04:36Z",
"userId": 10014,
"ip": "127.0.0.1",
"platformId": 1,
"productPaymentId": 10141,
"productPaymentUri": {
"uri": "/api/web/productgroup/3/products/2/productPayments/10141"
},
"status": "ACTIVE",
"currency": "SEK",
"paymentInfo": "378282******0005",
"paymentInfoExpiryDate": "2021-12-01T00:00:00Z",
"userPaymentMethod": {
"id": "64848290-edd0-4145-8747-1a0262059fe3",
"userId": 10014,
"extAgreementRef": "37x7k5g",
"paymentInfo": "378282******0005",
"expireDate": "2021-12-01T00:00:00Z",
"registered": "2020-01-01T13:02:11Z",
"userPaymentMethodStatus": "ACTIVE",
"userPaymentMethodType": "CREDIT_CARD",
"allowOneClickBuy": true,
"paymentProviderId": 61
},
"autorenewErrors": 0,
"statusText": "Order frozen until 2020-03-01T15:04:36Z",
"externalOrderRef": "37x7k5g",
"registered": "2020-01-01T15:04:36Z",
"activePeriods": 1,
"trialOverride": "DEFAULT",
"period": "P20D"
}

When freezing a subscription, it will be automatically unfrozen on the given unfreezeDate. By using the following, the subscription can be manually unfrozen.

curl --location --request PUT 'http://{api-domain}/api/{platform}/order/{orderId}/unfreeze' \
--header 'Accept: application/json;v=3' \
--header 'Authorization: Bearer {bearerToken}'

Example response

{
"uri": "/api/web/order/8047",
"autorenewStatus": "ACTIVE",
"earliestEndDate": "2020-01-20T15:04:36Z",
"endDate": "2020-01-20T15:04:36Z",
"accessEndDate": "2020-01-16T21:04:36Z",
"id": 8047,
"price": 414.1,
"initPrice": 414.1,
"productName": "Product group 1 subscription-20-days",
"productId": 2,
"productUri": {
"uri": "/api/web/productgroup/3/products/2"
},
"productGroupId": 3,
"productGroupUri": {
"uri": "/api/web/productgroup/3"
},
"startDate": "2020-01-01T15:04:36Z",
"userId": 10014,
"ip": "127.0.0.1",
"platformId": 1,
"productPaymentId": 10141,
"productPaymentUri": {
"uri": "/api/web/productgroup/3/products/2/productPayments/10141"
},
"status": "ACTIVE",
"currency": "SEK",
"paymentInfo": "378282******0005",
"paymentInfoExpiryDate": "2021-12-01T00:00:00Z",
"userPaymentMethod": {
"id": "64848290-edd0-4145-8747-1a0262059fe3",
"userId": 10014,
"extAgreementRef": "37x7k5g",
"paymentInfo": "378282******0005",
"expireDate": "2021-12-01T00:00:00Z",
"registered": "2020-01-01T13:02:11Z",
"userPaymentMethodStatus": "ACTIVE",
"userPaymentMethodType": "CREDIT_CARD",
"allowOneClickBuy": true,
"paymentProviderId": 61
},
"autorenewErrors": 0,
"statusText": "Order unfrozen (2020-01-01T15:04:36Z)",
"externalOrderRef": "37x7k5g",
"registered": "2020-01-01T15:04:36Z",
"activePeriods": 1,
"trialOverride": "DEFAULT",
"period": "P20D"
}