Revert a subscription
Use the revertSubscription method to roll a subscription back to the state it was in immediately before its last order (e.g. a renewal, upgrade, or extend). Revert restores the expiration date, product/quantity values and pricing options captured in the pre-order snapshot, and records the reversal — along with the reason provided — in the subscription's history.
Request parameters
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.
LicenceCode
Required (string) Unique, system-generated subscription identifier of the subscription to revert.
OrderReference
Required (string) The 2Checkout reference number of the order whose changes should be undone. Must be the last order placed on the subscription.
Reason
Required (string)
Free-text explanation for the revert. Recorded against the subscription's history alongside the revert event.
Revert restores the subscription to its pre-order snapshot:
Expiration date is reverted to the snapshot value.
Product, product name, pricing options and quantity are reverted to the snapshot values.
A new history entry is written, capturing the before/after values and the Reason supplied.
If reverting a prolong-license action causes the expiration date to fall in the past, the expiration date will be left to the current value.
Revert only accepts subscriptions whose last change was order-driven (renewal, upgrade, extend, etc.). If the subscription was modified some other way after that order, for example, directly by a merchant user, the revert will fail.
You cannot revert a subscription that has addon subscriptions linked to it.
Request sample
<?php
require ('PATH_TO_AUTH');
$subscriptionReferenceTest = 'YOUR_SUBSCRIPTION_REFERENCE';
$jsonRpcRequest = array (
'method' => 'getSubscription',
'params' => array($sessionID, $subscriptionReferenceTest),
'id' => $i++,
'jsonrpc' => '2.0'
);
$updatedSubscription = callRPC((Object)$jsonRpcRequest, $host, true);
var_dump ($updatedSubscription);
$updatedSubscription->RecurringEnabled = false;
$updatedSubscription->SubscriptionEnabled = true;
$updatedSubscription->ExpirationDate = '2020-12-12';
$jsonRpcRequest = array (
'method' => 'updateSubscription',
'params' => array($sessionID, $updatedSubscription),
'id' => $i++,
'jsonrpc' => '2.0'
);
var_dump (callRPC((Object)$jsonRpcRequest, $host, true));Response parameters
Boolean
true or false depending on whether the changes were successful or not.
Error codes
LICENCE_NOT_FOUND
The licence or order cannot be found.
NOT_LAST_ORDER
The provided order is not the last order on this subscription.
NO_SNAPSHOT
No snapshot exists for this subscription before the given order.
SUBSCRIPTION_MODIFIED_EXTERNALLY
The subscription was modified outside of an order after the last order and cannot be reverted.
SUBSEQUENT_CHANGES
The subscription was modified after this order. Revert is not allowed.
INVALID_ORDER
A valid OrderReference (order RefNo) is required.
MISSING_REASON
Reason for revert is required.
REVERT_FAILED
Revert transaction rolled back due to a database failure.
ADDON_REVERT_NOT_ALLOWED
Revert is not allowed for subscriptions with add-ons.
Last updated
Was this helpful?