Cancel subscription pause
Overview
Use the cancelRenewalPause method to cancel a subscription's pause and change its status.
Request Parameters
Parameters | Required | Type/Description |
---|---|---|
merchantCode | Required | String. Unique merchant ID code that can be found in the Merchant Control Panel. |
SubscriptionRef | Required | String. The system-generated reference code of the subscription. |
Request Example
<?php $host = 'http://api.sandbox58.avangate.local/rpc/6.0/'; $merchantCode = "22322"; // MERCHANT CODE $key = "q0^H5i?q3=)x9NP02W3q"; // MERCHANT SECRET KEY $string = strlen($merchantCode) . $merchantCode . strlen(gmdate('Y-m-d H:i:s')) . gmdate('Y-m-d H:i:s'); $hash = hash_hmac('md5', $string, $key); $i = 1; // counter for api calls // call login $jsonRpcRequest = new stdClass(); $jsonRpcRequest->jsonrpc = '2.0'; $jsonRpcRequest->method = 'login'; $jsonRpcRequest->params = array($merchantCode, gmdate('Y-m-d H:i:s'), $hash); $jsonRpcRequest->id = $i++; $sessionID = callRPC($jsonRpcRequest, $host); var_dump("session id:" . $sessionID); // call api methods below $SubscriptionRef = 'FA27DD5072'; $jsonRpcRequest = array ( 'jsonrpc' => '2.0', 'method' => 'cancelRenewalPause', 'params' => array($sessionID, $SubscriptionRef), 'id' => $i++ ); var_dump ("cancelRenewalPause", callRPC((Object)$jsonRpcRequest, $host)); print ("If TRUE pause is canceled"); /* $jsonRpcRequest = array ( 'jsonrpc' => '2.0', 'method' => 'getRenewalPause', 'params' => array($sessionID, $SubscriptionRef), 'id' => $i++ ); var_dump ("getRenewalPause", callRPC((Object)$jsonRpcRequest, $host)); */ function callRPC($Request, $hostUrl, $Debug = false) { $curl = curl_init($hostUrl); curl_setopt( $curl, CURLOPT_POST, 1); curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt( $curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Accept: application/json')); $RequestString = json_encode($Request); curl_setopt( $curl, CURLOPT_POSTFIELDS, $RequestString); curl_setopt( $curl, CURLOPT_COOKIE, "XDEBUG_SESSION=PHPSTORM"); if (stristr($hostUrl, 'sandboxdev') || stristr($hostUrl, 'git-sb')) { curl_setopt( $curl, CURLOPT_PROXY, 'localhost:3128'); // curl_setopt( $curl, CURLOPT_PROXY, 'proxy.avangate.local:8080'); // curl_setopt( $curl, CURLOPT_PROXYUSERPWD, 'andrei.avramica:pw'); // for authenticated proxies } $ResponseString = curl_exec ($curl); if (!empty($ResponseString)) { $Response = json_decode ($ResponseString,false); if (isset($Response->error) && !is_null($Response->error)) { var_dump($Response->error) ; return null; } return $Response->result; } else { return null; } }
Response Parameters
Parameters | Type/Description |
---|---|
SubscriptionRef |
Boolean
|
Response Example
{ “StartDate”: “2020-02-19 22:20:30", “ResumeDate”: “2020-03-01 18:00:00", “PauseReason”: “vacation leave” }