Reply
Highlighted
Contributor
Posts: 18
Registered: ‎07-14-2014

Pulling transaction details PHP

This is what I have. I'm trying to pull each batches transaction details. It doesn't give me an error, the page is entirely blank.

 

<?php
//error_reporting(E_ALL);
require_once "anet_php_sdk/AuthorizeNet.php";
define("AUTHORIZENET_API_LOGIN_ID", "669KMkmY9K6U");
define("AUTHORIZENET_TRANSACTION_KEY", "4G6V83hNY8hYtu4a");
$includeStatistics = true;
// Get Settled Batch List
$request = new AuthorizeNetTD;
$response = $request->getSettledBatchList();
echo count($response->xml->batchList->batch) . " batches\n";
foreach ($response->xml->batchList->batch as $batch) {
echo "Batch ID: " . $batch->batchId . "\n";
$response2 = $request->getTransactionListRequest($batch->batchId);
foreach ($response2->xml->transactions as $transactions) {
echo "Transaction ID: " . $transactions->transaction) . "\n";
}
}

Highlighted
Expert
Posts: 4,525
Registered: ‎03-08-2010

Re: Pulling transaction details PHP

so it doesn't even give you  "0 batches"?

Highlighted
Contributor
Posts: 18
Registered: ‎07-14-2014

Re: Pulling transaction details PHP

If I remove this:

 

$response2 = $request->getTransactionListRequest($batch->batchId);
foreach ($response2->xml->transactions as $transactions) {
echo "Transaction ID: " . $transactions->transaction) . "\n";
}

 

Then it gives me 1 batch. It's like if there is an error at any point, it just breaks the whole page.

Highlighted
Contributor
Posts: 18
Registered: ‎07-14-2014

Re: Pulling transaction details PHP

It had an extra ) in it. Now it returns this, but no transaction detail.

 

1 batches Batch ID: XXXXXXX

Highlighted
Contributor
Posts: 18
Registered: ‎07-14-2014

Re: Pulling transaction details PHP

This is the line breaking everything:
$response2 = $request->getTransactionListRequest($batch->batchId);

Highlighted
Expert
Posts: 4,525
Registered: ‎03-08-2010

Re: Pulling transaction details PHP

[ Edited ]

echo the $response2

try creating another $request

Highlighted
Contributor
Posts: 18
Registered: ‎07-14-2014

Re: Pulling transaction details PHP

It still breaks everything after the batch info. Am I calling the method correctly?

 

require_once "anet_php_sdk/AuthorizeNet.php";
define("AUTHORIZENET_API_LOGIN_ID", "669KMkmY9K6U");

define("AUTHORIZENET_TRANSACTION_KEY", "4G6V83hNY8hYtu4a");

$includeStatistics = true;
// Get Settled Batch List
$request = new AuthorizeNetTD;
$response = $request->getSettledBatchList();
echo count($response->xml->batchList->batch) . " batches\n";
foreach ($response->xml->batchList->batch as $batch) {
echo "Batch ID: " . $batch->batchId . "\n";
$request2 = new AuthorizeNetTD;
$response2 = $request2->getTransactionListRequest($batch->batchId);
echo count($response2->xml->transactions->transaction) . " transactions\n";
foreach ($response2->xml->transactions->transaction as $transaction) {
echo "Transaction ID: " . $transaction->transId . "\n";
}
}

print_r("<br />" . $response2);

Highlighted
Expert
Posts: 4,525
Registered: ‎03-08-2010

Re: Pulling transaction details PHP

https://github.com/AuthorizeNet/sdk-php/blob/master/lib/AuthorizeNetTD.php

it just getTransactionList  without the request

Highlighted
Contributor
Posts: 18
Registered: ‎07-14-2014

Re: Pulling transaction details PHP

Raynor, could you help me out a little on how to execute this? Should the below php code pull a list of transactions onto the screen for July 14th?

 

define("AUTHORIZENET_API_LOGIN_ID", "669KMkmY9K6U");
define("AUTHORIZENET_TRANSACTION_KEY", "xxxxx");
define("AUTHORIZENET_SANDBOX", true);

getTransactionsForDay(7,14,2014);

Highlighted
Contributor
Posts: 18
Registered: ‎07-14-2014

Re: Pulling transaction details PHP

Got it!

 

require_once "/anet_php_sdk/AuthorizeNet.php";
define("AUTHORIZENET_API_LOGIN_ID", "669KMkmY9K6U");
define("AUTHORIZENET_TRANSACTION_KEY", "xxxxx");
define("AUTHORIZENET_SANDBOX", true);

$request = new AuthorizeNetTD;
$response = $request->getTransactionsForDay(7,14,2014);
print_r($response);