1+ require 'rubygems'
2+ require 'yaml'
3+ require 'authorizenet'
4+
5+ include AuthorizeNet ::API
6+
7+ config = YAML . load_file ( File . dirname ( __FILE__ ) + "/../credentials.yml" )
8+
9+ transaction = Transaction . new ( config [ 'api_login_id' ] , config [ 'api_transaction_key' ] , :gateway => :sandbox )
10+
11+ batchId = "4532808"
12+ request = GetBatchStatisticsRequest . new
13+ request . batchId = batchId
14+
15+ #standard api call to retrieve response
16+ response = transaction . get_batch_statistics ( request )
17+
18+
19+ if response != nil
20+ if response . messages . resultCode == MessageTypeEnum ::Ok
21+ puts "Successfully got the list of subscriptions"
22+ puts response . messages . messages [ 0 ] . code
23+ puts response . messages . messages [ 0 ] . text
24+ puts response . batch . batchId
25+ puts response . batch . settlementTimeUTC
26+ puts response . batch . settlementTimeLocal
27+ puts response . batch . settlementState
28+ puts response . batch . paymentMethod
29+ for i in 0 ..response . batch . statistics . length -1
30+ puts "Statistic Details::"
31+ puts "Account Type: " + response . batch . statistics [ i ] . accountType
32+ puts "Charge Amount: " + response . batch . statistics [ i ] . chargeAmount
33+ puts "Charge Count: " + response . batch . statistics [ i ] . chargeCount
34+ puts "Refund Amount: " + response . batch . statistics [ i ] . refundAmount
35+ puts "Refund Count: " + response . batch . statistics [ i ] . refundCount
36+ puts "Void Count: " + response . batch . statistics [ i ] . voidCount
37+ puts "Decline Count: " + response . batch . statistics [ i ] . declineCount
38+ puts "Error Count: " + response . batch . statistics [ i ] . errorCount
39+ end
40+
41+
42+ else
43+
44+ puts response . messages . messages [ 0 ] . code
45+ puts response . messages . messages [ 0 ] . text
46+ raise "Failed to get the batch statistics"
47+ end
48+ end
0 commit comments