$merchantAccountId = 'account-2015-01-19_08_33_26';
$merchantAutoBillId = fetchMerchantAutobillId($merchantAccountId);
$merchantAutoBillId = 'ab-2015-01-19_08_33_26';
$autobill = new AutoBill();
$autobill->setMerchantAutoBillId($merchantAutoBillId);
// Cancel the AutoBill - leave customer entitled for the current period he/she already paid for
$disentitle = false;
// disentitle customer immediately
$force = true;
// force - this is a No-op flag unless you are using minimum commitment period feature
$settle = false;
$sendCancellationNotice = false;
logCall('Autobill->cancel ' . $merchantAutoBillId);
$response = $autobill->cancel($disentitle, $force, $settle, $sendCancellationNotice);
if (isCallSuccessful($response)) {
    print 'Subscription ID ' . $autobill->getMerchantAutoBillId() . ' has been cancelled!' . PHP_EOL;
    print 'Your entitlements will last through ' . $response['data']->autobill->endTimestamp . '. There will be no further auto-renewals.' . PHP_EOL;
    // Cancellation will attempt to cancel any pending renewal transactions . But it may not be successful
    // if the renewal transaction is in flight (in process of being submitted to the processor and waiting for
    // response. In that case, we want to use CashBox's feature to schedule a refund against this transaction
    // after it captures
    $latestTx = null;
    $transaction = new Transaction();
    logCall('transaction->fetchByAutobill ' . $merchantAutoBillId);
    $response = $transaction->fetchByAutobill($autobill);
    if (isCallSuccessful($response)) {
        $fetchedTxns = $response['data']->transactions;
        if ($fetchedTxns != null) {
            foreach ($fetchedTxns as $fetchedTx) {
                if ($fetchedTx->transactionItems[0]->sku == 'VIN_PM_VALIDATION') {
                    // This is a validation transaction, so we can ignore it