Skip to content

Commit 554985f

Browse files
Sample code for API updates.
1 parent 703aa85 commit 554985f

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
require 'rubygems'
2+
require 'yaml'
3+
require 'authorizenet'
4+
5+
require 'securerandom'
6+
7+
include AuthorizeNet::API
8+
9+
def get_Transaction_List_For_Customer(customerProfileId = '40036377')
10+
config = YAML.load_file(File.dirname(__FILE__) + "/../credentials.yml")
11+
12+
transaction1 = AuthorizeNet::API::Transaction.new(config['api_login_id'], config['api_transaction_key'], :gateway => :sandbox)
13+
14+
request = AuthorizeNet::API::GetTransactionListForCustomerRequest.new
15+
request.customerProfileId = customerProfileId
16+
request.paging = Paging.new;
17+
request.paging.limit = 10;
18+
request.paging.offset = 1;
19+
20+
request.sorting = TransactionListSorting.new;
21+
request.sorting.orderBy = "id";
22+
request.sorting.orderDescending = true;
23+
24+
response = transaction1.get_transaction_list_for_customer(request)
25+
26+
if response.messages.resultCode == MessageTypeEnum::Ok
27+
transactions = response.transactions
28+
if transactions == nil
29+
puts "#{response.messages.messages[0].text}"
30+
else
31+
response.transactions.transaction.each do |trans|
32+
puts "\nTransaction ID : #{trans.transId} "
33+
puts "Submitted on (Local) : %s " %[trans.submitTimeUTC]
34+
puts "Status : #{trans.transactionStatus} "
35+
puts "Settle Amount : %.2f " %[trans.settleAmount]
36+
end
37+
end
38+
else
39+
puts "Error : Failed to get Transaction List for customer\n"
40+
puts "Error Text : #{response.messages.messages[0].text} \n"
41+
puts "Error Code : #{response.messages.messages[0].code} "
42+
end
43+
return response
44+
45+
end
46+
47+
48+
if __FILE__ == $0
49+
get_Transaction_List_For_Customer()
50+
end

spec/sample_code_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,9 @@ def validate_response(response= nil)
246246

247247
response = get_unsettled_transaction_List()
248248
validate_response(response)
249+
250+
response = get_Transaction_List_For_Customer()
251+
validate_response(response)
249252

250253
end
251254

0 commit comments

Comments
 (0)