Change the status of recurring rules via API

If you ever wanted to change the status of existing recurring rule found at Transactions > Recurring commissions via API, then the following sample script might come in handy:
 
 
<?php
include_once 'PapApi.class.php';
$papURL = "URL_TO_PostAffiliatePro"; //URL to Post Affliate Pro including protocol, but without any trailing slash
$merchantUsername = "merchant@example.com"; //merchant username
$merchantPassword = "123456"; //merchant password
$session = new Pap_Api_Session($papURL."/scripts/server.php");
if(!@$session->login($merchantUsername,$merchantPassword)) {  
  die("Can't login: ".$session->getMessage());
}
$request = new Gpf_Rpc_FormRequest("Pap_Features_RecurringCommissions_RecurringCommissionsForm", "changeStatus", $session); 
//Let's define the IDs of recurring regulations to be affected. 
//Click here to find out how to get the IDs of recurring rules via API
$request->addParam('ids',new Gpf_Rpc_Array(array('351b6ef9','edb0b9dd')));
$request->addParam('status', 'A'); //A = approved; P = Pending; D = Declined;
// send request 
try { 
    $request->sendNow(); 
} catch(Exception $e) { 
    die("API call error: ".$e->getMessage()); 
}         
?>
 
That's it. 
×