Ok, here goes! The AuthNet phone support person could not help me so I will try this in the forums.
I am implementing the new Transaction APIs.
I downloaded the SDK from authnet and I am able to get one function working - the getSettledBatchList function.
Here is the code I am using as described in the Sample Code:
06-09-2011 10:51 AM
You are correct that not all of the Transaction Details API functions are available yet in the current versions of the SDK. The only way to make use of these functions is directly via an XML request.
Here is a stripped down version of the code used in the PHP SDK to process a properly formatted XML request:
$post_string = "<xml />"; //This should be your properly structured XML request
$post_url = "https://apitest.authorize.net/xml/v1/request.api"; //switch 'apitest' to 'api' for production
$curl_request = curl_init($post_url);
curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post_string);
curl_setopt($curl_request, CURLOPT_HEADER, 0);
curl_setopt($curl_request, CURLOPT_TIMEOUT, 45);
curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_request, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($curl_request, CURLOPT_CAINFO, dirname(dirname(__FILE__)) . '/ssl/cert.pem'); //must be correct path to cert.pem from the SDK
curl_setopt($curl_request, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
$response = curl_exec($curl_request); //XML Response is stored here
curl_close($curl_request);
06-13-2011 02:14 PM
<?php
$post_string= '<?xml version="1.0" encoding="utf-8"?>
<getTransactionDetailsRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
<merchantAuthentication>
<name>XXXXXX</name>
<transactionKey>XXXXXXXXXXXXXXXXXXXXXXXXX</transactionKey>
</merchantAuthentication>
<transId>3679480912</transId>
</getTransactionDetailsRequest>';
//This should be your properly structured XML request
$post_url = "https://api.authorize.net/xml/v1/request.api"; //switch 'apitest' to 'api' for production
$curl_request = curl_init($post_url);
curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post_string);
curl_setopt($curl_request, CURLOPT_HEADER, 0);
curl_setopt($curl_request, CURLOPT_TIMEOUT, 45);
curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_request, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($curl_request, CURLOPT_CAINFO, dirname(dirname("./anet_php_sdk/lib/ssl/cert.pem"))); //must be correct path to cert.pem from the SDK
curl_setopt($curl_request, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
$response = curl_exec($curl_request); //XML Response is stored here
if($response ==true) {
echo "The test passed <br/>";
}
if($response == false) {
echo "no";
}
curl_close($curl_request);
$xmlData = new SimpleXMLElement($response);//it is used for accessing dom XML element
print_r($xmlData); //just for testing
foreach($xmlData->Response as $response) {
echo "$response->messages->resultCode";
}
?>
I have 'XXX'ed the sensitive data . I have used the transaction id from the merchant interface under reports.
Output:no
Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in C:\wamp\www\test1\index.php:46 Stack trace: #0 C:\wamp\www\test1\index.php(46): SimpleXMLElement->__construct('') #1 {main} thrown in C:\wamp\www\test1\index.php on line 46
which means there is no response generated.
Where do I get batchId from.
06-15-2011 12:45 PM