authorizenetsample 0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- 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 +42 -0
- 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 +54 -0
- 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 +62 -0
- 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 +47 -0
- 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 +16 -0
- data/lib/authorizenetsample.rb +4 -0
- 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 +110 -0
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'yaml'
|
3
|
+
require 'authorizenet'
|
4
|
+
require 'securerandom'
|
5
|
+
|
6
|
+
include AuthorizeNet::API
|
7
|
+
|
8
|
+
def create_an_android_pay_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
|
+
request.transactionRequest = TransactionRequestType.new()
|
15
|
+
request.transactionRequest.amount = ((SecureRandom.random_number + 1 ) * 150 ).round(2)
|
16
|
+
request.transactionRequest.payment = PaymentType.new
|
17
|
+
request.transactionRequest.payment.opaqueData = OpaqueDataType.new('COMMON.ANDROID.INAPP.PAYMENT','eyJkYXRhIjoiQkRQTldTdE1tR2V3UVVXR2c0bzdFXC9qKzFjcTFUNzhxeVU4NGI2N2l0amNZSTh3UFlBT2hzaGpoWlBycWRVcjRYd1BNYmo0emNHTWR5KysxSDJWa1BPWStCT01GMjV1YjE5Y1g0bkN2a1hVVU9UakRsbEIxVGdTcjhKSFp4Z3A5ckNnc1NVZ2JCZ0tmNjBYS3V0WGY2YWpcL284WkliS25yS1E4U2gwb3VMQUtsb1VNbit2UHU0K0E3V0tycXJhdXo5SnZPUXA2dmhJcStIS2pVY1VOQ0lUUHlGaG1PRXRxK0grdzB2UmExQ0U2V2hGQk5uQ0hxenpXS2NrQlwvMG5xTFpSVFliRjBwK3Z5QmlWYVdIZWdoRVJmSHhSdGJ6cGVjelJQUHVGc2ZwSFZzNDh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ndRUU1Ba0dCU3NPQXdJZEJRQURnWUVBYlVLWUNrdUlLUzlRUTJtRmNNWVJFSW0ybCtYZzhcL0pYditHQlZRSmtPS29zY1k0aU5ERkFcL2JRbG9nZjlMTFU4NFRId05SbnN2VjNQcnY3UlRZODFncTBkdEM4elljQWFBa0NISUkzeXFNbko0QU91NkVPVzlrSmsyMzJnU0U3V2xDdEhiZkxTS2Z1U2dRWDhLWFFZdVpMazJScjYzTjhBcFhzWHdCTDNjSjB4Z2VBd2dkMENBUUV3T3pBbk1TVXdJd1lEVlFRREhod0FZd0JvQUcwQVlRQnBBRUFBZGdCcEFITUFZUUF1QUdNQWJ3QnRBaEJjbCtQZjMrVTRwazEzblZEOW53UVFNQWtHQlNzT0F3SWFCUUF3RFFZSktvWklodmNOQVFFQkJRQUVnWUJhSzNFbE9zdGJIOFdvb3NlREFCZitKZ1wvMTI5SmNJYXdtN2M2VnhuN1phc05iQXEzdEF0OFB0eSt1UUNnc3NYcVprTEE3a3oyR3pNb2xOdHY5d1ltdTlVandhcjFQSFlTK0JcL29Hbm96NTkxd2phZ1hXUnowbk1vNXkzTzFLelgwZDhDUkhBVmE4OFNyVjFhNUpJaVJldjNvU3RJcXd2NXh1WmxkYWc2VHI4dz09In0=',nil)
|
18
|
+
|
19
|
+
request.transactionRequest.transactionType = TransactionTypeEnum::AuthCaptureTransaction
|
20
|
+
|
21
|
+
response = transaction.create_transaction(request)
|
22
|
+
|
23
|
+
if response != nil
|
24
|
+
if response.messages.resultCode == MessageTypeEnum::Ok
|
25
|
+
if response.transactionResponse != nil && response.transactionResponse.messages != nil
|
26
|
+
puts "Successfully made a purchase (authorization code: #{response.transactionResponse.authCode})"
|
27
|
+
puts "Transaction Response code: #{response.transactionResponse.responseCode}"
|
28
|
+
puts "Code: #{response.transactionResponse.messages.messages[0].code}"
|
29
|
+
puts "Description: #{response.transactionResponse.messages.messages[0].description}"
|
30
|
+
else
|
31
|
+
puts "Transaction Failed"
|
32
|
+
if response.transactionResponse.errors != nil
|
33
|
+
puts "Error Code: #{response.transactionResponse.errors.errors[0].errorCode}"
|
34
|
+
puts "Error Message: #{response.transactionResponse.errors.errors[0].errorText}"
|
35
|
+
end
|
36
|
+
raise "Failed to make purchase."
|
37
|
+
end
|
38
|
+
else
|
39
|
+
puts "Transaction Failed"
|
40
|
+
if response.transactionResponse != nil && response.transactionResponse.errors != nil
|
41
|
+
puts "Error Code: #{response.transactionResponse.errors.errors[0].errorCode}"
|
42
|
+
puts "Error Message: #{response.transactionResponse.errors.errors[0].errorText}"
|
43
|
+
else
|
44
|
+
puts "Error Code: #{response.messages.messages[0].code}"
|
45
|
+
puts "Error Message: #{response.messages.messages[0].text}"
|
46
|
+
end
|
47
|
+
raise "Failed to make purchase."
|
48
|
+
end
|
49
|
+
else
|
50
|
+
puts "Response is null"
|
51
|
+
raise "Failed to make purchase."
|
52
|
+
end
|
53
|
+
|
54
|
+
return response
|
55
|
+
end
|
56
|
+
|
57
|
+
if __FILE__ == $0
|
58
|
+
create_an_android_pay_transaction()
|
59
|
+
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 create_an_apple_pay_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
|
+
request.transactionRequest = TransactionRequestType.new()
|
15
|
+
request.transactionRequest.amount = ((SecureRandom.random_number + 1 ) * 150 ).round(2)
|
16
|
+
request.transactionRequest.payment = PaymentType.new
|
17
|
+
request.transactionRequest.payment.opaqueData = OpaqueDataType.new('COMMON.APPLE.INAPP.PAYMENT','eyJkYXRhIjoiQkRQTldTdE1tR2V3UVVXR2c0bzdFX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.transactionRequest.transactionType = TransactionTypeEnum::AuthCaptureTransaction
|
19
|
+
|
20
|
+
response = transaction.create_transaction(request)
|
21
|
+
|
22
|
+
if response != nil
|
23
|
+
if response.messages.resultCode == MessageTypeEnum::Ok
|
24
|
+
if response.transactionResponse != nil && response.transactionResponse.messages != nil
|
25
|
+
puts "Successfully made a purchase (authorization code: #{response.transactionResponse.authCode})"
|
26
|
+
puts "Transaction Response code: #{response.transactionResponse.responseCode}"
|
27
|
+
puts "Code: #{response.transactionResponse.messages.messages[0].code}"
|
28
|
+
puts "Description: #{response.transactionResponse.messages.messages[0].description}"
|
29
|
+
else
|
30
|
+
puts "Transaction Failed"
|
31
|
+
if response.transactionResponse.errors != nil
|
32
|
+
puts "Error Code: #{response.transactionResponse.errors.errors[0].errorCode}"
|
33
|
+
puts "Error Message: #{response.transactionResponse.errors.errors[0].errorText}"
|
34
|
+
end
|
35
|
+
raise "Failed to make purchase."
|
36
|
+
end
|
37
|
+
else
|
38
|
+
puts "Transaction Failed"
|
39
|
+
if response.transactionResponse != nil && response.transactionResponse.errors != nil
|
40
|
+
puts "Error Code: #{response.transactionResponse.errors.errors[0].errorCode}"
|
41
|
+
puts "Error Message: #{response.transactionResponse.errors.errors[0].errorText}"
|
42
|
+
else
|
43
|
+
puts "Error Code: #{response.messages.messages[0].code}"
|
44
|
+
puts "Error Message: #{response.messages.messages[0].text}"
|
45
|
+
end
|
46
|
+
raise "Failed to make purchase."
|
47
|
+
end
|
48
|
+
else
|
49
|
+
puts "Response is null"
|
50
|
+
raise "Failed to make purchase."
|
51
|
+
end
|
52
|
+
|
53
|
+
return response
|
54
|
+
end
|
55
|
+
|
56
|
+
if __FILE__ == $0
|
57
|
+
create_an_apple_pay_transaction()
|
58
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'yaml'
|
3
|
+
require 'authorizenet'
|
4
|
+
require 'securerandom'
|
5
|
+
|
6
|
+
include AuthorizeNet::API
|
7
|
+
|
8
|
+
def authorization_and_capture_continued()
|
9
|
+
config = YAML.load_file(File.dirname(__FILE__) + "/../credentials.yml")
|
10
|
+
|
11
|
+
puts "PayPal Authorization Capture-Continue Transaction"
|
12
|
+
|
13
|
+
transaction = Transaction.new(config['api_login_id'], config['api_transaction_key'], :gateway => :sandbox)
|
14
|
+
|
15
|
+
payPalType = PayPalType.new
|
16
|
+
payPalType.successUrl = "http://www.merchanteCommerceSite.com/Success/TC25262"
|
17
|
+
payPalType.cancelUrl = "http://www.merchanteCommerceSite.com/Success/TC25262"
|
18
|
+
payPalType.payerID = "M8R9JRNJ3R28Y"
|
19
|
+
|
20
|
+
paymentType = PaymentType.new
|
21
|
+
paymentType.payPal = payPalType
|
22
|
+
|
23
|
+
request = CreateTransactionRequest.new
|
24
|
+
request.transactionRequest = TransactionRequestType.new()
|
25
|
+
request.transactionRequest.refTransId = "2241762169"
|
26
|
+
request.transactionRequest.amount = 15.00
|
27
|
+
request.transactionRequest.payment = paymentType
|
28
|
+
request.transactionRequest.transactionType = TransactionTypeEnum::AuthCaptureContinueTransaction
|
29
|
+
|
30
|
+
response = transaction.create_transaction(request)
|
31
|
+
|
32
|
+
if response != nil
|
33
|
+
if response.messages.resultCode == MessageTypeEnum::Ok
|
34
|
+
if response.transactionResponse != nil && response.transactionResponse.messages != nil
|
35
|
+
puts "Successfully created an Authorization Capture-Continue transaction (authorization code: #{response.transactionResponse.authCode})"
|
36
|
+
puts "Transaction Response code: #{response.transactionResponse.responseCode}"
|
37
|
+
puts "Code: #{response.transactionResponse.messages.messages[0].code}"
|
38
|
+
puts "Description: #{response.transactionResponse.messages.messages[0].description}"
|
39
|
+
else
|
40
|
+
puts "Transaction Failed"
|
41
|
+
if response.transactionResponse.errors != nil
|
42
|
+
puts "Error Code: #{response.transactionResponse.errors.errors[0].errorCode}"
|
43
|
+
puts "Error Message: #{response.transactionResponse.errors.errors[0].errorText}"
|
44
|
+
end
|
45
|
+
raise "Failed to make purchase."
|
46
|
+
end
|
47
|
+
else
|
48
|
+
puts "Transaction Failed"
|
49
|
+
if response.transactionResponse != nil && response.transactionResponse.errors != nil
|
50
|
+
puts "Error Code: #{response.transactionResponse.errors.errors[0].errorCode}"
|
51
|
+
puts "Error Message: #{response.transactionResponse.errors.errors[0].errorText}"
|
52
|
+
else
|
53
|
+
puts "Error Code: #{response.messages.messages[0].code}"
|
54
|
+
puts "Error Message: #{response.messages.messages[0].text}"
|
55
|
+
end
|
56
|
+
raise "Failed to make purchase."
|
57
|
+
end
|
58
|
+
else
|
59
|
+
puts "Response is null"
|
60
|
+
raise "Failed to make purchase."
|
61
|
+
end
|
62
|
+
|
63
|
+
return response
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
if __FILE__ == $0
|
68
|
+
authorization_and_capture_continued()
|
69
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'yaml'
|
3
|
+
require 'authorizenet'
|
4
|
+
require 'securerandom'
|
5
|
+
|
6
|
+
include AuthorizeNet::API
|
7
|
+
|
8
|
+
def authorization_and_capture()
|
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
|
+
# Define the PayPal specific parameters
|
14
|
+
payPalType = PayPalType.new()
|
15
|
+
payPalType.successUrl = "http://www.merchanteCommerceSite.com/Success/TC25262"
|
16
|
+
payPalType.cancelUrl = "http://www.merchanteCommerceSite.com/Success/TC25262"
|
17
|
+
|
18
|
+
paymentType = PaymentType.new()
|
19
|
+
paymentType.payPal = payPalType
|
20
|
+
|
21
|
+
# Construct the request object
|
22
|
+
request = CreateTransactionRequest.new
|
23
|
+
request.transactionRequest = TransactionRequestType.new()
|
24
|
+
request.transactionRequest.amount = ((SecureRandom.random_number + 1 ) * 150 ).round(2)
|
25
|
+
request.transactionRequest.payment = paymentType
|
26
|
+
request.transactionRequest.transactionType = TransactionTypeEnum::AuthCaptureTransaction
|
27
|
+
|
28
|
+
response = transaction.create_transaction(request)
|
29
|
+
|
30
|
+
if response != nil
|
31
|
+
if response.messages.resultCode == MessageTypeEnum::Ok
|
32
|
+
if response.transactionResponse != nil && (response.transactionResponse.responseCode == "1" || response.transactionResponse.responseCode == "5")
|
33
|
+
puts "Successfully created an authorize and capture transaction."
|
34
|
+
puts " Response Code: #{response.transactionResponse.responseCode}"
|
35
|
+
puts " Transaction ID: #{response.transactionResponse.transId}"
|
36
|
+
puts " Secure Acceptance URL: #{response.transactionResponse.secureAcceptance.SecureAcceptanceUrl}"
|
37
|
+
puts " Transaction Response code: #{response.transactionResponse.responseCode}"
|
38
|
+
puts " Code: #{response.transactionResponse.messages.messages[0].code}"
|
39
|
+
puts " Description: #{response.transactionResponse.messages.messages[0].description}"
|
40
|
+
else
|
41
|
+
puts "PayPal authorize and capture transaction failed"
|
42
|
+
if 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
|
+
end
|
46
|
+
raise "Failed PayPal Authorize Capture Transaction."
|
47
|
+
end
|
48
|
+
else
|
49
|
+
puts "PayPal authorize and capture transaction failed"
|
50
|
+
if response.transactionResponse != nil && response.transactionResponse.errors != nil
|
51
|
+
puts "Error Code: #{response.transactionResponse.errors.errors[0].errorCode}"
|
52
|
+
puts "Error Message: #{response.transactionResponse.errors.errors[0].errorText}"
|
53
|
+
else
|
54
|
+
puts "Error Code: #{response.messages.messages[0].code}"
|
55
|
+
puts "Error Message: #{response.messages.messages[0].text}"
|
56
|
+
end
|
57
|
+
raise "Failed PayPal Authorize Capture Transaction."
|
58
|
+
end
|
59
|
+
else
|
60
|
+
puts "Response is null"
|
61
|
+
raise "Failed PayPal Authorize Capture Transaction."
|
62
|
+
end
|
63
|
+
|
64
|
+
return response
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
if __FILE__ == $0
|
69
|
+
authorization_and_capture()
|
70
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'yaml'
|
3
|
+
require 'authorizenet'
|
4
|
+
require 'securerandom'
|
5
|
+
|
6
|
+
include AuthorizeNet::API
|
7
|
+
|
8
|
+
def authorization_only_continued(transId)
|
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
|
+
payPalType = PayPalType.new()
|
16
|
+
payPalType.successUrl = "http://www.merchanteCommerceSite.com/Success/TC25262"
|
17
|
+
payPalType.cancelUrl = "http://www.merchanteCommerceSite.com/Success/TC25262"
|
18
|
+
#payerID should be taken from GetDetails
|
19
|
+
payPalType.payerID = "S6D5ETGSVYX94"
|
20
|
+
|
21
|
+
#standard api call to retrieve response
|
22
|
+
paymentType = PaymentType.new()
|
23
|
+
paymentType.payPal = payPalType
|
24
|
+
|
25
|
+
request.transactionRequest = TransactionRequestType.new()
|
26
|
+
#request.transactionRequest.amount = ((SecureRandom.random_number + 1 ) * 150 ).round(2)
|
27
|
+
request.transactionRequest.payment = paymentType
|
28
|
+
#refTransId should be taken from the transId returned by AuthOnly
|
29
|
+
request.transactionRequest.refTransId = transId
|
30
|
+
request.transactionRequest.transactionType = TransactionTypeEnum::AuthOnlyContinueTransaction
|
31
|
+
response = transaction.create_transaction(request)
|
32
|
+
|
33
|
+
if response != nil
|
34
|
+
if response.messages.resultCode == MessageTypeEnum::Ok
|
35
|
+
if response.transactionResponse != nil && response.transactionResponse.messages != nil
|
36
|
+
puts "Successful AuthOnly Transaction (Transaction response code: #{response.transactionResponse.responseCode})"
|
37
|
+
puts "Transaction Response code: #{response.transactionResponse.responseCode}"
|
38
|
+
puts "Code: #{response.transactionResponse.messages.messages[0].code}"
|
39
|
+
puts "Description: #{response.transactionResponse.messages.messages[0].description}"
|
40
|
+
else
|
41
|
+
puts "Transaction Failed"
|
42
|
+
if 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
|
+
end
|
46
|
+
puts "Failed to authorize card."
|
47
|
+
end
|
48
|
+
else
|
49
|
+
puts "Transaction Failed"
|
50
|
+
if response.transactionResponse != nil && response.transactionResponse.errors != nil
|
51
|
+
puts "Error Code: #{response.transactionResponse.errors.errors[0].errorCode}"
|
52
|
+
puts "Error Message: #{response.transactionResponse.errors.errors[0].errorText}"
|
53
|
+
else
|
54
|
+
puts "Error Code: #{response.messages.messages[0].code}"
|
55
|
+
puts "Error Message: #{response.messages.messages[0].text}"
|
56
|
+
end
|
57
|
+
puts "Failed to authorize card."
|
58
|
+
end
|
59
|
+
else
|
60
|
+
puts "Response is null"
|
61
|
+
raise "Failed to authorize card."
|
62
|
+
end
|
63
|
+
|
64
|
+
return response
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
if __FILE__ == $0
|
69
|
+
authorization_only_continued()
|
70
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'yaml'
|
3
|
+
require 'authorizenet'
|
4
|
+
require 'securerandom'
|
5
|
+
|
6
|
+
include AuthorizeNet::API
|
7
|
+
|
8
|
+
def authorization_only()
|
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
|
+
# Define the PayPal specific parameters
|
14
|
+
payPalType = PayPalType.new()
|
15
|
+
payPalType.successUrl = "http://www.merchanteCommerceSite.com/Success/TC25262"
|
16
|
+
payPalType.cancelUrl = "http://www.merchanteCommerceSite.com/Success/TC25262"
|
17
|
+
|
18
|
+
paymentType = PaymentType.new()
|
19
|
+
paymentType.payPal = payPalType
|
20
|
+
|
21
|
+
# Construct the request object
|
22
|
+
request = CreateTransactionRequest.new
|
23
|
+
request.transactionRequest = TransactionRequestType.new()
|
24
|
+
request.transactionRequest.amount = ((SecureRandom.random_number + 1 ) * 150 ).round(2)
|
25
|
+
request.transactionRequest.payment = paymentType
|
26
|
+
request.transactionRequest.transactionType = TransactionTypeEnum::AuthOnlyTransaction
|
27
|
+
|
28
|
+
response = transaction.create_transaction(request)
|
29
|
+
|
30
|
+
|
31
|
+
if response != nil
|
32
|
+
if response.messages.resultCode == MessageTypeEnum::Ok
|
33
|
+
if response.transactionResponse != nil && (response.transactionResponse.responseCode == "1" || response.transactionResponse.responseCode == "5")
|
34
|
+
puts "Successfully created an authorize only transaction."
|
35
|
+
puts " Response Code: #{response.transactionResponse.responseCode}"
|
36
|
+
puts " Transaction ID: #{response.transactionResponse.transId}"
|
37
|
+
puts " Secure Acceptance URL: #{response.transactionResponse.secureAcceptance.SecureAcceptanceUrl}"
|
38
|
+
puts " Transaction Response code: #{response.transactionResponse.responseCode}"
|
39
|
+
puts " Code: #{response.transactionResponse.messages.messages[0].code}"
|
40
|
+
puts " Description: #{response.transactionResponse.messages.messages[0].description}"
|
41
|
+
else
|
42
|
+
puts "PayPal authorize only transaction failed"
|
43
|
+
if response.transactionResponse.errors != nil
|
44
|
+
puts " Error Code: #{response.transactionResponse.errors.errors[0].errorCode}"
|
45
|
+
puts " Error Message: #{response.transactionResponse.errors.errors[0].errorText}"
|
46
|
+
end
|
47
|
+
raise "Failed PayPal Authorize Only Transaction."
|
48
|
+
end
|
49
|
+
else
|
50
|
+
puts "PayPal authorize only transaction failed"
|
51
|
+
if response.transactionResponse != nil && response.transactionResponse.errors != nil
|
52
|
+
puts "Error Code: #{response.transactionResponse.errors.errors[0].errorCode}"
|
53
|
+
puts "Error Message: #{response.transactionResponse.errors.errors[0].errorText}"
|
54
|
+
else
|
55
|
+
puts "Error Code: #{response.messages.messages[0].code}"
|
56
|
+
puts "Error Message: #{response.messages.messages[0].text}"
|
57
|
+
end
|
58
|
+
raise "Failed PayPal Authorize Only Transaction."
|
59
|
+
end
|
60
|
+
else
|
61
|
+
puts "Response is null"
|
62
|
+
raise "Failed PayPal Authorize Only Transaction."
|
63
|
+
end
|
64
|
+
|
65
|
+
return response
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
if __FILE__ == $0
|
70
|
+
authorization_only()
|
71
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'yaml'
|
3
|
+
require 'authorizenet'
|
4
|
+
require 'securerandom'
|
5
|
+
|
6
|
+
include AuthorizeNet::API
|
7
|
+
|
8
|
+
def credit()
|
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
|
+
payPalType = PayPalType.new()
|
16
|
+
payPalType.successUrl = "http://www.merchanteCommerceSite.com/Success/TC25262"
|
17
|
+
payPalType.cancelUrl = "http://www.merchanteCommerceSite.com/Success/TC25262"
|
18
|
+
|
19
|
+
#standard api call to retrieve response
|
20
|
+
paymentType = PaymentType.new()
|
21
|
+
paymentType.payPal = payPalType
|
22
|
+
|
23
|
+
request.transactionRequest = TransactionRequestType.new()
|
24
|
+
request.transactionRequest.amount = ((SecureRandom.random_number + 1 ) * 150 ).round(2)
|
25
|
+
request.transactionRequest.payment = paymentType
|
26
|
+
#refTransId for which credit has to happen
|
27
|
+
request.transactionRequest.refTransId = "2241762126"
|
28
|
+
request.transactionRequest.transactionType = TransactionTypeEnum::RefundTransaction
|
29
|
+
response = transaction.create_transaction(request)
|
30
|
+
|
31
|
+
if response != nil
|
32
|
+
if response.messages.resultCode == MessageTypeEnum::Ok
|
33
|
+
if response.transactionResponse != nil && response.transactionResponse.messages != nil
|
34
|
+
puts "Successful Credit Transaction (Transaction response code: #{response.transactionResponse.responseCode})"
|
35
|
+
puts "Transaction Response code: #{response.transactionResponse.responseCode}"
|
36
|
+
puts "Code: #{response.transactionResponse.messages.messages[0].code}"
|
37
|
+
puts "Description: #{response.transactionResponse.messages.messages[0].description}"
|
38
|
+
else
|
39
|
+
puts "Transaction Failed"
|
40
|
+
if response.transactionResponse.errors != nil
|
41
|
+
puts "Error Code: #{response.transactionResponse.errors.errors[0].errorCode}"
|
42
|
+
puts "Error Message: #{response.transactionResponse.errors.errors[0].errorText}"
|
43
|
+
end
|
44
|
+
raise "Failed to authorize card."
|
45
|
+
end
|
46
|
+
else
|
47
|
+
puts "Transaction Failed"
|
48
|
+
if response.transactionResponse != nil && response.transactionResponse.errors != nil
|
49
|
+
puts "Error Code: #{response.transactionResponse.errors.errors[0].errorCode}"
|
50
|
+
puts "Error Message: #{response.transactionResponse.errors.errors[0].errorText}"
|
51
|
+
else
|
52
|
+
puts "Error Code: #{response.messages.messages[0].code}"
|
53
|
+
puts "Error Message: #{response.messages.messages[0].text}"
|
54
|
+
end
|
55
|
+
raise "Failed to authorize card."
|
56
|
+
end
|
57
|
+
else
|
58
|
+
puts "Response is null"
|
59
|
+
raise "Failed to authorize card."
|
60
|
+
end
|
61
|
+
|
62
|
+
return response
|
63
|
+
end
|
64
|
+
|
65
|
+
if __FILE__ == $0
|
66
|
+
credit()
|
67
|
+
end
|