workarea-authorize_cim 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +20 -0
  3. data/.github/ISSUE_TEMPLATE/bug_report.md +37 -0
  4. data/.github/ISSUE_TEMPLATE/documentation-request.md +17 -0
  5. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  6. data/.gitignore +13 -0
  7. data/.rails-rubocop.yml +130 -0
  8. data/.rubocop.yml +13 -0
  9. data/CHANGELOG.md +90 -0
  10. data/CODE_OF_CONDUCT.md +3 -0
  11. data/CONTRIBUTING.md +3 -0
  12. data/Gemfile +12 -0
  13. data/LICENSE +52 -0
  14. data/LICENSE.md +3 -0
  15. data/README.md +40 -0
  16. data/Rakefile +50 -0
  17. data/app/errors/workarea/payment/create_profile_error.rb +19 -0
  18. data/app/models/workarea/payment.decorator +14 -0
  19. data/app/models/workarea/payment/authorize/credit_card.decorator +61 -0
  20. data/app/models/workarea/payment/capture/credit_card.decorator +38 -0
  21. data/app/models/workarea/payment/profile.decorator +169 -0
  22. data/app/models/workarea/payment/purchase/credit_card.decorator +61 -0
  23. data/app/models/workarea/payment/refund.decorator +19 -0
  24. data/app/models/workarea/payment/refund/credit_card.decorator +39 -0
  25. data/app/models/workarea/payment/store_credit_card.decorator +122 -0
  26. data/app/models/workarea/payment/tender/credit_card.decorator +25 -0
  27. data/app/models/workarea/payment/transaction.decorator +16 -0
  28. data/bin/rails +17 -0
  29. data/bin/rake +17 -0
  30. data/bin/rspec +17 -0
  31. data/bin/rubocop +17 -0
  32. data/config/initializers/configuration.rb +3 -0
  33. data/lib/active_merchant/billing/bogus_authorize_net_cim_gateway.rb +99 -0
  34. data/lib/workarea/authorize_cim.rb +47 -0
  35. data/lib/workarea/authorize_cim/engine.rb +10 -0
  36. data/lib/workarea/authorize_cim/error.rb +12 -0
  37. data/lib/workarea/authorize_cim/version.rb +7 -0
  38. data/test/dummy/Rakefile +6 -0
  39. data/test/dummy/app/assets/config/manifest.js +4 -0
  40. data/test/dummy/app/assets/images/.keep +0 -0
  41. data/test/dummy/app/assets/javascripts/application.js +13 -0
  42. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  43. data/test/dummy/app/controllers/application_controller.rb +3 -0
  44. data/test/dummy/app/controllers/concerns/.keep +0 -0
  45. data/test/dummy/app/helpers/application_helper.rb +2 -0
  46. data/test/dummy/app/jobs/application_job.rb +2 -0
  47. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  48. data/test/dummy/app/models/concerns/.keep +0 -0
  49. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  50. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  51. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  52. data/test/dummy/bin/bundle +3 -0
  53. data/test/dummy/bin/rails +4 -0
  54. data/test/dummy/bin/rake +4 -0
  55. data/test/dummy/bin/setup +34 -0
  56. data/test/dummy/bin/update +29 -0
  57. data/test/dummy/config.ru +5 -0
  58. data/test/dummy/config/application.rb +20 -0
  59. data/test/dummy/config/boot.rb +5 -0
  60. data/test/dummy/config/cable.yml +9 -0
  61. data/test/dummy/config/environment.rb +5 -0
  62. data/test/dummy/config/environments/development.rb +56 -0
  63. data/test/dummy/config/environments/production.rb +86 -0
  64. data/test/dummy/config/environments/test.rb +43 -0
  65. data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
  66. data/test/dummy/config/initializers/assets.rb +11 -0
  67. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  68. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  69. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  70. data/test/dummy/config/initializers/inflections.rb +16 -0
  71. data/test/dummy/config/initializers/mime_types.rb +4 -0
  72. data/test/dummy/config/initializers/new_framework_defaults.rb +21 -0
  73. data/test/dummy/config/initializers/session_store.rb +3 -0
  74. data/test/dummy/config/initializers/workarea.rb +5 -0
  75. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  76. data/test/dummy/config/locales/en.yml +23 -0
  77. data/test/dummy/config/puma.rb +47 -0
  78. data/test/dummy/config/routes.rb +5 -0
  79. data/test/dummy/config/secrets.yml +22 -0
  80. data/test/dummy/config/spring.rb +6 -0
  81. data/test/dummy/db/seeds.rb +3 -0
  82. data/test/dummy/lib/assets/.keep +0 -0
  83. data/test/dummy/log/.keep +0 -0
  84. data/test/dummy/public/404.html +67 -0
  85. data/test/dummy/public/422.html +67 -0
  86. data/test/dummy/public/500.html +66 -0
  87. data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
  88. data/test/dummy/public/apple-touch-icon.png +0 -0
  89. data/test/dummy/public/favicon.ico +0 -0
  90. data/test/factories/workarea/factories/authorize_cim_factory.rb +14 -0
  91. data/test/models/workarea/payment/authorize/credit_card_test.decorator +17 -0
  92. data/test/models/workarea/payment/authorize_cim_integration_test.rb +137 -0
  93. data/test/models/workarea/payment/capture/credit_card_test.decorator +80 -0
  94. data/test/models/workarea/payment/credit_card_integration_test.decorator +30 -0
  95. data/test/models/workarea/payment/profile_test.rb +60 -0
  96. data/test/models/workarea/payment/purchase/credit_card_test.decorator +17 -0
  97. data/test/models/workarea/payment/refund/credit_card_test.decorator +95 -0
  98. data/test/models/workarea/payment/refund_test.decorator +14 -0
  99. data/test/models/workarea/payment/store_credit_card_test.decorator +7 -0
  100. data/test/services/workarea/cancel_order_test.decorator +55 -0
  101. data/test/support/workarea/authorize_cim_gateway_duplicate_window_patch.rb +14 -0
  102. data/test/support/workarea/authorize_cim_gateway_vcr_config.rb +22 -0
  103. data/test/support/workarea/workarea_3_2_backports.rb +57 -0
  104. data/test/system/workarea/storefront/orders_system_test.decorator +28 -0
  105. data/test/test_helper.rb +17 -0
  106. data/test/vcr_cassettes/authorize_net_cim/auth_capture.yml +435 -0
  107. data/test/vcr_cassettes/authorize_net_cim/auth_void.yml +436 -0
  108. data/test/vcr_cassettes/authorize_net_cim/purchase_void.yml +436 -0
  109. data/test/vcr_cassettes/authorize_net_cim/store_auth.yml +371 -0
  110. data/test/vcr_cassettes/authorize_net_cim/store_purchase.yml +371 -0
  111. data/test/vcr_cassettes/credit_card/auth_capture.yml +438 -0
  112. data/test/vcr_cassettes/credit_card/auth_void.yml +439 -0
  113. data/test/vcr_cassettes/credit_card/purchase_void.yml +439 -0
  114. data/test/vcr_cassettes/credit_card/store_auth.yml +374 -0
  115. data/test/vcr_cassettes/credit_card/store_purchase.yml +374 -0
  116. data/test/workers/workarea/send_refund_email_test.decorator +70 -0
  117. data/workarea-authorize_cim.gemspec +27 -0
  118. metadata +187 -0
@@ -0,0 +1,122 @@
1
+ # frozen_string_literal: true
2
+ module Workarea
3
+ decorate Payment::StoreCreditCard, with: :cim do
4
+ def perform!
5
+ return true if @credit_card.token.present?
6
+ return false unless @credit_card.profile.gateway_id.present?
7
+
8
+ tmp_profile = customer_profile.params['profile']
9
+
10
+ existing_profiles = if tmp_profile.present?
11
+ [tmp_profile['payment_profiles']].flatten.compact
12
+ else
13
+ []
14
+ end
15
+
16
+ existing_match = existing_profiles.detect do |profile|
17
+ profile['payment']['credit_card']['card_number'].end_with?(@credit_card.number.last(4))
18
+ end
19
+
20
+ if existing_match.present?
21
+ @credit_card.token = existing_match['customer_payment_profile_id']
22
+ update_on_gateway
23
+ else
24
+ create_on_gateway
25
+ end
26
+
27
+ rescue ActiveMerchant::ActiveMerchantError
28
+ false
29
+ end
30
+
31
+ private
32
+
33
+ def address_hash
34
+ if address.blank?
35
+ {}
36
+ else
37
+ { first_name: address.first_name,
38
+ last_name: address.last_name,
39
+ company: address.company,
40
+ address: address.street,
41
+ city: address.city,
42
+ state: address.region,
43
+ zip: address.postal_code,
44
+ country: address.country,
45
+ phone_number: address.phone_number }
46
+ end
47
+ end
48
+
49
+ def customer_profile
50
+ @customer_profile ||= if gateway_id.present?
51
+ gateway.get_customer_profile(customer_profile_id: gateway_id)
52
+ else
53
+ gateway.create_customer_profile(
54
+ profile: @credit_card.slice(:email)
55
+ )
56
+ end
57
+ end
58
+
59
+ def customer_payment_profile
60
+ @customer_payment_profile ||=
61
+ begin
62
+ response = gateway.get_customer_payment_profile(
63
+ customer_profile_id: gateway_id,
64
+ customer_payment_profile_id: @credit_card.token
65
+ )
66
+
67
+ raise AuthorizeCim::Error, response.params unless response.success?
68
+ response
69
+ end
70
+ end
71
+
72
+ def create_on_gateway
73
+ response = gateway.create_customer_payment_profile(
74
+ customer_profile_id: gateway_id,
75
+ payment_profile: {
76
+ payment: {
77
+ credit_card: active_merchant_card
78
+ },
79
+ bill_to: address_hash
80
+ }
81
+ )
82
+
83
+ raise ActiveMerchant::ResponseError, response unless response.success?
84
+ @credit_card.token = response.params['customer_payment_profile_id']
85
+ end
86
+
87
+ def update_on_gateway
88
+ profile = customer_payment_profile.params['payment_profile']
89
+
90
+ card = ActiveMerchant::Billing::CreditCard.new(
91
+ first_name: @credit_card.first_name,
92
+ last_name: @credit_card.last_name,
93
+ month: @credit_card.month,
94
+ year: @credit_card.year,
95
+ number: profile['payment']['credit_card']['card_number'],
96
+ verification_value: @credit_card.cvv
97
+ )
98
+
99
+ payment_profile = { customer_payment_profile_id: @credit_card.token,
100
+ payment: { credit_card: card },
101
+ bill_to: address_hash }
102
+
103
+ response = gateway.update_customer_payment_profile(customer_profile_id: gateway_id,
104
+ payment_profile: payment_profile)
105
+
106
+ raise ActiveMerchant::ResponseError, response unless response.success?
107
+ true
108
+ end
109
+
110
+ def gateway_id
111
+ @credit_card.profile.gateway_id
112
+ end
113
+
114
+ def active_merchant_card
115
+ @credit_card.to_active_merchant
116
+ end
117
+
118
+ def address
119
+ @credit_card.try(:address)
120
+ end
121
+ end
122
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+ module Workarea
3
+ decorate Payment::Tender::CreditCard, with: :cim do
4
+ decorated do
5
+ field :ip_address, type: String
6
+ end
7
+
8
+ # @return [String]
9
+ def gateway_profile_id
10
+ profile.gateway_id
11
+ end
12
+
13
+ def valid_capture_date?
14
+ payment.eligible_for_refund?.tap do |eligible|
15
+ unless eligible
16
+ payment.errors.add(
17
+ :base,
18
+ 'The initial charge has not yet been settled.' \
19
+ 'A transaction must be settled before you can issue a refund.'
20
+ )
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+ module Workarea
3
+ decorate Payment::Transaction, with: :cim do
4
+ def purchase?
5
+ action == "purchase"
6
+ end
7
+
8
+ def refunds
9
+ self.class.successful.refunds.where(reference_id: id)
10
+ end
11
+
12
+ def refund_amount
13
+ refunds.to_a.sum(&:amount)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
3
+
4
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
5
+ ENGINE_PATH = File.expand_path('../../lib/workarea/authorize_cim/engine', __FILE__)
6
+
7
+ # Set up gems listed in the Gemfile.
8
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
9
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
10
+
11
+ require 'action_controller/railtie'
12
+ require 'action_mailer/railtie'
13
+ require 'action_view/railtie'
14
+ require 'sprockets/railtie'
15
+ require "rails/test_unit/railtie"
16
+
17
+ require 'rails/engine/commands'
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'rake' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("rake", "rake")
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'rspec' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require 'pathname'
11
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require 'rubygems'
15
+ require 'bundler/setup'
16
+
17
+ load Gem.bin_path('rspec-core', 'rspec')
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'rubocop' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require 'pathname'
11
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require 'rubygems'
15
+ require 'bundler/setup'
16
+
17
+ load Gem.bin_path('rubocop', 'rubocop')
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ Workarea::AuthorizeCim.auto_initialize_gateway
@@ -0,0 +1,99 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveMerchant
4
+ module Billing
5
+ class BogusAuthorizeNetCimGateway < BogusGateway
6
+ SUCCESS_PAYMENT_PROFILE_ID = '111111'
7
+ FAILURE_PAYMENT_PROFILE_ID = '222222'
8
+ ERROR_PAYMENT_PROFILE_ID = '333333'
9
+
10
+ def initialize(*args)
11
+ super
12
+ @test = true
13
+ end
14
+
15
+ def find_customer_profile_id
16
+ "1#{SecureRandom.random_number(100_000)}"
17
+ end
18
+
19
+ def create_customer_profile(_options)
20
+ profile_id = find_customer_profile_id
21
+ params = { 'messages' => { 'result_code' => 'Ok', 'message' => { 'code' => 'I00001', 'text' => 'Successful.' } }, 'customer_profile_id' => profile_id, 'customer_payment_profile_id_list' => nil, 'customer_shipping_address_id_list' => nil, 'validation_direct_response_list' => nil }
22
+ Response.new(true, SUCCESS_MESSAGE, params, test: true)
23
+ end
24
+
25
+ def create_customer_payment_profile(options)
26
+ card = options[:payment_profile][:payment][:credit_card]
27
+ params = { 'messages' => { 'result_code' => 'Ok', 'message' => { 'code' => 'I00001', 'text' => 'Successful.' } } }
28
+
29
+ case card.number
30
+ when /1$/
31
+ Response.new(true, SUCCESS_MESSAGE, params.merge('customer_payment_profile_id' => SUCCESS_PAYMENT_PROFILE_ID), test: true)
32
+ when /2$/
33
+ Response.new(false, SUCCESS_MESSAGE, params.merge('customer_payment_profile_id' => FAILURE_PAYMENT_PROFILE_ID), test: true)
34
+ else
35
+ Response.new(false, SUCCESS_MESSAGE, params.merge('customer_payment_profile_id' => ERROR_PAYMENT_PROFILE_ID), test: true)
36
+ end
37
+ end
38
+
39
+ def create_customer_shipping_address(options); end
40
+
41
+ def delete_customer_profile(_options)
42
+ params = { 'messages' => { 'result_code' => 'Ok', 'message' => { 'code' => 'I00001', 'text' => 'Successful.' } } }
43
+ Response.new(true, SUCCESS_MESSAGE, params, test: true)
44
+ end
45
+
46
+ def delete_customer_payment_profile(options); end
47
+
48
+ def delete_customer_shipping_address(options); end
49
+
50
+ def get_customer_profile(options)
51
+ params = { 'messages' => { 'result_code' => 'Ok', 'message' => { 'code' => 'I00001', 'text' => 'Successful.' } }, 'profile' => { 'email' => 'user@workarea.com', 'customer_profile_id' => options[:customer_profile_id], 'payment_profiles' => nil } }
52
+ Response.new(true, SUCCESS_MESSAGE, params, test: true)
53
+ end
54
+
55
+ def get_customer_profile_ids(options = {}); end
56
+
57
+ def get_customer_payment_profile(_options)
58
+ params = { 'messages' => { 'result_code' => 'Ok', 'message' => { 'code' => 'I00001', 'text' => 'Successful.' } }, 'payment_profile' => { 'customer_payment_profile_id' => '8619844', 'payment' => { 'credit_card' => { 'card_number' => 'XXXX1111', 'expiration_date' => 'XXXX' } } } }
59
+ Response.new(true, SUCCESS_MESSAGE, params, test: true)
60
+ end
61
+
62
+ def get_customer_shipping_address(options); end
63
+
64
+ def update_customer_profile(options); end
65
+
66
+ def update_customer_payment_profile(_options)
67
+ params = { 'messages' => { 'result_code' => 'Ok', 'message' => { 'code' => 'I00001', 'text' => 'Successful.' } } }
68
+ Response.new(true, SUCCESS_MESSAGE, params, test: true)
69
+ end
70
+
71
+ def update_customer_shipping_address(options); end
72
+
73
+ def create_customer_profile_transaction(options)
74
+ payment_profile_id = options[:transaction][:customer_payment_profile_id]
75
+
76
+ unless payment_profile_id.nil? || payment_profile_id =~ /^1/ || payment_profile_id =~ /^2/
77
+ raise Error, NUMBER_ERROR_MESSAGE
78
+ end
79
+
80
+ if payment_profile_id =~ /^1/ || payment_profile_id.nil?
81
+ params = { 'messages' => { 'result_code' => 'Ok', 'message' => { 'code' => 'I00001', 'text' => 'Successful.' } }, 'direct_response' => { 'raw' => '1,1,1,(TESTMODE) This transaction has been approved.,000000,P,0,,,77.49,CC,auth_only,,,,,,,,,,,,bcrouse@workarea.com,,,,,,,,,,,,,,F6000E62F2517691DED641D62E1B0FD8,,,,,,,,,,,,,XXXX5100,MasterCard,,,,,,,,,,,,,,,,', 'response_code' => '1', 'response_subcode' => '1', 'response_reason_code' => '1', 'message' => '(TESTMODE) This transaction has been approved.', 'approval_code' => '000000', 'avs_response' => 'P', 'transaction_id' => '0', 'invoice_number' => '', 'order_description' => '', 'amount' => '77.49', 'method' => 'CC', 'transaction_type' => 'auth_only', 'customer_id' => '', 'first_name' => '', 'last_name' => '', 'company' => '', 'address' => '', 'city' => '', 'state' => '', 'zip_code' => '', 'country' => '', 'phone' => '', 'fax' => '', 'email_address' => 'bcrouse@workarea.com', 'ship_to_first_name' => '', 'ship_to_last_name' => '', 'ship_to_company' => '', 'ship_to_address' => '', 'ship_to_city' => '', 'ship_to_state' => '', 'ship_to_zip_code' => '', 'ship_to_country' => '', 'tax' => '', 'duty' => '', 'tax_exempt' => '', 'purchase_order_number' => '', 'md5_hash' => 'F6000E62F2517691DED641D62E1B0FD8', 'card_code' => '', 'cardholder_authentication_verification_response' => '', 'account_number' => 'XXXX5100', 'card_type' => 'MasterCard', 'split_tender_id' => '', 'requested_amount' => '', 'balance_on_card' => '' } }
82
+ Response.new(true, SUCCESS_MESSAGE, params, test: true, authorization: AUTHORIZATION)
83
+ else
84
+ params = { 'messages' => { 'result_code' => 'FAILURE', 'message' => { 'code' => 'BOGUS_FAIL', 'text' => 'Failure.' } }, 'direct_response' => { 'raw' => '1,1,1,(TESTMODE) This transaction has been declined.,000000,P,0,,,77.49,CC,auth_only,,,,,,,,,,,,bcrouse@workarea.com,,,,,,,,,,,,,,F6000E62F2517691DED641D62E1B0FD8,,,,,,,,,,,,,XXXX5100,MasterCard,,,,,,,,,,,,,,,,', 'response_code' => '1', 'response_subcode' => '1', 'response_reason_code' => '1', 'message' => FAILURE_MESSAGE, 'approval_code' => '000000', 'avs_response' => 'P', 'transaction_id' => '0', 'invoice_number' => '', 'order_description' => '', 'amount' => '77.49', 'method' => 'CC', 'transaction_type' => 'auth_only', 'customer_id' => '', 'first_name' => '', 'last_name' => '', 'company' => '', 'address' => '', 'city' => '', 'state' => '', 'zip_code' => '', 'country' => '', 'phone' => '', 'fax' => '', 'email_address' => 'bcrouse@workarea.com', 'ship_to_first_name' => '', 'ship_to_last_name' => '', 'ship_to_company' => '', 'ship_to_address' => '', 'ship_to_city' => '', 'ship_to_state' => '', 'ship_to_zip_code' => '', 'ship_to_country' => '', 'tax' => '', 'duty' => '', 'tax_exempt' => '', 'purchase_order_number' => '', 'md5_hash' => 'F6000E62F2517691DED641D62E1B0FD8', 'card_code' => '', 'cardholder_authentication_verification_response' => '', 'account_number' => 'XXXX5100', 'card_type' => 'MasterCard', 'split_tender_id' => '', 'requested_amount' => '', 'balance_on_card' => '' } }
85
+ Response.new(false, FAILURE_MESSAGE, params, test: true)
86
+ end
87
+ end
88
+
89
+ def create_customer_profile_transaction_for_refund(_options)
90
+ response_params = { 'messages' => { 'result_code' => 'Ok', 'message' => { 'code' => 'I00001', 'text' => 'Successful.' } }, 'direct_response' => { 'raw' => '1,1,1,This transaction has been approved.,,P,2246535996,,,10.00,CC,credit,,Jon,Bytof,workarea,100 Market St,Philadelphia,PA,19106,US,2154503048,,jbytof+tahari@workarea.com,,,,,,,,,,,,,,CD971B50C98175583C8F4BB1FECE7215,,,,,,,,,,,,,XXXX0015,MasterCard,,,,,,,,,,,,,,,,', 'response_code' => '1', 'response_subcode' => '1', 'response_reason_code' => '1', 'message' => 'This transaction has been approved.', 'approval_code' => '', 'avs_response' => 'P', 'transaction_id' => '2246535996', 'invoice_number' => '', 'order_description' => '', 'amount' => '10.00', 'method' => 'CC', 'transaction_type' => 'credit', 'customer_id' => '', 'first_name' => 'Jon', 'last_name' => 'Bytof', 'company' => 'workarea', 'address' => '100 Market St', 'city' => 'Philadelphia', 'state' => 'PA', 'zip_code' => '19106', 'country' => 'US', 'phone' => '2154503048', 'fax' => '', 'email_address' => 'jbytof+tahari@workarea.com', 'ship_to_first_name' => '', 'ship_to_last_name' => '', 'ship_to_company' => '', 'ship_to_address' => '', 'ship_to_city' => '', 'ship_to_state' => '', 'ship_to_zip_code' => '', 'ship_to_country' => '', 'tax' => '', 'duty' => '', 'freight' => '', 'tax_exempt' => '', 'purchase_order_number' => '', 'md5_hash' => 'CD971B50C98175583C8F4BB1FECE7215', 'card_code' => '', 'cardholder_authentication_verification_response' => '', 'account_number' => 'XXXX0015', 'card_type' => 'MasterCard', 'split_tender_id' => '', 'requested_amount' => '', 'balance_on_card' => '' } }
91
+ Response.new(true, SUCCESS_MESSAGE, response_params, test: true, authorization: AUTHORIZATION)
92
+ end
93
+
94
+ def create_customer_profile_transaction_for_void(options); end
95
+
96
+ def validate_customer_payment_profile(options); end
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'workarea'
4
+
5
+ require 'workarea/authorize_cim/engine'
6
+ require 'workarea/authorize_cim/version'
7
+ require 'workarea/authorize_cim/error'
8
+
9
+ require 'active_merchant/billing/bogus_authorize_net_cim_gateway'
10
+
11
+ module Workarea
12
+ module AuthorizeCim
13
+ # Credentials for Authorize.Net from Rails secrets.
14
+ #
15
+ # @return [Hash]
16
+ def self.credentials
17
+ return {} unless Rails.application.secrets.authorize.present?
18
+ Rails.application.secrets.authorize.symbolize_keys
19
+ end
20
+
21
+ # Conditionally use the real gateway when secrets are present.
22
+ # Otherwise, use the bogus gateway.
23
+ #
24
+ # @return [ActiveMerchant::Billing::Gateway]
25
+ def self.gateway
26
+ Workarea.config.gateways.credit_card
27
+ end
28
+
29
+ def self.gateway=(gateway)
30
+ Workarea.config.gateways.credit_card = gateway
31
+ end
32
+
33
+ def self.auto_initialize_gateway
34
+ if credentials.present?
35
+ if ENV['HTTP_PROXY'].present?
36
+ uri = URI.parse(ENV['HTTP_PROXY'])
37
+ ActiveMerchant::Billing::AuthorizeNetCimGateway.proxy_address = uri.host
38
+ ActiveMerchant::Billing::AuthorizeNetCimGateway.proxy_port = uri.port
39
+ end
40
+
41
+ self.gateway = ActiveMerchant::Billing::AuthorizeNetCimGateway.new credentials
42
+ else
43
+ self.gateway = ActiveMerchant::Billing::BogusAuthorizeNetCimGateway.new
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Workarea
4
+ module AuthorizeCim
5
+ class Engine < ::Rails::Engine
6
+ include Workarea::Plugin
7
+ isolate_namespace Workarea::AuthorizeCim
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,12 @@
1
+ module Workarea
2
+ module AuthorizeCim
3
+ class Error < StandardError
4
+ def initialize(params)
5
+ @code = params['message']['code']
6
+ @text = params['message']['text']
7
+
8
+ super "#{@text} (#{@code})"
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Workarea
4
+ module AuthorizeCim
5
+ VERSION = '2.1.1'
6
+ end
7
+ end
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require_relative 'config/application'
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,4 @@
1
+
2
+ //= link_tree ../images
3
+ //= link_directory ../javascripts .js
4
+ //= link_directory ../stylesheets .css
File without changes
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .