cancel
Showing results for 
Search instead for 
Did you mean: 

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";
}
}

foundation406
Contributor
9 REPLIES 9

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

RaynorC1emen7
Expert

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.

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

 

1 batches Batch ID: XXXXXXX

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

echo the $response2

try creating another $request

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

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

it just getTransactionList  without the request

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

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