1+ <?php
2+ require 'vendor/autoload.php ' ;
3+ use net \authorize \api \contract \v1 as AnetAPI ;
4+ use net \authorize \api \controller as AnetController ;
5+ define ("AUTHORIZENET_LOG_FILE " , "phplog " );
6+
7+ // Common Set Up for API Credentials
8+ $ merchantAuthentication = new AnetAPI \MerchantAuthenticationType ();
9+ $ merchantAuthentication ->setName ( "5KP3u95bQpv " );
10+ $ merchantAuthentication ->setTransactionKey ("4Ktq966gC55GAX7S " );
11+ $ refId = 'ref ' . time ();
12+
13+ //Setting a valid batch Id for the Merchant
14+ $ batchId = "4532808 " ;
15+
16+ // Creating a request
17+ $ request = new AnetAPI \GetBatchStatisticsRequest ();
18+ $ request ->setMerchantAuthentication ($ merchantAuthentication );
19+ $ request ->setBatchId ($ batchId );
20+
21+ //Creating the controller
22+ $ controller = new AnetController \GetBatchStatisticsController ($ request );
23+
24+ //Retrieving response
25+ $ response = $ controller ->executeWithApiResponse ( \net \authorize \api \constants \ANetEnvironment::SANDBOX );
26+
27+ if (($ response != null ) && ($ response ->getMessages ()->getResultCode () == "Ok " ))
28+ {
29+ echo "SUCCESS: Successfully got the list of subscriptions : \n\n" ;
30+ echo "Batch ID : " . $ response ->getBatch ()->getBatchId () . "\n" ;
31+ echo "Settlement Time : " . date_format ($ response ->getBatch ()->getSettlementTimeUTC (),"Y/m/d H:i:s " ) . "\n" ;
32+ echo "Settlement state : " . $ response ->getBatch ()->getSettlementState () . "\n" ;
33+ echo "Payment Method : " . $ response ->getBatch ()->getPaymentMethod () . "\n" ;
34+ echo "Statistic Details: " ;
35+ //Displaying the details of each transaction in the list
36+ foreach ($ response ->getBatch ()->getStatistics () as $ statistics )
37+ {
38+ echo " Account Type : " . $ statistics ->getAccountType () . "\n" ;
39+ echo " Charge Amount : " . $ statistics ->getChargeAmount () . "\n" ;
40+ echo " Charge Count : " . $ statistics ->getChargeCount () . "\n" ;
41+ echo " Refund Amount : " . $ statistics ->getRefundAmount () . "\n" ;
42+ echo " Refund Count : " . $ statistics ->getRefundCount () . "\n" ;
43+ echo " Void Count : " . $ statistics ->getRefundCount () . "\n" ;
44+ echo " Decline Count : " . $ statistics ->getRefundCount () . "\n" ;
45+ echo " Error Count : " . $ statistics ->getRefundCount () . "\n" ;
46+ }
47+ }
48+ else
49+ {
50+ echo "ERROR : Failed to get the batch statistics \n" ;
51+ echo "Response : " . $ response ->getMessages ()->getMessage ()[0 ]->getCode () . " " .$ response ->getMessages ()->getMessage ()[0 ]->getText () . "\n" ;
52+
53+ }
54+ ?>
0 commit comments