function fetchMerchantAutobillId($merchantAccountId)
{
    $merchantAutoBillId = null;
    $autobillAPI = new AutoBill();
    $account = new Account();
    $account->merchantAccountId = $merchantAccountId;
    logCall('Autobill->fetchByAccount ' . $merchantAccountId);
    $response = $autobillAPI->fetchByAccount($account, true);
    if (isCallSuccessful($response)) {
        print "Found account with id: " . $merchantAccountId . PHP_EOL;
        $fetchedAutoBills = $response['data']->autobills;
        foreach ($fetchedAutoBills as $autobill) {
            // process each autobill found here
            print "Found autobill with id: " . $autobill->getMerchantAutoBillId() . PHP_EOL;
            // If this is the autobill you want, set it here.  Check if $autobill is still active.
            if ($autobill->status == 'Active') {
                $merchantAutoBillId = $autobill->getMerchantAutoBillId();
            }
        }
    }
    return $merchantAutoBillId;
}
#
#			Customer account identified (in $merchantAccountId below)
#
#		Files Used:
#
#				Requires functionality for HOA Account_UpdatePaymentMethod
#				in file hoaAccountUpdatePaymentMethod.php
#
#-----------------------------------------------------------------------------------
require_once "hoaAccountUpdatePaymentMethod.php";
$merchantAccountId = 'testaccount5861';
# $merchantAccountId = 'TestAccount-88663';
$account = new Account();
$account->setMerchantAccountId($merchantAccountId);
$autobill = new AutoBill();
$response = $autobill->fetchByAccount($account, false);
print_r($response);
if ($response['returnCode'] == 200) {
    $targetAutoBill = $response['data']->autobills[0];
    $paymentMethod = $targetAutoBill->paymentMethod;
    $merchantPaymentMethodId = $paymentMethod->merchantPaymentMethodId;
    print "\$merchantPaymentMethodId={$merchantPaymentMethodId}" . PHP_EOL;
    $results = hoaAccountUpdatePaymentMethod($merchantAccountId, $merchantPaymentMethodId);
    $apiReturnCode = $results['apiReturnCode'];
    $validated = $results['validated'];
    print "results: apiReturnCode={$apiReturnCode}, validated={$validated}" . PHP_EOL;
    if ($apiReturnCode == '200' && $validated == '1') {
        print "Card successfully validated when updated.  Now check if AutoBill re-activated:" . PHP_EOL;
        $entitlement = new Entitlement();
        $response = $entitlement->fetchByAccount($account, true, false);
        print_r($response);
<?php

require_once 'Vindicia/Soap/Vindicia.php';
require_once 'Vindicia/Soap/Const.php';
$accountID = $argv[1];
$account = new Account();
$account->setMerchantAccountId($accountID);
$autobill = new AutoBill();
$response = $autobill->fetchByAccount($account, 'true');
//print the entire response for debugging
//print_r ($response);
$returnCode = $response['returnCode'];
$returnString = $response['returnString'];
if ($returnCode == 200) {
    $returned_abills = $response['data']->autobills;
    print "merchantAutoBillId,status\n";
    foreach ($returned_abills as $autobill) {
        print "{$autobill->merchantAutoBillId}" . "," . "{$autobill->status}" . "\n";
    }
} else {
    print "Unable to retrieve AutoBills for account ID: {$accountID} \n";
    print "{$returnString}\n";
}
        return true;
    } else {
        print 'Error:' . PHP_EOL;
        print 'Soap Id = ' . $response['data']->return->soapId . PHP_EOL;
        print 'Return Code = ' . $response['returnCode'] . PHP_EOL;
        print 'Return String = ' . $response['returnString'] . PHP_EOL;
        return false;
    }
}
$merchantAccountId = '313a6101cd7208f047af98256dceae582dc8537cfaa258845323741f7f3975668c35';
//$merchantAccountId = 'account-2015-01-19_08_33_26';
$account = new Account();
$account->setMerchantAccountId($merchantAccountId);
$autobillAPI = new AutoBill();
logCall('Autobill->fetchByAccount ' . $merchantAccountId);
$response = $autobillAPI->fetchByAccount($account, true);
if (isCallSuccessful($response)) {
    print "Found account with id: " . $merchantAccountId . PHP_EOL;
    $fetchedAutoBills = $response['data']->autobills;
    foreach ($fetchedAutoBills as $autobill) {
        // process each autobill found here
        print "Found autobill with id: " . $autobill->getMerchantAutoBillId() . PHP_EOL;
        print "Start Date: " . $autobill->startTimestamp . PHP_EOL;
        print "NextBilling: " . PHP_EOL;
        print "Date: " . $autobill->nextBilling->getTimestamp() . " ";
        print "Amount: " . $autobill->nextBilling->getAmount() . PHP_EOL;
        $autobillVid = $autobill->VID;
        $autobill = new AutoBill();
        $autobill->setVID($autobillVid);
        $numberOfFutureRebillsToFetch = 24;
        logCall('Autobill->fetchFutureRebills ' . $merchantAccountId);