Upgrade subscription
Overview
Use the setSubscriptionUpgrade method to upgrade a subscription.
Requirements
You can only upgrade subscriptions with automatic renewal enabled.
Parameters
Parameters | Type/Description |
---|---|
sessionID |
Required (string) |
|
Session identifier, the output of the Login method. Include sessionID into all your requests. 2Checkout throws an exception if the values are incorrect. The sessionID expires in 10 minutes. |
subscriptionReference |
Required (string) |
Unique, system-generated subscription identifier. |
|
productCode |
Required (string) |
|
Unique identifier of the target product for the subscription upgrade process. You control the product code and can set it up in the Control Panel. |
options |
Optional (string) |
|
Pricing options of the target product for the subscription upgrade process.
String - ';' separated list of 'OptionValue' returned by getProductUpgradeOptions function. If the pricing options groups is "scale" (interval), the Options parameter should be sent like this: [option group unique code] + "=" + value e.g. Users=7 |
customPrice |
Optional (string) |
|
The price you want to charge customers for the upgrade. The currency used by default is the same as in the previous payment customers made. |
Response
Parameters | Type/Description |
---|---|
Boolean |
true or false depending on whether or not the operation succeeded. |
Request
<?php
require ('PATH_TO_AUTH');
$subscriptionReference = 'YOUR_SUBSCRIPTION_REFERENCE';
$productCode = 'YOUR_PRODUCT_CODE';
$options = 'YOUR_PRICE_CODES'; //case sensitive; include only price options codes (exclude spaces)
$customPrice = 1;
$jsonRpcRequest = array (
'method' => 'setSubscriptionUpgrade',
'params' => array($sessionID, $subscriptionReference, $productCode, $options, $customPrice),
'id' => $i++,
'jsonrpc' => '2.0');
var_dump (callRPC((Object)$jsonRpcRequest, $host, true));