These docs are for v2.0. Click to read the latest docs for v2.1.

calculateSwitchPrice

📘

You can try that method by clicking here

Parameters

NameTypeDescription
publisherToken*stringYour publisher token
customerEmail*stringCustomer's email
currentOfferId*stringId of an offer that a viewer wants to switch from (the one currently active)
newOfferId*stringId of an offer that a viewer wants to switch to
switchType*stringType of switching (currently supported: instant_keep_date)

Result Parameters

NameTypeDescription
offerPricefloatprice of the new offer
offerCurrencystringcurrency of the new offer
offerCurrencySymbolstringcurrency symbol of the new offer
offerLocalestringlocale of the new offer
offerCountrystringcountry of the new offer
newSubscriptionPlanPriceInclTaxfloatprice of the new offer including tax
newSubscriptionPlanPriceExclTaxfloatprice of the new offer excluding tax
switchPriceInclTaxfloatthe amount of money that a viewer should be charged immediately before switching their subscription including tax
switchPriceExclTaxfloatthe amount of money that a viewer should be charged immediately before switching their subscription excluding tax
customerCurrencystringcurrency used by user
customerCurrencySymbolstringsymbol of currency used by user
customerLocalestringcustomer locale
customerCountrystringcustomer country
discountedNewSubscriptionPlanPriceInclTaxfloatprice of the new offer including tax with coupon applied
discountedNewSubscriptionPlanPriceExclTaxfloatprice of the new offer excluding tax with coupon applied
discountedPreviousSubscriptionPlanPriceInclTaxfloatprice of the old offer including tax with coupon applied
discountedPreviousSubscriptionPlanPriceExclTaxfloatprice of the old offer excluding tax with coupon applied
discountPeriodsintegerthe number of discounted billing periods

API Request/Response

Request

{
    "method": "calculateSwitchPrice",
    "params": {
      "publisherToken": "your_publisher_token",
      "customerEmail": "[email protected]",
      "currentOfferId": "S123123123_PL",
      "newOfferId": "S321321321_PL",
      "switchType": "instant_keep_date"
    },
    "jsonrpc": "2.0",
    "id": 1
  }

Response

{
    "result": {
        "offerPrice": 298.99,
        "offerCurrency": "USD",
        "offerCurrencySymbol": "$",
        "offerLocale": "en_US",
        "offerCountry": "FI",
        "newSubscriptionPlanPriceInclTax": 265.01,
        "newSubscriptionPlanPriceExclTax": 215.45,
        "switchPriceInclTax": 83,
        "switchPriceExclTax": 67.48,
        "customerCurrency": "EUR",
        "customerCurrencySymbol": "€",
        "customerLocale": "PL",
        "customerCountry": "PL",
        "discountedNewSubscriptionPlanPriceInclTax": 265.01,
        "discountedNewSubscriptionPlanPriceExclTax": 215.45542890768024,
        "discountedPreviousSubscriptionPlanPriceInclTax": 6.6612,
        "discountedPreviousSubscriptionPlanPriceExclTax": 8.19,
        "discountPeriods": 0
    },
    "id": "1",
    "jsonrpc": "2.0"
}

ErrorCodes

CodeDescription
3Invalid publisher token
10Invalid email address
32Unable to find existing subscription