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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2a4ded3214abe5d49bead90f7d0b2a6de15efd72
4
- data.tar.gz: b0131156cd63e60107ab1eed036726755b37be0d
3
+ metadata.gz: 5f66ce446442873fef466523ee5418c1fdba594a
4
+ data.tar.gz: ab0253eb972f5d48402cf97340eefa48d3f782e3
5
5
  SHA512:
6
- metadata.gz: 30314626dfd9d39c5c16be816f9a0bdce57029e900a36c229573c5d797fe242fa79207aee6a3e7d905ddfe3bf616563686207532747bbc8ad41feb94e2ce7fae
7
- data.tar.gz: 964381ab25de55665a7d1c426669bc849e792e669aef8e3170d7b97d91083f9575ceb46486dacc0a3033ded02f870e87bb0ca1cc7016dfbe2646dd269d31cc09
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(api_login_id,api_transaction_key,iframeCommunicatorUrl,customerProfileId = '37696245')
8
+ def get_accept_customer_profile_page(customerProfileId = '37696245')
9
9
  config = YAML.load_file(File.dirname(__FILE__) + "/../credentials.yml")
10
10
 
11
- # transaction = Transaction.new(config['api_login_id'], config['api_transaction_key'], :gateway => :sandbox)
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,setting1])
24
- puts "TESTING #{setting1.settingValue}"
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
- # if response.messages.resultCode == MessageTypeEnum::Ok
34
- # puts "Successfully got Accept Customer page token."
35
- # puts " Response code: #{response.messages.messages[0].code}"
36
- # puts " Response message: #{response.messages.messages[0].text}"
37
- # puts " Token: #{response.token}"
38
- # else
39
- # puts "#{response.messages.messages[0].code}"
40
- # puts "#{response.messages.messages[0].text}"
41
- # raise "Failed to get hosted profile page with customer profile ID #{request.customerProfileId}"
42
- # end
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(api_login_id,api_transaction_key,customerProfileId = '40036377')
8
+ def get_customer_profile(customerProfileId = '40036377')
9
9
  config = YAML.load_file(File.dirname(__FILE__) + "/../credentials.yml")
10
10
 
11
- # transaction = Transaction.new(config['api_login_id'], config['api_transaction_key'], :gateway => :sandbox)
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
- # if response.messages.resultCode == MessageTypeEnum::Ok
22
- # puts "Successfully retrieved a customer with profile ID is #{request.customerProfileId} and whose customer ID is #{response.profile.merchantCustomerId}."
23
- # response.profile.paymentProfiles.each do |paymentProfile|
24
- # puts " Payment Profile ID #{paymentProfile.customerPaymentProfileId}"
25
- # puts " Payment Details:"
26
- # if paymentProfile.billTo != nil
27
- # puts " Last Name: #{paymentProfile.billTo.lastName}"
28
- # puts " Address: #{paymentProfile.billTo.address}"
29
- # end
30
- # end
31
- # response.profile.shipToList.each do |ship|
32
- # puts " Shipping Address ID #{ship.customerAddressId}"
33
- # puts " Shipping Details:"
34
- # puts " First Name: #{ship.firstName}"
35
- # puts " Last Name: #{ship.lastName}"
36
- # puts " Address: #{ship.address}"
37
- # end
38
-
39
- # if response.subscriptionIds != nil && response.subscriptionIds.subscriptionId != nil
40
- # puts " List of subscriptions: "
41
- # response.subscriptionIds.subscriptionId.each do |subscriptionId|
42
- # puts " #{subscriptionId}"
43
- # end
44
- # end
45
-
46
- # else
47
- # puts response.messages.messages[0].text
48
- # raise "Failed to get customer profile information with ID #{request.customerProfileId}"
49
- # end
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(api_login_id,api_transaction_key,token)
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
- # transaction = Transaction.new(config['api_login_id'], config['api_transaction_key'], :gateway => :sandbox)
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
- # request.transactionRequest.amount = ((SecureRandom.random_number + 1 ) * 150 ).round(2)
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
- # request.transactionRequest.payment.opaqueData = OpaqueDataType.new('COMMON.ACCEPT.INAPP.PAYMENT','eyJjb2RlIjoiNTBfMl8wNjAwMDUzQTczNERGMDY0MUMyMzUxMkIyQTM2MUE3QTBFQUQ4NTIxQ0EzQjM3MUU1REMyMjlEQkYwMjRERjI5QzdFOTJBMDIzNzJGRDVDQkI0ODRDMTQ2NDYyQ0U4NkFCRjA0Q0Y3IiwidG9rZW4iOiI5NTM5MzYyNzY1NjM2NTgyODA0NjA0IiwidiI6IjEuMSJ9')
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(api_login_id,api_transaction_key,customerId=nil,iframeCommunicatorUrl)
8
+ def get_an_accept_payment_page()
9
9
  config = YAML.load_file(File.dirname(__FILE__) + "/../credentials.yml")
10
10
 
11
- # transaction = Transaction.new(config['api_login_id'], config['api_transaction_key'], :gateway => :sandbox)
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 = 99
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
- # if response.messages.resultCode == MessageTypeEnum::Ok
57
- # puts "#{response.messages.messages[0].code}"
58
- # puts "#{response.messages.messages[0].text}"
59
- # puts "#{response.token}"
60
- # else
61
- # puts "#{response.messages.messages[0].code}"
62
- # puts "#{response.messages.messages[0].text}"
63
- # raise "Failed to get hosted payment page"
64
- # end
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
 
@@ -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"
@@ -2,8 +2,8 @@
2
2
  # api_login_id: 5KP3u95bQpv
3
3
  # api_transaction_key: 346HZ32z3fP4hTG2
4
4
 
5
- api_login_id: 87N83jqsSa3R
6
- api_transaction_key: 4K7kREpEd2bc988W
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authorizenetsample
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.5
4
+ version: 1.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Authorize.Net