cancel
Showing results for 
Search instead for 
Did you mean: 

php api get settle batch list

Hi

 

I am following this code https://github.com/AuthorizeNet/sample-code-php/blob/master/TransactionReporting/get-settled-batch-l... with a date range. But response don't have batches as expected. e.g if i use 2017-02-01 08:15:30 to 2017-02-14 08:15:30 , the number of batches returned are not same as i see in authorize.net Reports section.

modshahid
Member
9 REPLIES 9

Hello @modshahid

 

Is this with your production system, sandbox or both?

 

Richard

RichardH
Administrator Administrator
Administrator

its production

Hi @modshahid,

 

Generally, discrepancies like this come down to time zone issues. For example, if the time zone in the merchant interface is set to your own time zone (like Pacific, for example), but you do the request with dates/times in UTC, it's easy to be off by one in the dates.

 

What time zone is your account set to in the merchant interface? What time zone are you sending with the request?

Hi

 

Both are in Pacific timezone

Hi @modshahid,

 

Can you post an example of the code you're using for your request? Additionally, can you post a section from the phplog file showing the actual log of what was sent/receive?

Php Code:

 

require '/libraries/authorize.net/vendor/autoload.php';
use net\authorize\api\contract\v1 as AnetAPI;
use net\authorize\api\controller as AnetController;

function getSettledBatchList($firstSettlementDate, $lastSettlementDate) {
    $auth_name = 'XXXXXXXXXXX';
    $auth_transaction_key = 'XXXXXXXXXXXXXXXXXXXXX';

    $merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
    $merchantAuthentication->setName($auth_name);
    $merchantAuthentication->setTransactionKey($auth_transaction_key);

    $request = new AnetAPI\GetSettledBatchListRequest();
    $request->setMerchantAuthentication($merchantAuthentication);
    $request->setIncludeStatistics(true);

    $request->setFirstSettlementDate($firstSettlementDate);
    $request->setLastSettlementDate($lastSettlementDate);

    $controller = new AnetController\GetSettledBatchListController ($request);

    $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::PRODUCTION);

    if (($response != null) && ($response->getMessages()->getResultCode() == "Ok")){
        foreach($response->getBatchList() as $batch){
              echo "<br /><br />";
            echo "Batch ID: " . $batch->getBatchId() . "<br />";
              echo "Batch settled on (UTC): " . $batch->getSettlementTimeUTC()->format('r') . "<br />";
              echo "Batch settled on (Local): " . $batch->getSettlementTimeLocal()->format('r') . "<br />";
              echo "Batch settlement state: " . $batch->getSettlementState() . "<br />";
              echo "Batch market type: " . $batch->getMarketType() . "<br />";
              echo "Batch product: " . $batch->getProduct() . "<br />";
              foreach($batch->getStatistics() as $statistics){
                  echo "Account type: ".$statistics->getAccountType()."<br />";
                  echo "Total charge amount: ".$statistics->getChargeAmount()."<br />";
                  echo "Charge count: ".$statistics->getChargeCount()."<br />";
                  echo "Refund amount: ".$statistics->getRefundAmount()."<br />";
                  echo "Refund count: ".$statistics->getRefundCount()."<br />";
                  echo "Void count: ".$statistics->getVoidCount()."<br />";
                  echo "Decline count: ".$statistics->getDeclineCount()."<br />";
                  echo "Error amount: ".$statistics->getErrorCount()."<br />";
              }
        }

    }else{
        echo "ERROR :  Invalid response<br />";
        $errorMessages = $response->getMessages()->getMessage();
        echo "Response : " . $errorMessages[0]->getCode() . "  " .$errorMessages[0]->getText() . "<br />";
    }

    return $response;
}

$fDate = new DateTime();
$fDate->setDate(2017,02,10);
$fDate->setTime(08,15,30);
$fDate->setTimezone(new DateTimeZone('America/Los_Angeles'));

$sDate = new DateTime();
$sDate->setDate(2017,02,15);
$sDate->setTime(08,15,30);
$sDate->setTimezone(new DateTimeZone('America/Los_Angeles'));

$resp = getSettledBatchList($fDate, $sDate);

 

 

PHPLOG

 

Wed, 01 Mar 2017 11:56:40 +0000 INFO : [execute] (/var/www/sandbox/application/libraries/authorize.net.ach/vendor/authorizenet/authorizenet/lib/net/authorize/api/controller/base/ApiOperationBase.php : 113) - Request Serialization Begin
 Wed, 01 Mar 2017 11:56:40 +0000 DEBUG : [execute] (/var/www/sandbox/application/libraries/authorize.net.ach/vendor/authorizenet/authorizenet/lib/net/authorize/api/controller/base/ApiOperationBase.php : 114) - net\authorize\api\contract\v1\GetSettledBatchListRequest Object
(
    [includeStatistics:net\authorize\api\contract\v1\GetSettledBatchListRequest:private] => 1
    [firstSettlementDate:net\authorize\api\contract\v1\GetSettledBatchListRequest:private] => DateTime Object
        (
            [date] => 2017-02-10 00:15:30
            [timezone_type] => 3
            [timezone] => America/Los_Angeles
        )

    [lastSettlementDate:net\authorize\api\contract\v1\GetSettledBatchListRequest:private] => DateTime Object
        (
            [date] => 2017-02-15 00:15:30
            [timezone_type] => 3
            [timezone] => America/Los_Angeles
        )

    [merchantAuthentication:net\authorize\api\contract\v1\ANetApiRequestType:private] => net\authorize\api\contract\v1\MerchantAuthenticationType Object
        (
            [name:net\authorize\api\contract\v1\MerchantAuthenticationType:private] => xxxx
            [transactionKey:net\authorize\api\contract\v1\MerchantAuthenticationType:private] => xxxx
            [sessionToken:net\authorize\api\contract\v1\MerchantAuthenticationType:private] =>
            [password:net\authorize\api\contract\v1\MerchantAuthenticationType:private] =>
            [impersonationAuthentication:net\authorize\api\contract\v1\MerchantAuthenticationType:private] =>
            [fingerPrint:net\authorize\api\contract\v1\MerchantAuthenticationType:private] =>
            [mobileDeviceId:net\authorize\api\contract\v1\MerchantAuthenticationType:private] =>
        )

    [refId:net\authorize\api\contract\v1\ANetApiRequestType:private] =>
)

 Wed, 01 Mar 2017 11:56:40 +0000 INFO : [execute] (/var/www/sandbox/application/libraries/authorize.net.ach/vendor/authorizenet/authorizenet/lib/net/authorize/api/controller/base/ApiOperationBase.php : 116) - Request  Serialization End
 Wed, 01 Mar 2017 11:56:40 +0000 INFO : [_sendRequest] (/var/www/sandbox/application/libraries/authorize.net.ach/vendor/authorizenet/authorizenet/lib/net/authorize/util/HttpClient.php : 78) -  Url: https://api2.authorize.net/xml/v1/request.api
 Wed, 01 Mar 2017 11:56:40 +0000 INFO : [_sendRequest] (/var/www/sandbox/application/libraries/authorize.net.ach/vendor/authorizenet/authorizenet/lib/net/authorize/util/HttpClient.php : 80) - Request to AnetApi:
<?xml version="1.0" encoding="UTF-8"?>
<getSettledBatchListRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
  <merchantAuthentication>
    <name><![CDATA[xxxx]]></name>
    <transactionKey>xxxx</transactionKey>
  </merchantAuthentication>
  <includeStatistics>true</includeStatistics>
  <firstSettlementDate>2017-02-10T00:15:30-08:00</firstSettlementDate>
  <lastSettlementDate>2017-02-15T00:15:30-08:00</lastSettlementDate>
</getSettledBatchListRequest>

 Wed, 01 Mar 2017 11:56:40 +0000 INFO : [_sendRequest] (/var/www/sandbox/application/libraries/authorize.net.ach/vendor/authorizenet/authorizenet/lib/net/authorize/util/HttpClient.php : 92) - Sending 'XML' Request type
 Wed, 01 Mar 2017 11:56:40 +0000 INFO : [_sendRequest] (/var/www/sandbox/application/libraries/authorize.net.ach/vendor/authorizenet/authorizenet/lib/net/authorize/util/HttpClient.php : 97) - Sending http request via Curl
 Wed, 01 Mar 2017 11:56:41 +0000 INFO : [_sendRequest] (/var/www/sandbox/application/libraries/authorize.net.ach/vendor/authorizenet/authorizenet/lib/net/authorize/util/HttpClient.php : 99) - Response from AnetApi: <?xml version="1.0" encoding="utf-8"?><getSettledBatchListResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"><messages><resultCode>Ok</resultCode><message><code>I00001</code><text>Successful.</text></message></messages><batchList><batch><batchId>615042233</batchId><settlementTimeUTC>2017-02-11T01:19:26Z</settlementTimeUTC><settlementTimeLocal>2017-02-10T17:19:26</settlementTimeLocal><settlementState>settledSuccessfully</settlementState><paymentMethod>eCheck</paymentMethod><statistics><statistic><accountType>eCheck</accountType><chargeAmount>171.12</chargeAmount><chargeCount>1</chargeCount><refundAmount>0.00</refundAmount><refundCount>0</refundCount><voidCount>0</voidCount><declineCount>0</declineCount><errorCount>0</errorCount><returnedItemAmount>0.00</returnedItemAmount><returnedItemCount>0</returnedItemCount><chargebackAmount>0.00</chargebackAmount><chargebackCount>0</chargebackCount><correctionNoticeCount>0</correctionNoticeCount><chargeChargeBackAmount>0.00</chargeChargeBackAmount><chargeChargeBackCount>0</chargeChargeBackCount><refundChargeBackAmount>0.00</refundChargeBackAmount><refundChargeBackCount>0</refundChargeBackCount><chargeReturnedItemsAmount>463.50</chargeReturnedItemsAmount><chargeReturnedItemsCount>1</chargeReturnedItemsCount><refundReturnedItemsAmount>0.00</refundReturnedItemsAmount><refundReturnedItemsCount>0</refundReturnedItemsCount></statistic></statistics></batch><batch><batchId>615043893</batchId><settlementTimeUTC>2017-02-11T01:22:54Z</settlementTimeUTC><settlementTimeLocal>2017-02-10T17:22:54</settlementTimeLocal><settlementState>settledSuccessfully</settlementState><paymentMethod>creditCard</paymentMethod><marketType>MOTO</marketType><product>Card Not Present</product><statistics><statistic><accountType>AmericanExpress</accountType><chargeAmount>10252.93</chargeAmount><chargeCount>2</chargeCount><refundAmount>0.00</refundAmount><refundCount>0</refundCount><voidCount>0</voidCount><declineCount>0</declineCount><errorCount>0</errorCount></statistic><statistic><accountType>Discover</accountType><chargeAmount>0.00</chargeAmount><chargeCount>0</chargeCount><refundAmount>0.00</refundAmount><refundCount>0</refundCount><voidCount>0</voidCount><declineCount>1</declineCount><errorCount>0</errorCount></statistic><statistic><accountType>MasterCard</accountType><chargeAmount>397.00</chargeAmount><chargeCount>1</chargeCount><refundAmount>0.00</refundAmount><refundCount>0</refundCount><voidCount>0</voidCount><declineCount>1</declineCount><errorCount>0</errorCount></statistic><statistic><accountType>Visa</accountType><chargeAmount>0.00</chargeAmount><chargeCount>0</chargeCount><refundAmount>0.00</refundAmount><refundCount>0</refundCount><voidCount>0</voidCount><declineCount>3</declineCount><errorCount>0</errorCount></statistic></statistics></batch><batch><batchId>615386282</batchId><settlementTimeUTC>2017-02-14T01:13:25Z</settlementTimeUTC><settlementTimeLocal>2017-02-13T17:13:25</settlementTimeLocal><settlementState>settledSuccessfully</settlementState><paymentMethod>eCheck</paymentMethod><statistics><statistic><accountType>eCheck</accountType><chargeAmount>11308.93</chargeAmount><chargeCount>16</chargeCount><refundAmount>0.00</refundAmount><refundCount>0</refundCount><voidCount>0</voidCount><declineCount>0</declineCount><errorCount>0</errorCount><returnedItemAmount>0.00</returnedItemAmount><returnedItemCount>0</returnedItemCount><chargebackAmount>0.00</chargebackAmount><chargebackCount>0</chargebackCount><correctionNoticeCount>0</correctionNoticeCount><chargeChargeBackAmount>1747.00</chargeChargeBackAmount><chargeChargeBackCount>1</chargeChargeBackCount><refundChargeBackAmount>0.00</refundChargeBackAmount><refundChargeBackCount>0</refundChargeBackCount><chargeReturnedItemsAmount>0.00</chargeReturnedItemsAmount><chargeReturnedItemsCount>0</chargeReturnedItemsCount><refundReturnedItemsAmount>0.00</refundReturnedItemsAmount><refundReturnedItemsCount>0</refundReturnedItemsCount></statistic></statistics></batch><batch><batchId>615386576</batchId><settlementTimeUTC>2017-02-14T01:14:18Z</settlementTimeUTC><settlementTimeLocal>2017-02-13T17:14:18</settlementTimeLocal><settlementState>settledSuccessfully</settlementState><paymentMethod>creditCard</paymentMethod><marketType>MOTO</marketType><product>Card Not Present</product><statistics><statistic><accountType>AmericanExpress</accountType><chargeAmount>85471.86</chargeAmount><chargeCount>116</chargeCount><refundAmount>0.00</refundAmount><refundCount>0</refundCount><voidCount>0</voidCount><declineCount>3</declineCount><errorCount>0</errorCount></statistic><statistic><accountType>Discover</accountType><chargeAmount>4141.33</chargeAmount><chargeCount>8</chargeCount><refundAmount>0.00</refundAmount><refundCount>0</refundCount><voidCount>0</voidCount><declineCount>3</declineCount><errorCount>0</errorCount></statistic><statistic><accountType>MasterCard</accountType><chargeAmount>91226.03</chargeAmount><chargeCount>126</chargeCount><refundAmount>0.00</refundAmount><refundCount>0</refundCount><voidCount>0</voidCount><declineCount>16</declineCount><errorCount>0</errorCount></statistic><statistic><accountType>Visa</accountType><chargeAmount>303490.90</chargeAmount><chargeCount>409</chargeCount><refundAmount>0.00</refundAmount><refundCount>0</refundCount><voidCount>0</voidCount><declineCount>31</declineCount><errorCount>0</errorCount></statistic></statistics></batch><batch><batchId>615527836</batchId><settlementTimeUTC>2017-02-15T01:15:51Z</settlementTimeUTC><settlementTimeLocal>2017-02-14T17:15:51</settlementTimeLocal><settlementState>settledSuccessfully</settlementState><paymentMethod>eCheck</paymentMethod><statistics><statistic><accountType>eCheck</accountType><chargeAmount>595.50</chargeAmount><chargeCount>2</chargeCount><refundAmount>0.00</refundAmount><refundCount>0</refundCount><voidCount>0</voidCount><declineCount>0</declineCount><errorCount>0</errorCount><returnedItemAmount>0.00</returnedItemAmount><returnedItemCount>0</returnedItemCount><chargebackAmount>0.00</chargebackAmount><chargebackCount>0</chargebackCount><correctionNoticeCount>0</correctionNoticeCount><chargeChargeBackAmount>0.00</chargeChargeBackAmount><chargeChargeBackCount>0</chargeChargeBackCount><refundChargeBackAmount>0.00</refundChargeBackAmount><refundChargeBackCount>0</refundChargeBackCount><chargeReturnedItemsAmount>0.00</chargeReturnedItemsAmount><chargeReturnedItemsCount>0</chargeReturnedItemsCount><refundReturnedItemsAmount>0.00</refundReturnedItemsAmount><refundReturnedItemsCount>0</refundReturnedItemsCount></statistic></statistics></batch><batch><batchId>615528519</batchId><settlementTimeUTC>2017-02-15T01:17:29Z</settlementTimeUTC><settlementTimeLocal>2017-02-14T17:17:29</settlementTimeLocal><settlementState>settledSuccessfully</settlementState><paymentMethod>creditCard</paymentMethod><marketType>MOTO</marketType><product>Card Not Present</product><statistics><statistic><accountType>AmericanExpress</accountType><chargeAmount>37913.75</chargeAmount><chargeCount>20</chargeCount><refundAmount>0.00</refundAmount><refundCount>0</refundCount><voidCount>2</voidCount><declineCount>0</declineCount><errorCount>0</errorCount></statistic><statistic><accountType>Discover</accountType><chargeAmount>206.40</chargeAmount><chargeCount>1</chargeCount><refundAmount>0.00</refundAmount><refundCount>0</refundCount><voidCount>0</voidCount><declineCount>0</declineCount><errorCount>0</errorCount></statistic><statistic><accountType>MasterCard</accountType><chargeAmount>10231.20</chargeAmount><chargeCount>8</chargeCount><refundAmount>0.00</refundAmount><refundCount>0</refundCount><voidCount>0</voidCount><declineCount>6</declineCount><errorCount>0</errorCount></statistic><statistic><accountType>Visa</accountType><chargeAmount>15101.86</chargeAmount><chargeCount>13</chargeCount><refundAmount>0.00</refundAmount><refundCount>0</refundCount><voidCount>0</voidCount><declineCount>14</declineCount><errorCount>0</errorCount></statistic></statistics></batch></batchList></getSettledBatchListResponse>
 Wed, 01 Mar 2017 11:56:41 +0000 INFO : [execute] (/var/www/sandbox/application/libraries/authorize.net.ach/vendor/authorizenet/authorizenet/lib/net/authorize/api/controller/base/ApiOperationBase.php : 126) - Response De-Serialization Begin
 Wed, 01 Mar 2017 11:56:41 +0000 INFO : [execute] (/var/www/sandbox/application/libraries/authorize.net.ach/vendor/authorizenet/authorizenet/lib/net/authorize/api/controller/base/ApiOperationBase.php : 128) - Response De-Serialization End
 Wed, 01 Mar 2017 11:56:41 +0000 INFO : [execute] (/var/www/sandbox/application/libraries/authorize.net.ach/vendor/authorizenet/authorizenet/lib/net/authorize/api/controller/base/ApiOperationBase.php : 113) - Request Serialization Begin
 Wed, 01 Mar 2017 11:56:41 +0000 DEBUG : [execute] (/var/www/sandbox/application/libraries/authorize.net.ach/vendor/authorizenet/authorizenet/lib/net/authorize/api/controller/base/ApiOperationBase.php : 114) - net\authorize\api\contract\v1\GetTransactionListRequest Object
(
    [batchId:net\authorize\api\contract\v1\GetTransactionListRequest:private] => 615042233
    [merchantAuthentication:net\authorize\api\contract\v1\ANetApiRequestType:private] => net\authorize\api\contract\v1\MerchantAuthenticationType Object
        (
            [name:net\authorize\api\contract\v1\MerchantAuthenticationType:private] => xxxx
            [transactionKey:net\authorize\api\contract\v1\MerchantAuthenticationType:private] => xxxx
            [sessionToken:net\authorize\api\contract\v1\MerchantAuthenticationType:private] =>
            [password:net\authorize\api\contract\v1\MerchantAuthenticationType:private] =>
            [impersonationAuthentication:net\authorize\api\contract\v1\MerchantAuthenticationType:private] =>
            [fingerPrint:net\authorize\api\contract\v1\MerchantAuthenticationType:private] =>
            [mobileDeviceId:net\authorize\api\contract\v1\MerchantAuthenticationType:private] =>
        )

    [refId:net\authorize\api\contract\v1\ANetApiRequestType:private] =>
)

 Wed, 01 Mar 2017 11:56:41 +0000 INFO : [execute] (/var/www/sandbox/application/libraries/authorize.net.ach/vendor/authorizenet/authorizenet/lib/net/authorize/api/controller/base/ApiOperationBase.php : 116) - Request  Serialization End
 Wed, 01 Mar 2017 11:56:41 +0000 INFO : [_sendRequest] (/var/www/sandbox/application/libraries/authorize.net.ach/vendor/authorizenet/authorizenet/lib/net/authorize/util/HttpClient.php : 78) -  Url: https://api2.authorize.net/xml/v1/request.api
 Wed, 01 Mar 2017 11:56:41 +0000 INFO : [_sendRequest] (/var/www/sandbox/application/libraries/authorize.net.ach/vendor/authorizenet/authorizenet/lib/net/authorize/util/HttpClient.php : 80) - Request to AnetApi:
<?xml version="1.0" encoding="UTF-8"?>
<getTransactionListRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
  <merchantAuthentication>
    <name><![CDATA[xxxx]]></name>
    <transactionKey>xxxx</transactionKey>
  </merchantAuthentication>
  <batchId><![CDATA[615042233]]></batchId>
</getTransactionListRequest>

 Wed, 01 Mar 2017 11:56:41 +0000 INFO : [_sendRequest] (/var/www/sandbox/application/libraries/authorize.net.ach/vendor/authorizenet/authorizenet/lib/net/authorize/util/HttpClient.php : 92) - Sending 'XML' Request type
 Wed, 01 Mar 2017 11:56:41 +0000 INFO : [_sendRequest] (/var/www/sandbox/application/libraries/authorize.net.ach/vendor/authorizenet/authorizenet/lib/net/authorize/util/HttpClient.php : 97) - Sending http request via Curl
 Wed, 01 Mar 2017 11:56:42 +0000 INFO : [_sendRequest] (/var/www/sandbox/application/libraries/authorize.net.ach/vendor/authorizenet/authorizenet/lib/net/authorize/util/HttpClient.php : 99) - Response from AnetApi: <?xml version="1.0" encoding="utf-8"?><getTransactionListResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"><messages><resultCode>Ok</resultCode><message><code>I00001</code><text>Successful.</text></message></messages><transactions><transaction><transId>20416103216</transId><submitTimeUTC>2017-02-10T22:32:11Z</submitTimeUTC><submitTimeLocal>2017-02-10T14:32:11</submitTimeLocal><transactionStatus>returnedItem</transactionStatus><invoiceNumber>97116</invoiceNumber><firstName>Wilson</firstName><lastName>Stephens</lastName><accountType>eCheck</accountType><accountNumber>xxxx-8535</accountNumber><settleAmount>171.12</settleAmount><hasReturnedItems>false</hasReturnedItems></transaction></transactions><totalNumInResultSet>2</totalNumInResultSet></getTransactionListResponse>
 Wed, 01 Mar 2017 11:56:42 +0000 INFO : [execute] (/var/www/sandbox/application/libraries/authorize.net.ach/vendor/authorizenet/authorizenet/lib/net/authorize/api/controller/base/ApiOperationBase.php : 126) - Response De-Serialization Begin
 Wed, 01 Mar 2017 11:56:42 +0000 INFO : [execute] (/var/www/sandbox/application/libraries/authorize.net.ach/vendor/authorizenet/authorizenet/lib/net/authorize/api/controller/base/ApiOperationBase.php : 128) - Response De-Serialization End

@Aaron@RichardHany solution so far?

Have you check your Time zone. 

both the first and last dates must be in the same time zone
a date constructed from an ISO8601 format date string

I think is the time zone that is causing you problems

both the first and last dates must be in the same time zone
a date constructed from an ISO8601 format date string