On-demand upgrade links allow you to create your own rules in terms of product upgrades, overriding existing upgrade settings through URL parameters.
Custom upgrade links allow you to define:
- The upgrade product
- Upgrade price
- Pricing options
- Time interval added to the subscription lifetime
Build your upgrade links using the following parameters.
|Parameter||Required / Optional||Type/Description|
Specifies the subscription to be upgraded.
|PROD||Required||Product ID of the target product used in the upgrade process.|
Price and currency to be used for the upgrade product.
|PERIOD||Required||Period of time to replace the subscription lifetime. Starts when the order is finalized. Requires PRICES parameter.|
Product pricing options to be applied to the upgrade product.
|PHASH||Required if using PRICE, PERIOD and/or OPTIONS.||HMAC_MD5 signature in order to prevent the request from being exploited. All custom upgrade links require digital signing, similar to current manual renewal links.|
Upgrade a subscription with a specific price and period of time
For this example, let's assume that we need a custom on-demand upgrade link for Subscription A (monthly subscription expiring on June 30th, 2019 with the reference ABC1D2E345) associated with Product A with the ID 1234567.
Product A is offered to customers in two versions:
- 1 user (code: 1user) - $99.99; (the customer using Subscription A opted for this particular pricing option).
- 2 users (code: 2users) - $149.99.
You're looking to prolong the subscription lifetime with 30 days, and charge the customer $50. For this example, the parameters must have the following values:
The resulting upgrade link (excluding PHASH) is:
Secure upgrade links
Use a HMAC_MD5 signature to prevent links from being exploited. To calculate the HMAC_MD5 signature, you need to build a string from the query parameters of the Buy Link prefixed by the length of the sequence of parameters in tandem with the Avangate-generated SECRET KEY for your account (view secret key).
- Using the parameters above, you get the following sequence: LICENSE=ABC1D2E345&PROD=1234567&OPTIONS1234567=1user&PRICES[USD]=50&PERIOD=30.
- You need to add the length of the character sequence at its beginning, to calculate the hash, namely 77. The resulting base string is 77LICENSE=ABC1D2E345&PROD=1234567&OPTIONS1234567=1user&PRICES[USD]=50&PERIOD=30.
- For the purpose of this demo, let's assume that your secret key is SECRET_KEY.
- Use the secret key and the base string to calculate the HMAC-MD5 HASH. The result should be: 32057a4f03f4ca766122040c4f2663c0 (valid exclusively for this example).
- The final upgrade link: