public function user_levels_removed($uid, $levels)
 {
     global $WishListMemberInstance;
     $settings = $WishListMemberInstance->GetOption('ewaysettings');
     $eway_ws = new EwayRecurWebserviceClient($settings['eway_customer_id'], $settings['eway_username'], $settings['eway_password'], $settings['eway_sandbox']);
     foreach ($levels as $lid) {
         //retrieve the trans id
         $txn = $WishListMemberInstance->GetMembershipLevelsTxnID($uid, $lid);
         list($tmp, $rebill_id, $invoice_ref, $cust_id) = explode('-', $txn);
         //do not run the call if this is not an eway rebill
         if ($tmp != 'EWAYRB') {
             return;
         }
         $resp = $eway_ws->call('DeleteRebillEvent', array('RebillCustomerID' => $cust_id, 'RebillID' => $rebill_id));
     }
 }
<?php

ini_set('display_errors', 0);
include dirname(__FILE__) . '/../EwayWebserviceClient.php';
include dirname(__FILE__) . '/../EwayRecurWebserviceClient.php';
$svc = new EwayRecurWebserviceClient(87654321, '*****@*****.**', 'test123', true);
//var
// $params = array(
//     'customerTitle' => '',
//     'customerFirstName' => 'Erwin',
//     'customerLastName' => 'Atuli',
//     'customerAddress' => '',
//     'customerSuburb' => '',
//     'customerState' => '',
//     'customerCompany' => '',
//     'customerPostCode' => '',
//     'customerCountry' => '',
//     'customerEmail' => '',
//     'customerFax' => '',
//     'customerPhone1' => '',
//     'customerPhone2' => '',
//     'customerRef' => '',
//     'customerJobDesc' => '',
//     'customerComments' => '',
//     'customerURL' => '',
// );
// echo "<pre>";
// $res = $svc->call("CreateRebillCustomer", $params);
// var_dump($res);
// echo "</pre>";
$params = array('RebillCustomerID' => '60092306', 'RebillID' => '70101756');
 public static function sync($data = array())
 {
     global $wpdb;
     global $WishListMemberInstance;
     $settings = $WishListMemberInstance->GetOption('ewaysettings');
     $eway_ws = new EwayRecurWebserviceClient($settings['eway_customer_id'], $settings['eway_username'], $settings['eway_password'], $settings['eway_sandbox']);
     $results = $wpdb->get_results("SELECT * FROM {$WishListMemberInstance->Tables->userlevel_options} WHERE option_value like 'EWAYRB-%-%-%'");
     foreach ($results as $row) {
         list($tmp, $rebill_id, $invoice_ref, $cust_id) = explode('-', $row->option_value);
         if (empty($rebill_id) || empty($cust_id) || empty($invoice_ref)) {
             continue;
         }
         $params = array('RebillCustomerID' => $cust_id, 'RebillID' => $rebill_id);
         $res = $eway_ws->call("QueryTransactions", $params);
         if (empty($res)) {
             continue;
         }
         $rebills = $res['QueryTransactionsResult']['rebillTransaction'];
         $last_trans = $rebills[0];
         foreach ($rebills as $r) {
             if ($r['Status'] == 'Future') {
                 break;
             }
             $last_trans = $r;
         }
         $_POST['sctxnid'] = $row->option_value;
         if ($last_trans['Status'] == 'Failed') {
             $WishListMemberInstance->ShoppingCartDeactivate();
         } else {
             $WishListMemberInstance->ShoppingCartReactivate();
         }
     }
 }