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; }
} } $transactionAPI = new Transaction(); logCall('transaction->fetchByAccount ' . $merchantAccountId); $response = $transactionAPI->fetchByAccount($account, false); if (isCallSuccessful($response)) { $fetchedTxns = $response['data']->transactions; if ($fetchedTxns != null) { foreach ($fetchedTxns as $fetchedTx) { print "Transaction VID " . $fetchedTx->getVID() . PHP_EOL; print "Transaction amount " . $fetchedTx->getAmount() . PHP_EOL; print "Transaction status " . PHP_EOL; print $fetchedTx->statusLog[0]->status . PHP_EOL; } } else { print "No transactions found \n"; } } $refundAPI = new Refund(); logCall('refundAPI->fetchByAccount ' . $merchantAccountId); $response = $refundAPI->fetchByAccount($account, false); if (isCallSuccessful($response)) { $refunds = $response['data']->refunds; if ($refunds != null) { foreach ($refunds as $refund) { print 'Refund of ' . $refund->amount . ' with Refund Id ' . $refund->merchantRefundId . ' had been issued against payment (transaction Id ' . $refund->transaction->merchantTransactionId . ') of ' . $refund->transaction->amount . ' made on ' . $refund->transaction->timestamp . PHP_EOL; } } else { print "No refunds found \n"; } }