authorizenetsample 1.1.6 → 1.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/CustomerProfiles/create-customer-payment-profile.rb +62 -0
- data/lib/CustomerProfiles/create-customer-profile-from-transaction.rb +51 -0
- data/lib/CustomerProfiles/create-customer-profile.rb +92 -0
- data/lib/CustomerProfiles/create-customer-shipping-address.rb +31 -0
- data/lib/CustomerProfiles/delete-customer-payment-profile.rb +32 -0
- data/lib/CustomerProfiles/delete-customer-profile.rb +31 -0
- data/lib/CustomerProfiles/delete-customer-shipping-address.rb +33 -0
- data/lib/CustomerProfiles/get-accept-customer-profile-page.rb +23 -5
- data/lib/CustomerProfiles/get-customer-payment-profile-list.rb +54 -0
- data/lib/CustomerProfiles/get-customer-payment-profile.rb +40 -0
- data/lib/CustomerProfiles/get-customer-profile-ids.rb +45 -0
- data/lib/CustomerProfiles/get-customer-profile.rb +39 -3
- data/lib/CustomerProfiles/get-customer-shipping-address.rb +41 -0
- data/lib/CustomerProfiles/update-customer-payment-profile.rb +37 -0
- data/lib/CustomerProfiles/update-customer-profile.rb +37 -0
- data/lib/CustomerProfiles/update-customer-shipping-address.rb +37 -0
- data/lib/CustomerProfiles/validate-customer-payment-profile.rb +37 -0
- data/lib/FraudManagement/approve-or-decline-held-transaction.rb +57 -0
- data/lib/FraudManagement/get-held-transaction-list.rb +47 -0
- data/lib/MobileInAppTransactions/create-an-accept-transaction.rb +59 -0
- data/lib/MobileInAppTransactions/create-an-android-pay-transaction.rb +59 -0
- data/lib/MobileInAppTransactions/create-an-apple-pay-transaction.rb +58 -0
- data/lib/PayPalExpressCheckout/authorization-and-capture-continued.rb +69 -0
- data/lib/PayPalExpressCheckout/authorization-and-capture.rb +70 -0
- data/lib/PayPalExpressCheckout/authorization-only-continued.rb +70 -0
- data/lib/PayPalExpressCheckout/authorization-only.rb +71 -0
- data/lib/PayPalExpressCheckout/credit.rb +67 -0
- data/lib/PayPalExpressCheckout/get-details.rb +69 -0
- data/lib/PayPalExpressCheckout/prior-authorization-capture.rb +112 -0
- data/lib/PayPalExpressCheckout/void.rb +113 -0
- data/lib/PaymentTransactions/authorize-credit-card.rb +103 -0
- data/lib/PaymentTransactions/capture-funds-authorized-through-another-channel.rb +60 -0
- data/lib/PaymentTransactions/capture-previously-authorized-amount.rb +104 -0
- data/lib/PaymentTransactions/charge-credit-card.rb +104 -0
- data/lib/PaymentTransactions/charge-customer-profile.rb +61 -0
- data/lib/PaymentTransactions/charge-tokenized-credit-card.rb +60 -0
- data/lib/PaymentTransactions/create-an-accept-payment-transaction.rb +47 -6
- data/lib/PaymentTransactions/credit-bank-account.rb +62 -0
- data/lib/PaymentTransactions/debit-bank-account.rb +64 -0
- data/lib/PaymentTransactions/get-an-accept-payment-page.rb +70 -49
- data/lib/PaymentTransactions/refund-transaction.rb +60 -0
- data/lib/PaymentTransactions/update-split-tender-group.rb +44 -0
- data/lib/PaymentTransactions/void-transaction.rb +103 -0
- data/lib/RecurringBilling/cancel-subscription.rb +36 -0
- data/lib/RecurringBilling/create-subscription-from-customer-profile.rb +52 -0
- data/lib/RecurringBilling/create-subscription.rb +54 -0
- data/lib/RecurringBilling/get-list-of-subscriptions.rb +51 -0
- data/lib/RecurringBilling/get-subscription-status.rb +36 -0
- data/lib/RecurringBilling/get-subscription.rb +42 -0
- data/lib/RecurringBilling/update-subscription.rb +54 -0
- data/lib/TransactionReporting/get-batch-statistics.rb +57 -0
- data/lib/TransactionReporting/get-customer-profile-transaction-list.rb +49 -0
- data/lib/TransactionReporting/get-merchant-details.rb +50 -0
- data/lib/TransactionReporting/get-settled-batch-list.rb +49 -0
- data/lib/TransactionReporting/get-transaction-details.rb +40 -0
- data/lib/TransactionReporting/get-transaction-list.rb +58 -0
- data/lib/TransactionReporting/get-unsettled-transaction-list.rb +48 -0
- data/lib/VisaCheckout/create-visa-checkout-transaction.rb +62 -0
- data/lib/VisaCheckout/decrypt-visa-checkout-data.rb +37 -0
- data/lib/authorize_netsample.rb +21 -0
- data/lib/authorizenetsample.rb +4 -12
- data/lib/credentials.yml +9 -0
- data/lib/spec/sample_code_spec.rb +320 -0
- data/lib/spec/spec.opts +2 -0
- data/lib/spec/spec_helper.rb +10 -0
- data/lib/spec/support/shared_helper.rb +7 -0
- metadata +69 -6
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'yaml'
|
3
|
+
require 'authorizenet'
|
4
|
+
require 'securerandom'
|
5
|
+
require "date"
|
6
|
+
|
7
|
+
include AuthorizeNet::API
|
8
|
+
|
9
|
+
def get_settled_batch_List()
|
10
|
+
config = YAML.load_file(File.dirname(__FILE__) + "/../credentials.yml")
|
11
|
+
|
12
|
+
transaction = AuthorizeNet::API::Transaction.new(config['api_login_id'], config['api_transaction_key'], :gateway => :sandbox)
|
13
|
+
|
14
|
+
firstSettlementDate = DateTime.now()-(1 * 7)
|
15
|
+
lastSettlementDate = DateTime.now()
|
16
|
+
|
17
|
+
puts "First settlement date: #{firstSettlementDate} Last settlement date: #{lastSettlementDate}"
|
18
|
+
|
19
|
+
request = GetSettledBatchListRequest.new
|
20
|
+
request.firstSettlementDate = firstSettlementDate
|
21
|
+
request.lastSettlementDate = lastSettlementDate
|
22
|
+
request.includeStatistics = true
|
23
|
+
|
24
|
+
response = transaction.get_settled_batch_list(request)
|
25
|
+
|
26
|
+
if response.messages.resultCode == MessageTypeEnum::Ok
|
27
|
+
|
28
|
+
response.batchList.batch.each do |batch|
|
29
|
+
puts "Transaction Id: #{batch.batchId}"
|
30
|
+
puts "Settlement Date: #{batch.settlementTimeUTC}"
|
31
|
+
puts "State: #{batch.settlementState}"
|
32
|
+
puts "Account Type: #{batch.statistics[0].accountType}"
|
33
|
+
puts ""
|
34
|
+
end
|
35
|
+
else
|
36
|
+
puts response.messages.messages[0].code
|
37
|
+
puts response.messages.messages[0].text
|
38
|
+
raise "Failed to fetch settled batch list"
|
39
|
+
end
|
40
|
+
|
41
|
+
return response
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
if __FILE__ == $0
|
48
|
+
get_settled_batch_List()
|
49
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'yaml'
|
3
|
+
require 'authorizenet'
|
4
|
+
require 'securerandom'
|
5
|
+
|
6
|
+
include AuthorizeNet::API
|
7
|
+
|
8
|
+
def get_transaction_Details()
|
9
|
+
config = YAML.load_file(File.dirname(__FILE__) + "/../credentials.yml")
|
10
|
+
|
11
|
+
transaction = AuthorizeNet::API::Transaction.new(config['api_login_id'], config['api_transaction_key'], :gateway => :sandbox)
|
12
|
+
|
13
|
+
transId = "60032208160"
|
14
|
+
request = GetTransactionDetailsRequest.new
|
15
|
+
request.transId = transId
|
16
|
+
|
17
|
+
#standard api call to retrieve response
|
18
|
+
response = transaction.get_transaction_details(request)
|
19
|
+
|
20
|
+
if response.messages.resultCode == MessageTypeEnum::Ok
|
21
|
+
puts "Get Transaction Details Successful "
|
22
|
+
puts "Transaction Id: #{response.transaction.transId}"
|
23
|
+
puts "Transaction Type: #{response.transaction.transactionType}"
|
24
|
+
puts "Transaction Status: #{response.transaction.transactionStatus}"
|
25
|
+
puts "Description: #{response.transaction.order.description}"
|
26
|
+
printf("Auth Amount: %.2f\n", response.transaction.authAmount)
|
27
|
+
printf("Settle Amount: %.2f\n", response.transaction.settleAmount)
|
28
|
+
else
|
29
|
+
puts response.messages.messages[0].code
|
30
|
+
puts response.messages.messages[0].text
|
31
|
+
raise "Failed to get transaction Details."
|
32
|
+
end
|
33
|
+
|
34
|
+
return response
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
if __FILE__ == $0
|
39
|
+
get_transaction_Details()
|
40
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'yaml'
|
3
|
+
require 'authorizenet'
|
4
|
+
require 'securerandom'
|
5
|
+
|
6
|
+
include AuthorizeNet::API
|
7
|
+
|
8
|
+
def get_transaction_List()
|
9
|
+
config = YAML.load_file(File.dirname(__FILE__) + "/../credentials.yml")
|
10
|
+
|
11
|
+
transaction1 = AuthorizeNet::API::Transaction.new(config['api_login_id'], config['api_transaction_key'], :gateway => :sandbox)
|
12
|
+
|
13
|
+
batchId = "7590305"
|
14
|
+
request = AuthorizeNet::API::GetTransactionListRequest.new
|
15
|
+
request.batchId = batchId
|
16
|
+
request.paging = Paging.new;
|
17
|
+
# Paging limit can be up to 1000 for this request
|
18
|
+
request.paging.limit = '20'
|
19
|
+
request.paging.offset = 1;
|
20
|
+
|
21
|
+
request.sorting = TransactionListSorting.new;
|
22
|
+
request.sorting.orderBy = TransactionListOrderFieldEnum::Id;
|
23
|
+
request.sorting.orderDescending = true;
|
24
|
+
|
25
|
+
response = transaction1.get_transaction_list(request)
|
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
|
45
|
+
else
|
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}"
|
49
|
+
end
|
50
|
+
|
51
|
+
return response
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
if __FILE__ == $0
|
57
|
+
get_transaction_List()
|
58
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'yaml'
|
3
|
+
require 'authorizenet'
|
4
|
+
require 'securerandom'
|
5
|
+
|
6
|
+
include AuthorizeNet::API
|
7
|
+
|
8
|
+
def get_unsettled_transaction_List()
|
9
|
+
|
10
|
+
config = YAML.load_file(File.dirname(__FILE__) + "/../credentials.yml")
|
11
|
+
#merchant information
|
12
|
+
transaction = AuthorizeNet::API::Transaction.new(config['api_login_id'], config['api_transaction_key'], :gateway => :sandbox)
|
13
|
+
|
14
|
+
request = GetUnsettledTransactionListRequest.new
|
15
|
+
|
16
|
+
request.status = TransactionGroupStatusEnum::ANY;
|
17
|
+
request.paging = Paging.new;
|
18
|
+
# Paging limit can be up to 1000
|
19
|
+
request.paging.limit = '20'
|
20
|
+
request.paging.offset = 1;
|
21
|
+
|
22
|
+
request.sorting = TransactionListSorting.new;
|
23
|
+
request.sorting.orderBy = TransactionListOrderFieldEnum::Id;
|
24
|
+
request.sorting.orderDescending = true;
|
25
|
+
|
26
|
+
response = transaction.get_unsettled_transaction_list(request)
|
27
|
+
|
28
|
+
if response.messages.resultCode == MessageTypeEnum::Ok
|
29
|
+
unsettled_transactions = response.transactions
|
30
|
+
|
31
|
+
response.transactions.transaction.each do |unsettled_transaction|
|
32
|
+
puts "Transaction #{unsettled_transaction.transId} was submitted at #{unsettled_transaction.submitTimeUTC}"
|
33
|
+
|
34
|
+
end
|
35
|
+
puts "Total transaction received #{unsettled_transactions.transaction.length}"
|
36
|
+
else
|
37
|
+
puts "ERROR message: #{response.messages.messages[0].text}"
|
38
|
+
puts "ERROR code: #{response.messages.messages[0].code}"
|
39
|
+
raise "Failed to get unsettled transaction list."
|
40
|
+
end
|
41
|
+
|
42
|
+
return response
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
if __FILE__ == $0
|
47
|
+
get_unsettled_transaction_List()
|
48
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'yaml'
|
3
|
+
require 'authorizenet'
|
4
|
+
require 'securerandom'
|
5
|
+
|
6
|
+
include AuthorizeNet::API
|
7
|
+
|
8
|
+
def create_visa_checkout_transaction()
|
9
|
+
config = YAML.load_file(File.dirname(__FILE__) + "/../credentials.yml")
|
10
|
+
|
11
|
+
transaction = Transaction.new(config['api_login_id'], config['api_transaction_key'], :gateway => :sandbox)
|
12
|
+
|
13
|
+
request = CreateTransactionRequest.new
|
14
|
+
|
15
|
+
request.transactionRequest = TransactionRequestType.new()
|
16
|
+
request.transactionRequest.amount = 16.00
|
17
|
+
request.transactionRequest.payment = PaymentType.new
|
18
|
+
request.transactionRequest.payment.opaqueData = OpaqueDataType.new('COMMON.VCO.ONLINE.PAYMENT','MCOjZ5xX4lW0D9uN5azwGktYlwUMpCkyd7MAWmMVIekZAPa8GRa4C1OC225NWfplk+toHvTu3aCNq89TX/HGn3+wnVC+x2fgA2Eo5Cd9zRU5W1Gp6DoYD2CWpGIBRxHxcfNAmSmtm+UEbwublZi+qn9vqMSFlJg5E5/f5JqmPLq7rvvvTEWPmZBi/Um8PoJ0Ng0KsNzyRVnWGPhJ+XCQeF9KbgNhUFW0NwKNumKiY+LHZSEXZebzlEf9w7tvuZHxuWvh1lq/DZwXj1SKGrv0EQnmCmehJE18+DgP7WCa4Hv/27tYfIA7rA1Krg24MGZNGOxj2pa2zMXyP5m5f69CatC9+pFgYIlGI93YYgAc5yucxNUS6hyCjp4TunvUJ6Cm16bye0MH+6beG1oP4atC6MP++cLzvaSg/61NWGv+EsNRADbZX3Obk/v8L8oe65laIprFnTeS7v5ZPaWBB4G2UUajXP+o1+k9zv14lBFkit0rdLA5LbN2ob8gi5L2DY88qAynZkKcfFgpICqrsR9fVRs/7SAQAqy3y77OiTcERw11rAaEXus0zp/FPRKRevDkjOCrc5c2konp93ZBN3FwcdERf/NJpwGF+Mw5CMA956DJwX/lazc/tKZiWOnAQEhw2FzWxZL1Vzdn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eB3LGdCa44GBs9wenq58touQD5W0nbFprtIivaGHJbDbtXzFgwTmtYfOy8vyqS2c8bFC/gYvF6XqRBILDqUdCJhmgiuDVBzAR+c8DkwV3RKqu7DA0wk9K/TC0WEdyEuN+C0bVWqD2EgJb+tQAS5EibtaAlc3fJzBk9K9AcHFRlEb03EDFj6VwD59Z4Fr4oup8lcJP7/tkJtBHA4Jv33VghWnAhEbj8YE04vu5x/S5sGu0K1RW32GNRtU9JQ050Wrylyq4j9tLqVS04fu5BVEv1k5SzIO4VV+szZer90vXtHxKvGGF3Qqu1qLUuwkNDcaEiQ3zBGvKvGG/XUJpTM2HL7NyLFJgeJ5vxZmwjW7YiFB4au6Ld32jklRmKdlfoZMeSsDsB0WKW6iATvXKURgcAAgaBs/8sRk5S+B8PvvxYhzXgGKeY+GtopSP3f/4RI8NjZROirfyo7ztSqu7BYNL3WJAGY5ozxQVjqPs9rLc/oluv9j0eVZwMqHvAKaVoKByvAoH6qMFMFCkhMkrLDQ8Rq/JXX/ZzanxMB','nxmC7ZfWoAOHx2luMPW+G8xnXMkvDJcRgoAbBOuQrAfG+OnEmgzht3B7AzhjegzmqjtYpVYhjoCNzEjwZv+5AyaeNhAeny9mkx4h5Dc+XIrCT2GB4Q8BBI9AO7XtTd2V')
|
19
|
+
request.transactionRequest.callId = '2751969838440085201'
|
20
|
+
|
21
|
+
request.transactionRequest.transactionType = TransactionTypeEnum::AuthCaptureTransaction
|
22
|
+
|
23
|
+
response = transaction.create_transaction(request)
|
24
|
+
|
25
|
+
if response != nil
|
26
|
+
if response.messages.resultCode == MessageTypeEnum::Ok
|
27
|
+
if response.transactionResponse != nil && response.transactionResponse.messages != nil
|
28
|
+
puts "Successfully made a purchase (authorization code: #{response.transactionResponse.authCode})"
|
29
|
+
puts "Transaction Response code: #{response.transactionResponse.responseCode}"
|
30
|
+
puts "Code: #{response.transactionResponse.messages.messages[0].code}"
|
31
|
+
puts "Description: #{response.transactionResponse.messages.messages[0].description}"
|
32
|
+
else
|
33
|
+
puts "Transaction Failed"
|
34
|
+
if response.transactionResponse.errors != nil
|
35
|
+
puts "Error Code: #{response.transactionResponse.errors.errors[0].errorCode}"
|
36
|
+
puts "Error Message: #{response.transactionResponse.errors.errors[0].errorText}"
|
37
|
+
end
|
38
|
+
raise "Failed to make purchase."
|
39
|
+
end
|
40
|
+
else
|
41
|
+
puts "Transaction Failed"
|
42
|
+
if response.transactionResponse != nil && response.transactionResponse.errors != nil
|
43
|
+
puts "Error Code: #{response.transactionResponse.errors.errors[0].errorCode}"
|
44
|
+
puts "Error Message: #{response.transactionResponse.errors.errors[0].errorText}"
|
45
|
+
else
|
46
|
+
puts "Error Code: #{response.messages.messages[0].code}"
|
47
|
+
puts "Error Message: #{response.messages.messages[0].text}"
|
48
|
+
end
|
49
|
+
raise "Failed to make purchase."
|
50
|
+
end
|
51
|
+
else
|
52
|
+
puts "Response is null"
|
53
|
+
raise "Failed to make purchase."
|
54
|
+
end
|
55
|
+
|
56
|
+
return response
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
if __FILE__ == $0
|
61
|
+
create_visa_checkout_transaction()
|
62
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'yaml'
|
3
|
+
require 'authorizenet'
|
4
|
+
require 'securerandom'
|
5
|
+
|
6
|
+
include AuthorizeNet::API
|
7
|
+
|
8
|
+
def decrypt_visa_checkout_data()
|
9
|
+
config = YAML.load_file(File.dirname(__FILE__) + "/../credentials.yml")
|
10
|
+
|
11
|
+
transaction = Transaction.new(config['api_login_id'], config['api_transaction_key'], :gateway => :sandbox)
|
12
|
+
|
13
|
+
request = DecryptPaymentDataRequest.new
|
14
|
+
request.opaqueData = OpaqueDataType.new('COMMON.VCO.ONLINE.PAYMENT','q1rx4GVCh0dqjZGgSBI8RB/VlI/1lwzTxDnrW/L1D4f/lfKZeQPo34eTB59akZXdRlRBW/dHVWgc2eVebvWpkAKmDrc+7Zr7lGXvHbLG78e0Z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qzCcCFZC9Q','KCSJeIab7wwH7mFcPM/YL+V9xBCDe4CmSjJ0MPHEodpWz4rmz78U8bR4Qqs1ipLBqH9mrfvLF4pytIcLOjKUtXvAII/xCze84INFMdtsVBgtEp5bZ4leehRQhNM+3/NH')
|
15
|
+
request.callId = '1238408836021304101'
|
16
|
+
|
17
|
+
response = transaction.decrypt_payment_data(request)
|
18
|
+
|
19
|
+
|
20
|
+
if response.messages.resultCode == MessageTypeEnum::Ok
|
21
|
+
puts "Successfully decrypted data (Card Number: #{response.cardInfo.cardNumber})"
|
22
|
+
puts "Billing Last Name #{response.billingInfo.lastName}"
|
23
|
+
puts "Shipping Last Name #{response.shippingInfo.lastName}"
|
24
|
+
puts "Amount #{response.paymentDetails.amount}"
|
25
|
+
else
|
26
|
+
puts response.messages.messages[0].code
|
27
|
+
puts response.messages.messages[0].text
|
28
|
+
raise "Failed to decrypt."
|
29
|
+
end
|
30
|
+
|
31
|
+
return response
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
if __FILE__ == $0
|
36
|
+
decrypt_visa_checkout_data()
|
37
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# The SDK initialization enters here. Loads all needed libraries and files. Inspects
|
2
|
+
# the current runtime to see if Rails is present. If it is, we inject our helper into
|
3
|
+
# ActiveSupport.
|
4
|
+
|
5
|
+
# coverall
|
6
|
+
# require 'coveralls'
|
7
|
+
# Coveralls.wear!
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
# TODO: Add local data validation where possible
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift File.dirname(__FILE__)
|
14
|
+
|
15
|
+
require "PaymentTransactions/create-an-accept-payment-transaction.rb"
|
16
|
+
|
17
|
+
require "PaymentTransactions/get-an-accept-payment-page.rb"
|
18
|
+
|
19
|
+
require "CustomerProfiles/get-customer-profile.rb"
|
20
|
+
|
21
|
+
require "CustomerProfiles/get-accept-customer-profile-page.rb"
|
data/lib/authorizenetsample.rb
CHANGED
@@ -1,12 +1,4 @@
|
|
1
|
-
# This file is just here to avoid obnoxious gem name/require name issues. All this
|
2
|
-
# file does is require authorize_netsample.rb, the real initialization file.
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
require "PaymentTransactions/create-an-accept-payment-transaction.rb"
|
7
|
-
|
8
|
-
require "PaymentTransactions/get-an-accept-payment-page.rb"
|
9
|
-
|
10
|
-
require "CustomerProfiles/get-customer-profile.rb"
|
11
|
-
|
12
|
-
require "CustomerProfiles/get-accept-customer-profile-page.rb"
|
1
|
+
# This file is just here to avoid obnoxious gem name/require name issues. All this
|
2
|
+
# file does is require authorize_netsample.rb, the real initialization file.
|
3
|
+
|
4
|
+
require 'authorize_netsample'
|
data/lib/credentials.yml
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
#obtain an API login_id and transaction_id according to instructions at https://developer.authorize.net/faqs/#gettranskey
|
2
|
+
# api_login_id: 5KP3u95bQpv
|
3
|
+
# api_transaction_key: 346HZ32z3fP4hTG2
|
4
|
+
|
5
|
+
api_login_id: 87N83jqsSa3R
|
6
|
+
api_transaction_key: 4K7kREpEd2bc988W
|
7
|
+
|
8
|
+
#obtained md5 hash value by first setting the hash value in https://sandbox.authorize.net/ under the Account tab->MD5 Hash
|
9
|
+
md5_value: MD5_TEST
|
@@ -0,0 +1,320 @@
|
|
1
|
+
cwd = Dir.pwd
|
2
|
+
|
3
|
+
if cwd.include? "sample-code-ruby"
|
4
|
+
puts "String includes sample-code-ruby"
|
5
|
+
specpath = "./spec/"
|
6
|
+
dirpath = "./"
|
7
|
+
else
|
8
|
+
specpath = "./sample-code-ruby/spec/"
|
9
|
+
dirpath = "./sample-code-ruby/"
|
10
|
+
end
|
11
|
+
|
12
|
+
require specpath + "spec_helper"
|
13
|
+
|
14
|
+
include AuthorizeNet::API
|
15
|
+
|
16
|
+
describe "SampleCode Testing" do
|
17
|
+
|
18
|
+
before :all do
|
19
|
+
begin
|
20
|
+
Dir.glob(dirpath + "**/*.rb") do |item| # note one extra "*"
|
21
|
+
next if item == '.' or item == '..'
|
22
|
+
item = item[0..-4]
|
23
|
+
|
24
|
+
if item != specpath + 'sample_code_spec'
|
25
|
+
puts "working on: #{item}"
|
26
|
+
require item
|
27
|
+
end
|
28
|
+
end
|
29
|
+
# Dir.glob("./sample-code-ruby/RecurringBilling/*") do |item| # note one extra "*"
|
30
|
+
# next if item == '.' or item == '..'
|
31
|
+
# item = item[0..-4]
|
32
|
+
# puts "working on: #{item}"
|
33
|
+
# require item
|
34
|
+
# end
|
35
|
+
|
36
|
+
creds = YAML.load_file(File.dirname(__FILE__) + "/credentials.yml")
|
37
|
+
@api_key = creds['api_transaction_key']
|
38
|
+
@api_login = creds['api_login_id']
|
39
|
+
@gateway = :sandbox
|
40
|
+
rescue Errno::ENOENT => e
|
41
|
+
@api_key = "TEST"
|
42
|
+
@api_login = "TEST"
|
43
|
+
warn "WARNING: Running w/o valid AuthorizeNet sandbox credentials. Create spec/credentials.yml."
|
44
|
+
end
|
45
|
+
end
|
46
|
+
def validate_response(response= nil)
|
47
|
+
expect(response).not_to eq(nil)
|
48
|
+
expect(response.messages).not_to eq(nil)
|
49
|
+
expect(response.messages.resultCode).not_to eq(nil)
|
50
|
+
expect(response.messages.resultCode).to eq(MessageTypeEnum::Ok)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should be able to run all Customer Profile sample code" do
|
54
|
+
puts "START - Customer Profiles"
|
55
|
+
|
56
|
+
response = create_customer_profile()
|
57
|
+
validate_response(response)
|
58
|
+
customerProfileId = response.customerProfileId
|
59
|
+
|
60
|
+
response = create_customer_payment_profile(customerProfileId)
|
61
|
+
validate_response(response)
|
62
|
+
customerPaymentProfileId = response.customerPaymentProfileId
|
63
|
+
|
64
|
+
response = create_customer_shipping_address(customerProfileId)
|
65
|
+
validate_response(response)
|
66
|
+
customerAddressId = response.customerAddressId
|
67
|
+
|
68
|
+
#response = validate_customer_payment_profile(customerProfileId, customerPaymentProfileId)
|
69
|
+
#validate_response(response)
|
70
|
+
|
71
|
+
# create_transaction_for_profile = authorize_credit_card()
|
72
|
+
# validate_response(response)
|
73
|
+
# response = create_customer_profile_from_a_transaction(create_transaction_for_profile.transactionResponse.transId)
|
74
|
+
# validate_response(response)
|
75
|
+
|
76
|
+
response = get_customer_payment_profile(customerProfileId, customerPaymentProfileId)
|
77
|
+
validate_response(response)
|
78
|
+
|
79
|
+
response = get_customer_payment_profile_list()
|
80
|
+
validate_response(response)
|
81
|
+
|
82
|
+
response = get_customer_profile(customerProfileId)
|
83
|
+
validate_response(response)
|
84
|
+
|
85
|
+
response = get_customer_profile_ids()
|
86
|
+
validate_response(response)
|
87
|
+
|
88
|
+
response = get_customer_shipping_address(customerProfileId, customerAddressId)
|
89
|
+
validate_response(response)
|
90
|
+
|
91
|
+
response = get_accept_customer_profile_page(customerProfileId)
|
92
|
+
validate_response(response)
|
93
|
+
|
94
|
+
response = update_customer_payment_profile(customerProfileId, customerPaymentProfileId)
|
95
|
+
validate_response(response)
|
96
|
+
|
97
|
+
response = update_customer_profile(customerProfileId)
|
98
|
+
validate_response(response)
|
99
|
+
|
100
|
+
response = update_customer_shipping_address(customerProfileId, customerAddressId)
|
101
|
+
validate_response(response)
|
102
|
+
|
103
|
+
response = delete_customer_shipping_address(customerProfileId, customerAddressId)
|
104
|
+
validate_response(response)
|
105
|
+
|
106
|
+
response = delete_customer_payment_profile(customerProfileId, customerPaymentProfileId)
|
107
|
+
validate_response(response)
|
108
|
+
|
109
|
+
response = delete_customer_profile(customerProfileId)
|
110
|
+
validate_response(response)
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should be able to run all Recurring Billing sample code" do
|
115
|
+
puts "START - Recurring Billing"
|
116
|
+
|
117
|
+
response = create_Subscription()
|
118
|
+
validate_response(response)
|
119
|
+
subscriptionId = response.subscriptionId
|
120
|
+
|
121
|
+
#Create subscription from customer profile
|
122
|
+
profile_response = create_customer_profile()
|
123
|
+
payment_response = create_customer_payment_profile(profile_response.customerProfileId)
|
124
|
+
shipping_response = create_customer_shipping_address(profile_response.customerProfileId)
|
125
|
+
|
126
|
+
#waiting for creating customer profile.
|
127
|
+
puts "Waiting for creation of customer profile..."
|
128
|
+
sleep 50
|
129
|
+
puts "Proceeding"
|
130
|
+
|
131
|
+
response = create_subscription_from_customer_profile(profile_response.customerProfileId, payment_response.customerPaymentProfileId, shipping_response.customerAddressId)
|
132
|
+
validate_response(response)
|
133
|
+
|
134
|
+
cancel_subscription(response.subscriptionId)
|
135
|
+
delete_customer_profile(profile_response.customerProfileId)
|
136
|
+
|
137
|
+
#End of create subscription from customer profile
|
138
|
+
|
139
|
+
response = get_subscription(subscriptionId)
|
140
|
+
validate_response(response)
|
141
|
+
|
142
|
+
response = get_list_of_subscriptions()
|
143
|
+
validate_response(response)
|
144
|
+
|
145
|
+
response = get_subscription_status(subscriptionId)
|
146
|
+
validate_response(response)
|
147
|
+
|
148
|
+
response = update_subscription(subscriptionId)
|
149
|
+
validate_response(response)
|
150
|
+
|
151
|
+
response = cancel_subscription(subscriptionId)
|
152
|
+
validate_response(response)
|
153
|
+
|
154
|
+
end
|
155
|
+
|
156
|
+
|
157
|
+
it "should be able to run all Payment Transaction sample code" do
|
158
|
+
puts "START - Payment Transactions"
|
159
|
+
|
160
|
+
response = authorize_credit_card()
|
161
|
+
validate_response(response)
|
162
|
+
|
163
|
+
response = capture_funds_authorized_through_another_channel()
|
164
|
+
validate_response(response)
|
165
|
+
|
166
|
+
# response = capture_only()
|
167
|
+
# validate_response(response)
|
168
|
+
|
169
|
+
response = capture_funds_authorized_through_another_channel()
|
170
|
+
validate_response(response)
|
171
|
+
|
172
|
+
response = capture_previously_authorized_amount()
|
173
|
+
validate_response(response)
|
174
|
+
|
175
|
+
response = charge_credit_card()
|
176
|
+
validate_response(response)
|
177
|
+
|
178
|
+
#create customer profile
|
179
|
+
response = create_customer_profile()
|
180
|
+
validate_response(response)
|
181
|
+
customerProfileId = response.customerProfileId
|
182
|
+
|
183
|
+
#create customer payment profile
|
184
|
+
response = create_customer_payment_profile(customerProfileId)
|
185
|
+
validate_response(response)
|
186
|
+
customerPaymentProfileId = response.customerPaymentProfileId
|
187
|
+
|
188
|
+
response = charge_customer_profile(customerProfileId, customerPaymentProfileId)
|
189
|
+
validate_response(response)
|
190
|
+
|
191
|
+
response = charge_tokenized_credit_card()
|
192
|
+
validate_response(response)
|
193
|
+
|
194
|
+
response = credit_bank_account()
|
195
|
+
validate_response(response)
|
196
|
+
|
197
|
+
response = debit_bank_account()
|
198
|
+
validate_response(response)
|
199
|
+
|
200
|
+
# response = refund_transaction()
|
201
|
+
# validate_response(response)
|
202
|
+
|
203
|
+
response = update_split_tender_group()
|
204
|
+
validate_response(response)
|
205
|
+
|
206
|
+
response = void_transaction()
|
207
|
+
validate_response(response)
|
208
|
+
end
|
209
|
+
|
210
|
+
|
211
|
+
it "should be able to run all PayPal Express Checkout sample code" do
|
212
|
+
puts "START - PayPal Express Checkout"
|
213
|
+
|
214
|
+
puts "TEST - authorization and capture"
|
215
|
+
response = authorization_and_capture()
|
216
|
+
validate_response(response)
|
217
|
+
|
218
|
+
# response = authorization_and_capture_continued()
|
219
|
+
# validate_response(response)
|
220
|
+
|
221
|
+
puts "TEST - authorization only"
|
222
|
+
response = authorization_only()
|
223
|
+
validate_response(response)
|
224
|
+
|
225
|
+
authTransId = response.transactionResponse.transId
|
226
|
+
puts "TransId to be used for AuthOnlyContinued, GetDetails & Void : #{authTransId}"
|
227
|
+
|
228
|
+
puts "TEST - authorization only continued"
|
229
|
+
response = authorization_only_continued(authTransId)
|
230
|
+
validate_response(response)
|
231
|
+
|
232
|
+
# response = credit()
|
233
|
+
# validate_response(response)
|
234
|
+
|
235
|
+
puts "TEST - Get Details"
|
236
|
+
response = get_details(authTransId)
|
237
|
+
validate_response(response)
|
238
|
+
|
239
|
+
puts "TEST - prior authorization and capture"
|
240
|
+
response = prior_authorization_capture()
|
241
|
+
validate_response(response)
|
242
|
+
|
243
|
+
# puts "TEST - Void"
|
244
|
+
# authTransId = get_transId()
|
245
|
+
# response = void(authTransId)
|
246
|
+
# validate_response(response)
|
247
|
+
|
248
|
+
end
|
249
|
+
|
250
|
+
it "should be able to run all Transaction Reporting sample code" do
|
251
|
+
puts "START - Transaction Reporting"
|
252
|
+
|
253
|
+
response = get_settled_batch_List()
|
254
|
+
validate_response(response)
|
255
|
+
|
256
|
+
#Start Get Batch Statistics
|
257
|
+
batchId = response.batchList.batch[0].batchId
|
258
|
+
|
259
|
+
response = get_batch_Statistics(batchId)
|
260
|
+
validate_response(response)
|
261
|
+
#End Get Batch Statistics
|
262
|
+
|
263
|
+
response = get_transaction_Details()
|
264
|
+
validate_response(response)
|
265
|
+
|
266
|
+
response = get_transaction_List()
|
267
|
+
validate_response(response)
|
268
|
+
|
269
|
+
response = get_unsettled_transaction_List()
|
270
|
+
validate_response(response)
|
271
|
+
|
272
|
+
response = get_Transaction_List_For_Customer()
|
273
|
+
validate_response(response)
|
274
|
+
|
275
|
+
end
|
276
|
+
|
277
|
+
|
278
|
+
it "should be able to run Merchant Details sample code" do
|
279
|
+
puts "START - Transaction Reporting / Merchant Details"
|
280
|
+
|
281
|
+
response = get_merchant_details()
|
282
|
+
validate_response(response)
|
283
|
+
|
284
|
+
end
|
285
|
+
|
286
|
+
|
287
|
+
it "should be able to run all Visa Checkout sample code" do
|
288
|
+
puts "START - Visa Checkout"
|
289
|
+
|
290
|
+
# response = create_visa_checkout_transaction()
|
291
|
+
# validate_response(response)
|
292
|
+
|
293
|
+
response = decrypt_visa_checkout_data()
|
294
|
+
validate_response(response)
|
295
|
+
|
296
|
+
end
|
297
|
+
|
298
|
+
it "should be able to run all Apple Pay sample code" do
|
299
|
+
|
300
|
+
# response = create_an_apple_pay_transaction()
|
301
|
+
# validate_response(response)
|
302
|
+
#
|
303
|
+
end
|
304
|
+
|
305
|
+
it "should be able to run Update Held Transaction sample code" do
|
306
|
+
|
307
|
+
#response = update_held_transaction("12345")
|
308
|
+
#validate_response(response)
|
309
|
+
|
310
|
+
end
|
311
|
+
|
312
|
+
it "should be able to run Get Accept Payment Page sample code" do
|
313
|
+
|
314
|
+
response = get_an_accept_payment_page()
|
315
|
+
validate_response(response)
|
316
|
+
|
317
|
+
end
|
318
|
+
|
319
|
+
|
320
|
+
end
|