Skip to content

Commit 27cbe9e

Browse files
committed
fix and cleanup get-transaction-list; add back to sample code tests
1 parent 575efce commit 27cbe9e

File tree

2 files changed

+26
-20
lines changed

2 files changed

+26
-20
lines changed

TransactionReporting/get-transaction-list.rb

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ def get_transaction_List()
1010

1111
transaction1 = AuthorizeNet::API::Transaction.new(config['api_login_id'], config['api_transaction_key'], :gateway => :sandbox)
1212

13-
batchId = "4606008"
14-
#batchId = "4551107"
13+
batchId = "7590305"
1514
request = AuthorizeNet::API::GetTransactionListRequest.new
1615
request.batchId = batchId
1716
request.paging = Paging.new;
@@ -20,28 +19,35 @@ def get_transaction_List()
2019
request.paging.offset = 1;
2120

2221
request.sorting = TransactionListSorting.new;
23-
request.sorting.orderBy = TransactionListOrderFieldEnum.Id;
22+
request.sorting.orderBy = TransactionListOrderFieldEnum::Id;
2423
request.sorting.orderDescending = true;
2524

2625
response = transaction1.get_transaction_list(request)
27-
28-
if response.messages.resultCode == MessageTypeEnum::Ok
29-
transactions = response.transactions
30-
if transactions == nil
31-
puts "#{response.messages.messages[0].text}"
32-
else
33-
response.transactions.transaction.each do |trans|
34-
puts "\nTransaction ID : #{trans.transId} "
35-
puts "Submitted on (Local) : %s " %[trans.submitTimeUTC]
36-
puts "Status : #{trans.transactionStatus} "
37-
puts "Settle Amount : %.2f " %[trans.settleAmount]
38-
end
39-
end
26+
27+
if response != nil
28+
if response.messages.resultCode == MessageTypeEnum::Ok
29+
if response.transactions == nil
30+
puts "#{response.messages.messages[0].text}"
31+
else
32+
puts "Successfully got the list of transactions for batch " + batchId + "."
33+
response.transactions.transaction.each do |trans|
34+
puts "Transaction ID: #{trans.transId} "
35+
puts " Submitted on (Local): %s " % [trans.submitTimeUTC]
36+
puts " Status: #{trans.transactionStatus} "
37+
puts " Settle Amount: %.2f " % [trans.settleAmount]
38+
end
39+
end
40+
else
41+
puts "Error: Failed to get Transaction List."
42+
puts "Error Text: #{response.messages.messages[0].text}"
43+
puts "Error Code: #{response.messages.messages[0].code}"
44+
end
4045
else
41-
puts "Error: Failed to get Transaction List\n"
42-
puts "Error Text : #{response.messages.messages[0].text} \n"
43-
puts "Error Code : #{response.messages.messages[0].code} "
46+
puts "Error: Failed to get Transaction List."
47+
puts "Error Text: #{response.messages.messages[0].text}"
48+
puts "Error Code: #{response.messages.messages[0].code}"
4449
end
50+
4551
return response
4652

4753
end

spec/sample_code_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def validate_response(response= nil)
246246
response = get_transaction_Details()
247247
validate_response(response)
248248

249-
#response = get_transaction_List()
249+
response = get_transaction_List()
250250
validate_response(response)
251251

252252
response = get_unsettled_transaction_List()

0 commit comments

Comments
 (0)