Authorize.net getSettledBatchList()

Hello, I am using the script below to pull all of my batch ID's from Authorize.net...When I send the request with a data range I get 0 results..When I send the request without a date range I get yesterdays results..Per their API if I do not send a date I will only get yesterdays results..So that part is working fine, I just can not get it to work using a date range..

require_once "AuthorizeNet.php";
define("AUTHORIZENET_API_LOGIN_ID", "xxxxx");
define("AUTHORIZENET_TRANSACTION_KEY", "xxxxxxx");
define("AUTHORIZENET_SANDBOX", false);
// Get Settled Batch List
$request = new AuthorizeNetTD;
$includeStatistics = true;
$firstSettlementDate = "2013-09-01T00:00:00";
$lastSettlementDate = "2010-09-01T00:00:00";
$response = $request->getSettledBatchList($includeStatistics,$firstSettlementDate,$lastSettlementDate);
//$response = $request->getSettledBatchList();
echo count($response->xml->batchList->batch) . " batches<br>";
foreach ($response->xml->batchList->batch as $batch) {
    echo "Batch ID: " . $batch->batchId . "<br>";
}

Open in new window

bradley525Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
This is just a guess, but it's easy to test out.  

1. Add error_reporting(E_ALL) to the top of the script.
2. Try printing the entire $response object with var_dump().  It might contain some error information.
0
bradley525Author Commented:
I did that but I did not receive any thing different...It fails at the foreach because there are not results..


Warning: Invalid argument supplied for foreach() in /home/content/77/9722977/html/anet_php_sdk/batch.php on line 16
0
Ray PaseurCommented:
What does the var_dump($response) contain?
0
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

bradley525Author Commented:
object(AuthorizeNetTD_Response)#3 (3) { ["xml"]=> object(SimpleXMLElement)#4 (1) { ["messages"]=> object(SimpleXMLElement)#6 (2) { ["resultCode"]=> string(5) "Error" ["message"]=> object(SimpleXMLElement)#7 (2) { ["code"]=> string(6) "E00003" ["text"]=> string(234) "The 'AnetApi/xml/v1/schema/AnetApiSchema.xsd:firstSettlementDate' element is invalid - The value '1Z' is invalid according to its datatype 'http://www.w3.org/2001/XMLSchema:dateTime' - The string '1Z' is not a valid XsdDateTime value." } } } ["response"]=> string(555) "ErrorE00003The 'AnetApi/xml/v1/schema/AnetApiSchema.xsd:firstSettlementDate' element is invalid - The value '1Z' is invalid according to its datatype 'http://www.w3.org/2001/XMLSchema:dateTime' - The string '1Z' is not a valid XsdDateTime value." ["xpath_xml"]=> object(SimpleXMLElement)#5 (1) { ["messages"]=> object(SimpleXMLElement)#6 (2) { ["resultCode"]=> string(5) "Error" ["message"]=> object(SimpleXMLElement)#7 (2) { ["code"]=> string(6) "E00003" ["text"]=> string(234) "The 'AnetApi/xml/v1/schema/AnetApiSchema.xsd:firstSettlementDate' element is invalid - The value '1Z' is invalid according to its datatype 'http://www.w3.org/2001/XMLSchema:dateTime' - The string '1Z' is not a valid XsdDateTime value." } } } } 

Open in new window

0
bradley525Author Commented:
Ok so I answered my own question...If you look above my last settlement date was before my first settlement date..that threw it off... After I changed it , it worked..

The working code it

error_reporting(E_ALL);
require_once "AuthorizeNet.php";
define("AUTHORIZENET_API_LOGIN_ID", "xxxx");
define("AUTHORIZENET_TRANSACTION_KEY", "xxxx");
define("AUTHORIZENET_SANDBOX", false);
// Get Settled Batch List
$request = new AuthorizeNetTD;
$includeStatistics = true;
$firstSettlementDate = "2013-09-01T08:15:30";
$lastSettlementDate = "2013-09-30T08:15:30";
//$response = $request->getSettledBatchList($includeStatistics = true, $firstSettlementDate = true, $lastSettlementDate = true, $utc = true);
$response = $request->getSettledBatchList($includeStatistics,$firstSettlementDate,$lastSettlementDate);
//$response = $request->getSettledBatchList();
echo count($response->xml->batchList->batch) . " batches<br>";
foreach ($response->xml->batchList->batch as $batch) {
    echo "Batch ID: " . $batch->batchId . "<br>";
}

Open in new window


object(AuthorizeNetTD_Response)#3 (3) { ["xml"]=> object(SimpleXMLElement)#4 (1) { ["messages"]=> object(SimpleXMLElement)#6 (2) { ["resultCode"]=> string(5) "Error" ["message"]=> object(SimpleXMLElement)#7 (2) { ["code"]=> string(6) "E00013" ["text"]=> string(59) "First Settlement Date is greater than Last Settlement Date." } } } ["response"]=> string(408) "ErrorE00013First Settlement Date is greater than Last Settlement Date." ["xpath_xml"]=> object(SimpleXMLElement)#5 (1) { ["messages"]=> object(SimpleXMLElement)#6 (2) { ["resultCode"]=> string(5) "Error" ["message"]=> object(SimpleXMLElement)#7 (2) { ["code"]=> string(6) "E00013" ["text"]=> string(59) "First Settlement Date is greater than Last Settlement Date." } } } } 

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ray PaseurCommented:
Amazing.  They have a BOM in the response string!

These things appear to be relevant.  Maybe their documentation has something about the error code or the message.
["code"]=> string(6) "E00003"
["text"]=> string(234) "The 'AnetApi/xml/v1/schema/AnetApiSchema.xsd:firstSettlementDate' element is invalid - The value '1Z' is invalid according to its datatype 'http://www.w3.org/2001/XMLSchema:dateTime' - The string '1Z' is not a valid XsdDateTime value."
0
bradley525Author Commented:
Only issue was that the date order was incorrect..the correct script is posted above..thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.