cancel
Showing results for 
Search instead for 
Did you mean: 

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);

 

 

truthsofwolf
Member
11 REPLIES 11

Hi,

Earlier I downloaded all the libraries manually, it was creating customer profiles at authorize.net sandbox account but was not giving any response.

 

After that I installed composer from https://getcomposer.org/download/ (as i am using windows platform) and downloaded the latest SDK using composer and it worked fine for me.

 

You need to use the below code provided at https://github.com/AuthorizeNet/sdk-php.
Add this code to composer.json file (in a directory where you want to install SDK) and install it.

{
  "require": {
  "php": ">=5.2.0",
  "ext-curl": "*",
  "authorizenet/authorizenet": "1.8.8",
  "jms/serializer": "xsd2php-dev as 0.18.0"
},
"require-dev": {
  "goetas/xsd2php": "2.*@dev",
  "goetas/xsd-reader": "2.*@dev"
},
"repositories": [{
    "type": "vcs",
    "url": "https://github.com/goetas/serializer.git"
    }]

}

 

I hope this will help you.


Thanks

@davinder Thank you very much. 

I was using the manual approach too because i was unfamiliar with composer.

But when I decided to take composer on, all was sorted.