Inside the loop where the two spots are marked "/* HERE */" I've tried several ways with no luck. What is the correct syntax?
require 'autoload.php';
require_once 'SampleCodeConstants.php';
use net\authorize\api\contract\v1 as AnetAPI;
use net\authorize\api\controller as AnetController;
/* Create a merchantAuthenticationType object with authentication details
retrieved from the constants file */
$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
$merchantAuthentication->setName(\SampleCodeConstants::MERCHANT_LOGIN_ID);
$merchantAuthentication->setTransactionKey(\SampleCodeConstants::MERCHANT_TRANSACTION_KEY);
// Set the transaction's refId
$refId = 'ref' . time();
$request = new AnetAPI\GetUnsettledTransactionListRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$controller = new AnetController\GetUnsettledTransactionListController($request);
$response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::PRODUCTION);
if (($response != null) && ($response->getMessages()->getResultCode() == 'Ok')) {
if (null != $response->getTransactions()) {
foreach($response->getTransactions() as $tx) {
echo 'SUCCESS: TransactionID: ' . $tx->getTransId() . "\n";
$request = new AnetAPI\GetTransactionDetailsRequest();
$request->setMerchantAuthentication($merchantAuthentication);
$request->setTransId($tx->getTransId());
$controller = new AnetController\GetTransactionDetailsController($request);
$response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::PRODUCTION);
echo "Submitted on (Local): " . date_format($tx->getSubmitTimeLocal(), 'Y-m-d H:i:s') . "\n";
echo "Settle amount: " . number_format($tx->getSettleAmount(), 2, '.', '') . "\n";
echo "Email: " . /* HERE */ . "\n";
echo "Transaction subject: " . /* HERE */ . "\n";
}
} else {
echo 'No unsettled transactions for the merchant.' . "\n";
}
} else {
echo 'ERROR : Invalid response' . "\n";
$errorMessages = $response->getMessages()->getMessage();
echo 'Response : ' . $errorMessages[0]->getCode() . ' ' .$errorMessages[0]->getText() . "\n";
}
return $response;