Reply
Member
Posts: 1
Registered: ‎07-29-2019

Error on Getting Transaction detail using PHP sdk

 During integration I need to get the transaction information to check if it is settled or not to update payment information in our end. I am using PHP SDK for the same but API is returning null.

 

Below is my code.

 

$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
$merchantAuthentication->setName('YOUR_LOGIN');
$merchantAuthentication->setTransactionKey('KEY');
$refId = 'ref' . time();
$request = new AnetAPI\GetTransactionDetailsRequest();

$request->setMerchantAuthentication($merchantAuthentication);
$request->setRefId($refId);
$request->setTransId('40035349370');

$controller = new AnetController\GetTransactionDetailsController($request);
$response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);
if (($response != null) && ($response->getMessages()->getResultCode() == "Ok"))
{
echo "SUCCESS: Transaction Status:" . $response->getTransaction()->getTransactionStatus() . "\n";
echo " Auth Amount:" . $response->getTransaction()->getAuthAmount() . "\n";
echo " Trans ID:" . $response->getTransaction()->getTransId() . "\n";
}
else
{
echo "ERROR : Invalid response\n";
$errorMessages = $response->getMessages()->getMessage();
echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n";
}
print_r($response);die('Test');

 

Please suggest. I also tried using "composer update". When I pass wrong transaction id it is returning error as below.

 

ERROR : Invalid response Response : E00040 The record cannot be found. net\authorize\api\contract\v1\GetTransactionDetailsResponse Object ( [transaction:net\authorize\api\contract\v1\GetTransactionDetailsResponse:private] => [clientId:net\authorize\api\contract\v1\GetTransactionDetailsResponse:private] => [transrefId:net\authorize\api\contract\v1\GetTransactionDetailsResponse:private] => [refId:net\authorize\api\contract\v1\ANetApiResponseType:private] => ref1564492259 [messages:net\authorize\api\contract\v1\ANetApiResponseType:private] => net\authorize\api\contract\v1\MessagesType Object ( [resultCode:net\authorize\api\contract\v1\MessagesType:private] => Error [message:net\authorize\api\contract\v1\MessagesType:private] => Array ( [0] => net\authorize\api\contract\v1\MessagesType\MessageAType Object ( [code:net\authorize\api\contract\v1\MessagesType\MessageAType:private] => E00040 [text:net\authorize\api\contract\v1\MessagesType\MessageAType:private] => The record cannot be found. ) ) ) [sessionToken:net\authorize\api\contract\v1\ANetApiResponseType:private] => ) traaa