authorizenetsample 1.2.5 → 1.9.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/CustomerProfiles/get-accept-customer-profile-page.rb +14 -20
- data/lib/CustomerProfiles/get-customer-profile.rb +31 -33
- data/lib/PaymentTransactions/create-an-accept-payment-transaction.rb +4 -17
- data/lib/PaymentTransactions/get-an-accept-payment-page.rb +14 -37
- data/lib/authorize_netsample.rb +1 -6
- data/lib/credentials.yml +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f66ce446442873fef466523ee5418c1fdba594a
|
4
|
+
data.tar.gz: ab0253eb972f5d48402cf97340eefa48d3f782e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f96670eb414ef0f6b2877b087e270664f6af2536057194ff3367f8ea1f9f5fcbfb9ace0e32cebf214c989de83c3e27982830453f1359aed11b9b3b8816b667c
|
7
|
+
data.tar.gz: b3038265b69d16bcdd8d4af0fb664159aef181ecec305a04c1c0d9a67380033a6f3c2a554aedcb04c11e125d221e7261c546378e9d3d39e00e960a1ce64baf30
|
@@ -5,23 +5,17 @@ require 'securerandom'
|
|
5
5
|
|
6
6
|
include AuthorizeNet::API
|
7
7
|
|
8
|
-
def get_accept_customer_profile_page(
|
8
|
+
def get_accept_customer_profile_page(customerProfileId = '37696245')
|
9
9
|
config = YAML.load_file(File.dirname(__FILE__) + "/../credentials.yml")
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
transaction = Transaction.new(api_login_id, api_transaction_key, :gateway => :sandbox)
|
11
|
+
transaction = Transaction.new(config['api_login_id'], config['api_transaction_key'], :gateway => :sandbox)
|
14
12
|
|
15
13
|
setting = SettingType.new
|
16
14
|
setting.settingName = SettingNameEnum::HostedProfileReturnUrl
|
17
15
|
setting.settingValue = "https://returnurl.com/return/"
|
18
|
-
|
19
|
-
setting1 = SettingType.new
|
20
|
-
setting1.settingName = SettingNameEnum::HostedProfileIFrameCommunicatorUrl
|
21
|
-
setting1.settingValue = iframeCommunicatorUrl
|
22
16
|
|
23
|
-
settings = Settings.new([setting
|
24
|
-
|
17
|
+
settings = Settings.new([setting])
|
18
|
+
|
25
19
|
|
26
20
|
request = GetHostedProfilePageRequest.new
|
27
21
|
request.customerProfileId = customerProfileId
|
@@ -30,16 +24,16 @@ require 'securerandom'
|
|
30
24
|
|
31
25
|
response = transaction.get_hosted_profile_page(request)
|
32
26
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
27
|
+
if response.messages.resultCode == MessageTypeEnum::Ok
|
28
|
+
puts "Successfully got Accept Customer page token."
|
29
|
+
puts " Response code: #{response.messages.messages[0].code}"
|
30
|
+
puts " Response message: #{response.messages.messages[0].text}"
|
31
|
+
puts " Token: #{response.token}"
|
32
|
+
else
|
33
|
+
puts "#{response.messages.messages[0].code}"
|
34
|
+
puts "#{response.messages.messages[0].text}"
|
35
|
+
raise "Failed to get hosted profile page with customer profile ID #{request.customerProfileId}"
|
36
|
+
end
|
43
37
|
return response
|
44
38
|
end
|
45
39
|
|
@@ -5,12 +5,10 @@ require 'securerandom'
|
|
5
5
|
|
6
6
|
include AuthorizeNet::API
|
7
7
|
|
8
|
-
def get_customer_profile(
|
8
|
+
def get_customer_profile(customerProfileId = '40036377')
|
9
9
|
config = YAML.load_file(File.dirname(__FILE__) + "/../credentials.yml")
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
transaction = Transaction.new(api_login_id, api_transaction_key, :gateway => :sandbox)
|
11
|
+
transaction = Transaction.new(config['api_login_id'], config['api_transaction_key'], :gateway => :sandbox)
|
14
12
|
|
15
13
|
|
16
14
|
request = GetCustomerProfileRequest.new
|
@@ -18,35 +16,35 @@ require 'securerandom'
|
|
18
16
|
|
19
17
|
response = transaction.get_customer_profile(request)
|
20
18
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
19
|
+
if response.messages.resultCode == MessageTypeEnum::Ok
|
20
|
+
puts "Successfully retrieved a customer with profile ID is #{request.customerProfileId} and whose customer ID is #{response.profile.merchantCustomerId}."
|
21
|
+
response.profile.paymentProfiles.each do |paymentProfile|
|
22
|
+
puts " Payment Profile ID #{paymentProfile.customerPaymentProfileId}"
|
23
|
+
puts " Payment Details:"
|
24
|
+
if paymentProfile.billTo != nil
|
25
|
+
puts " Last Name: #{paymentProfile.billTo.lastName}"
|
26
|
+
puts " Address: #{paymentProfile.billTo.address}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
response.profile.shipToList.each do |ship|
|
30
|
+
puts " Shipping Address ID #{ship.customerAddressId}"
|
31
|
+
puts " Shipping Details:"
|
32
|
+
puts " First Name: #{ship.firstName}"
|
33
|
+
puts " Last Name: #{ship.lastName}"
|
34
|
+
puts " Address: #{ship.address}"
|
35
|
+
end
|
36
|
+
|
37
|
+
if response.subscriptionIds != nil && response.subscriptionIds.subscriptionId != nil
|
38
|
+
puts " List of subscriptions: "
|
39
|
+
response.subscriptionIds.subscriptionId.each do |subscriptionId|
|
40
|
+
puts " #{subscriptionId}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
else
|
45
|
+
puts response.messages.messages[0].text
|
46
|
+
raise "Failed to get customer profile information with ID #{request.customerProfileId}"
|
47
|
+
end
|
50
48
|
return response
|
51
49
|
end
|
52
50
|
|
@@ -5,36 +5,23 @@ require 'securerandom'
|
|
5
5
|
|
6
6
|
include AuthorizeNet::API
|
7
7
|
|
8
|
-
def create_an_accept_payment_transaction(
|
8
|
+
def create_an_accept_payment_transaction()
|
9
9
|
puts File.dirname(__FILE__)
|
10
10
|
config = YAML.load_file(File.dirname(__FILE__) + "/../credentials.yml")
|
11
11
|
|
12
|
-
|
13
|
-
transaction = Transaction.new(api_login_id, api_transaction_key, :gateway => :sandbox)
|
12
|
+
transaction = Transaction.new(config['api_login_id'], config['api_transaction_key'], :gateway => :sandbox)
|
14
13
|
|
15
14
|
request = CreateTransactionRequest.new
|
16
|
-
|
17
|
-
billTo = CustomerAddressType.new
|
18
|
-
billTo.firstName = "John"
|
19
|
-
billTo.lastName = "Doe"
|
20
|
-
billTo.address = "123 My St"
|
21
|
-
billTo.city = "OurTown"
|
22
|
-
billTo.zip = "98004"
|
23
15
|
|
24
16
|
request.transactionRequest = TransactionRequestType.new()
|
25
|
-
|
26
|
-
request.transactionRequest.amount = 99
|
27
|
-
request.transactionRequest.billTo = billTo
|
17
|
+
request.transactionRequest.amount = ((SecureRandom.random_number + 1 ) * 150 ).round(2)
|
28
18
|
request.transactionRequest.payment = PaymentType.new
|
29
|
-
|
30
|
-
request.transactionRequest.payment.opaqueData = OpaqueDataType.new('COMMON.ACCEPT.INAPP.PAYMENT',token)
|
19
|
+
request.transactionRequest.payment.opaqueData = OpaqueDataType.new('COMMON.ACCEPT.INAPP.PAYMENT','eyJjb2RlIjoiNTBfMl8wNjAwMDUzQTczNERGMDY0MUMyMzUxMkIyQTM2MUE3QTBFQUQ4NTIxQ0EzQjM3MUU1REMyMjlEQkYwMjRERjI5QzdFOTJBMDIzNzJGRDVDQkI0ODRDMTQ2NDYyQ0U4NkFCRjA0Q0Y3IiwidG9rZW4iOiI5NTM5MzYyNzY1NjM2NTgyODA0NjA0IiwidiI6IjEuMSJ9')
|
31
20
|
request.transactionRequest.customer = CustomerDataType.new(nil,nil,'bmc@mail.com')
|
32
21
|
request.transactionRequest.transactionType = TransactionTypeEnum::AuthCaptureTransaction
|
33
22
|
request.transactionRequest.order = OrderType.new("invoiceNumber#{(SecureRandom.random_number*1000000).round(0)}","Order Description")
|
34
23
|
|
35
24
|
response = transaction.create_transaction(request)
|
36
|
-
|
37
|
-
|
38
25
|
|
39
26
|
# if response != nil
|
40
27
|
# if response.messages.resultCode == MessageTypeEnum::Ok
|
@@ -5,22 +5,14 @@ require 'securerandom'
|
|
5
5
|
|
6
6
|
include AuthorizeNet::API
|
7
7
|
|
8
|
-
def get_an_accept_payment_page(
|
8
|
+
def get_an_accept_payment_page()
|
9
9
|
config = YAML.load_file(File.dirname(__FILE__) + "/../credentials.yml")
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
transaction = Transaction.new(api_login_id, api_transaction_key, :gateway => :sandbox)
|
14
|
-
|
15
|
-
custProfile = CustomerProfilePaymentType.new
|
16
|
-
custProfile.customerProfileId = customerId
|
11
|
+
transaction = Transaction.new(config['api_login_id'], config['api_transaction_key'], :gateway => :sandbox)
|
17
12
|
|
18
13
|
transactionRequest = TransactionRequestType.new
|
19
|
-
transactionRequest.amount =
|
14
|
+
transactionRequest.amount = 12.12
|
20
15
|
transactionRequest.transactionType = TransactionTypeEnum::AuthCaptureTransaction
|
21
|
-
transactionRequest.profile = custProfile
|
22
|
-
|
23
|
-
|
24
16
|
|
25
17
|
setting1 = SettingType.new
|
26
18
|
setting1.settingName = SettingNameEnum::HostedPaymentButtonOptions
|
@@ -29,39 +21,24 @@ require 'securerandom'
|
|
29
21
|
setting2 = SettingType.new
|
30
22
|
setting2.settingName = SettingNameEnum::HostedPaymentOrderOptions
|
31
23
|
setting2.settingValue = "{\"show\": false}"
|
32
|
-
|
33
|
-
setting4 = SettingType.new
|
34
|
-
setting4.settingName = SettingNameEnum::HostedPaymentBillingAddressOptions
|
35
|
-
setting4.settingValue = "{\"show\": false}"
|
36
|
-
|
37
|
-
setting3 = SettingType.new
|
38
|
-
setting3.settingName = SettingNameEnum::HostedPaymentIFrameCommunicatorUrl
|
39
|
-
setting3.settingValue = "{\"url\": \"#{iframeCommunicatorUrl}\"}"
|
40
|
-
|
41
|
-
setting5 = SettingType.new
|
42
|
-
setting5.settingName = SettingNameEnum::HostedPaymentReturnOptions
|
43
|
-
setting5.settingValue = "{\"showReceipt\": false,\"url\": \"#{iframeCommunicatorUrl}\",\"urlText\":\"Continue\",\"cancelUrlText\":\"Cancel\"}"
|
44
|
-
|
45
24
|
|
46
|
-
|
47
|
-
|
48
|
-
settings = Settings.new([ setting1, setting2,setting3,setting4,setting5])
|
49
|
-
|
25
|
+
settings = Settings.new([ setting1, setting2])
|
26
|
+
|
50
27
|
request = GetHostedPaymentPageRequest.new
|
51
28
|
request.transactionRequest = transactionRequest
|
52
29
|
request.hostedPaymentSettings = settings
|
53
30
|
|
54
31
|
response = transaction.get_hosted_payment_page(request)
|
55
32
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
33
|
+
if response.messages.resultCode == MessageTypeEnum::Ok
|
34
|
+
puts "#{response.messages.messages[0].code}"
|
35
|
+
puts "#{response.messages.messages[0].text}"
|
36
|
+
puts "#{response.token}"
|
37
|
+
else
|
38
|
+
puts "#{response.messages.messages[0].code}"
|
39
|
+
puts "#{response.messages.messages[0].text}"
|
40
|
+
raise "Failed to get hosted payment page"
|
41
|
+
end
|
65
42
|
return response
|
66
43
|
end
|
67
44
|
|
data/lib/authorize_netsample.rb
CHANGED
@@ -12,10 +12,5 @@
|
|
12
12
|
|
13
13
|
$LOAD_PATH.unshift File.dirname(__FILE__)
|
14
14
|
|
15
|
+
require "PaymentTransactions/authorize-credit-card.rb"
|
15
16
|
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/credentials.yml
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
# api_login_id: 5KP3u95bQpv
|
3
3
|
# api_transaction_key: 346HZ32z3fP4hTG2
|
4
4
|
|
5
|
-
api_login_id:
|
6
|
-
api_transaction_key:
|
5
|
+
api_login_id: 78BZ5Xprry
|
6
|
+
api_transaction_key: 8s2F95Q7brhHd7Tn
|
7
7
|
|
8
8
|
#obtained md5 hash value by first setting the hash value in https://sandbox.authorize.net/ under the Account tab->MD5 Hash
|
9
9
|
md5_value: MD5_TEST
|