- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
PHP - Getting transaction details? (revised)
Apologies for repetition from my last post; I was not able to edit it and I was var_dumping the wrong variable.
I am trying to get transaction details using the PHP SDK. So far, it will get the transaction correctly (I checked in the logs and found that A.Net responded with the correct transaction information), but using var_dump() on the $response variable yields the following result:
object(net\authorize\api\contract\v1\GetTransactionDetailsResponse)#280 (4) { ["transaction":"net\authorize\api\contract\v1\GetTransactionDetailsResponse":private]=> NULL ["refId":"net\authorize\api\contract\v1\ANetApiResponseType":private]=> NULL ["messages":"net\authorize\api\contract\v1\ANetApiResponseType":private]=> NULL ["sessionToken":"net\authorize\api\contract\v1\ANetApiResponseType":private]=> NULL }
Moreover, when calling getTransaction() on $response, it returns null. So does getMessages().
Here is my code -- how can I get the transaction details (i.e., accessing properties like getAuthAmount(), getTransId(), etc)?
$request = new AnetAPI\GetTransactionDetailsRequest(); $request->setMerchantAuthentication($this->getAuthnetCreds()); $request->setTransId('7465634525'); $controller = new AnetController\GetTransactionDetailsController($request); $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::PRODUCTION); var_dump($response);
โ08-26-2015 03:45 PM - edited โ08-26-2015 03:46 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi there,
We're currently working on the full bank of new sample code here's the sample for gettransactiondetails in PHP: https://github.com/AuthorizeNet/sample-code-php/blob/master/Reporting/get-transaction-details.php
Hope this helps,
Brian
โ08-27-2015 01:18 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey Brian,
Thanks for the reply. I implemented the sample code but it's almost identical to what I'm trying above except it makes calls to error methods. Since getMessages() is null, I get the following error:
FatalErrorException in OrderController.php line 87:
Call to a member function getResultCode() on null
I know the transaction is being retrieved successfully because it logs the correct XML response in the phplog file. This is the revised code:
$request = new AnetAPI\GetTransactionDetailsRequest(); $request->setMerchantAuthentication($this->getAuthnetCreds()); $request->setTransId('2239019257'); $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"; echo "Response : " . $response->getMessages()->getMessage()[0]->getCode() . " " .$response->getMessages()->getMessage()[0]->getText() . "\n"; }
โ08-27-2015 09:04 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Fixed it. Turns out it was a broken dependency in composer.json.
โ08-27-2015 09:52 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have downloaded the latest SDK from github and i am getting the same issue. I have used the sample code provided at http://developer.authorize.net/api/reference/index.html#customer-profiles with my sandbox credentials.
It will be great If i can get some help from you.
Thanks
โ12-06-2015 11:47 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi there,
Are you using 1.8.6.2 of the PHP SDK? I have just run the sample code from https://github.com/AuthorizeNet/sample-code-php/blob/master/TransactionReporting/get-transaction-det... successfully.
Also I made sure to do a "composer update" to make sure I had the latest SDK and all the latest dependencies correct.
Let us know how that goes,
Brian
โ12-07-2015 10:22 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thanks for your suggestion. Earlier i had taken the SDK from master, but now i have downloaded version 1.8.6.2 and i am getting same result.
Should i get the latest version of other required libraries like jms, xsd2php, doctrine, Symfony, phpoption, parser-lib etc, as of now I am using it from master.
Please suggest.
Thanks
โ12-07-2015 11:05 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you paste in exactly what output you get when you run >php TransactionReporting/get-transaction-details.php from the command line?
Many thanks,
Brian
โ12-08-2015 08:06 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi guys,
I am facing the same issue. Using the latest SDK. Using it in YII-2 freamwork. This is the response I am getting.
net\authorize\api\contract\v1\ARBCreateSubscriptionResponse Object ( [subscriptionId:net\authorize\api\contract\v1\ARBCreateSubscriptionResponse:private] => [refId:net\authorize\api\contract\v1\ANetApiResponseType:private] => [messages:net\authorize\api\contract\v1\ANetApiResponseType:private] => [sessionToken:net\authorize\api\contract\v1\ANetApiResponseType:private] => )
When I tried to debug the function I found the XML is coming out properly. Below is the xml response
<?xml version="1.0" encoding="utf-8"?><ARBCreateSubscriptionResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"><refId>ref1450967088</refId><messages><resultCode>Ok</resultCode><message><code>I00001</code><text>Successful.</text></message></messages><subscriptionId>3043388</subscriptionId></ARBCreateSubscriptionResponse>
But the code $this->apiResponse = $this->serializer->deserialize( $xmlResponse, $this->apiResponseType , 'xml'); is not converting the xml into expected object.
Please help me here.
Thank you very much in advance
โ12-24-2015 06:53 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have this same error.
Please help.
@truthsofwolf what dependency was broken?
@davinder how did you fix yours?
โ04-09-2016 01:09 AM - edited โ04-09-2016 01:13 AM

