archetype_spree_gateway 3.9.5

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.
Files changed (124) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +21 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +39 -0
  5. data/Gemfile +9 -0
  6. data/Guardfile +9 -0
  7. data/LICENSE.md +26 -0
  8. data/README.md +105 -0
  9. data/Rakefile +15 -0
  10. data/app/models/spree/billing_integration.rb +21 -0
  11. data/app/models/spree/check.rb +41 -0
  12. data/app/models/spree/gateway/authorize_net.rb +45 -0
  13. data/app/models/spree/gateway/authorize_net_cim.rb +213 -0
  14. data/app/models/spree/gateway/balanced_gateway.rb +64 -0
  15. data/app/models/spree/gateway/banwire.rb +15 -0
  16. data/app/models/spree/gateway/beanstream.rb +193 -0
  17. data/app/models/spree/gateway/braintree_gateway.rb +184 -0
  18. data/app/models/spree/gateway/card_save.rb +10 -0
  19. data/app/models/spree/gateway/cyber_source.rb +10 -0
  20. data/app/models/spree/gateway/data_cash.rb +10 -0
  21. data/app/models/spree/gateway/epay.rb +10 -0
  22. data/app/models/spree/gateway/eway.rb +18 -0
  23. data/app/models/spree/gateway/eway_rapid.rb +14 -0
  24. data/app/models/spree/gateway/maxipago.rb +14 -0
  25. data/app/models/spree/gateway/migs.rb +11 -0
  26. data/app/models/spree/gateway/moneris.rb +10 -0
  27. data/app/models/spree/gateway/pay_junction.rb +14 -0
  28. data/app/models/spree/gateway/pay_pal_gateway.rb +12 -0
  29. data/app/models/spree/gateway/payflow_pro.rb +15 -0
  30. data/app/models/spree/gateway/paymill.rb +12 -0
  31. data/app/models/spree/gateway/payu_polska_gateway.rb +24 -0
  32. data/app/models/spree/gateway/pin_gateway.rb +60 -0
  33. data/app/models/spree/gateway/quickpay.rb +9 -0
  34. data/app/models/spree/gateway/sage_pay.rb +11 -0
  35. data/app/models/spree/gateway/secure_pay_au.rb +10 -0
  36. data/app/models/spree/gateway/spreedly_core_gateway.rb +11 -0
  37. data/app/models/spree/gateway/stripe_ach_gateway.rb +60 -0
  38. data/app/models/spree/gateway/stripe_apple_pay_gateway.rb +10 -0
  39. data/app/models/spree/gateway/stripe_elements_gateway.rb +61 -0
  40. data/app/models/spree/gateway/stripe_gateway.rb +151 -0
  41. data/app/models/spree/gateway/usa_epay_transaction.rb +9 -0
  42. data/app/models/spree/gateway/worldpay.rb +91 -0
  43. data/app/models/spree/payu_polska.rb +41 -0
  44. data/app/models/spree_gateway/apple_pay_order_decorator.rb +20 -0
  45. data/app/models/spree_gateway/apple_pay_payment_decorator.rb +9 -0
  46. data/app/models/spree_gateway/credit_card_decorator.rb +10 -0
  47. data/app/models/spree_gateway/order_decorator.rb +28 -0
  48. data/app/models/spree_gateway/payment_decorator.rb +36 -0
  49. data/app/views/spree/checkout/_payment_confirm.html.erb +39 -0
  50. data/app/views/spree/checkout/_payu.html +12 -0
  51. data/config/initializers/inflections.rb +3 -0
  52. data/config/initializers/spree_permitted_attributes.rb +5 -0
  53. data/config/locales/bg.yml +4 -0
  54. data/config/locales/de.yml +4 -0
  55. data/config/locales/en.yml +47 -0
  56. data/config/locales/sv.yml +4 -0
  57. data/config/routes.rb +19 -0
  58. data/db/migrate/20200317135551_add_spree_check_payment_source.rb +22 -0
  59. data/db/migrate/20200422114908_add_intent_key_to_payment.rb +5 -0
  60. data/lib/active_merchant/billing/stripe_gateway_decorator.rb +33 -0
  61. data/lib/controllers/spree/api/v2/storefront/intents_controller.rb +45 -0
  62. data/lib/controllers/spree/apple_pay_domain_verification_controller.rb +11 -0
  63. data/lib/generators/spree_gateway/install/install_generator.rb +19 -0
  64. data/lib/spree_frontend/controllers/spree/checkout_controller_decorator.rb +19 -0
  65. data/lib/spree_gateway/engine.rb +80 -0
  66. data/lib/spree_gateway/version.rb +5 -0
  67. data/lib/spree_gateway.rb +4 -0
  68. data/lib/views/backend/spree/admin/log_entries/_braintree.html.erb +31 -0
  69. data/lib/views/backend/spree/admin/log_entries/_stripe.html.erb +28 -0
  70. data/lib/views/backend/spree/admin/payments/source_forms/_quickcheckout.html.erb +8 -0
  71. data/lib/views/backend/spree/admin/payments/source_forms/_stripe.html.erb +79 -0
  72. data/lib/views/backend/spree/admin/payments/source_forms/_stripe_ach.html.erb +86 -0
  73. data/lib/views/backend/spree/admin/payments/source_forms/_stripe_apple_pay.html.erb +0 -0
  74. data/lib/views/backend/spree/admin/payments/source_forms/_stripe_elements.html.erb +79 -0
  75. data/lib/views/backend/spree/admin/payments/source_views/_stripe.html.erb +1 -0
  76. data/lib/views/backend/spree/admin/payments/source_views/_stripe_ach.html.erb +21 -0
  77. data/lib/views/backend/spree/admin/payments/source_views/_stripe_apple_pay.html.erb +1 -0
  78. data/lib/views/backend/spree/admin/payments/source_views/_stripe_elements.html.erb +1 -0
  79. data/lib/views/frontend/spree/checkout/payment/_stripe.html.erb +86 -0
  80. data/lib/views/frontend/spree/checkout/payment/_stripe_ach.html.erb +81 -0
  81. data/lib/views/frontend/spree/checkout/payment/_stripe_ach_verify.html.erb +16 -0
  82. data/lib/views/frontend/spree/checkout/payment/_stripe_additional_info.html.erb +16 -0
  83. data/lib/views/frontend/spree/checkout/payment/_stripe_apple_pay.html.erb +109 -0
  84. data/lib/views/frontend/spree/checkout/payment/_stripe_elements.html.erb +110 -0
  85. data/script/rails +7 -0
  86. data/spec/factories/check_factory.rb +10 -0
  87. data/spec/features/admin/stripe_elements_payment_spec.rb +100 -0
  88. data/spec/features/stripe_checkout_spec.rb +130 -0
  89. data/spec/features/stripe_elements_3ds_checkout_spec.rb +225 -0
  90. data/spec/models/gateway/authorize_net_cim_spec.rb +29 -0
  91. data/spec/models/gateway/authorize_net_spec.rb +23 -0
  92. data/spec/models/gateway/balanced_gateway_spec.rb +17 -0
  93. data/spec/models/gateway/banwire_spec.rb +11 -0
  94. data/spec/models/gateway/beanstream_spec.rb +17 -0
  95. data/spec/models/gateway/braintree_gateway_spec.rb +420 -0
  96. data/spec/models/gateway/card_save_spec.rb +11 -0
  97. data/spec/models/gateway/cyber_source_spec.rb +11 -0
  98. data/spec/models/gateway/data_cash_spec.rb +11 -0
  99. data/spec/models/gateway/epay_spec.rb +11 -0
  100. data/spec/models/gateway/eway_rapid_spec.rb +23 -0
  101. data/spec/models/gateway/eway_spec.rb +29 -0
  102. data/spec/models/gateway/maxipago_spec.rb +17 -0
  103. data/spec/models/gateway/moneris_spec.rb +11 -0
  104. data/spec/models/gateway/pay_junction_spec.rb +23 -0
  105. data/spec/models/gateway/pay_pal_spec.rb +11 -0
  106. data/spec/models/gateway/payflow_pro_spec.rb +23 -0
  107. data/spec/models/gateway/paymill_spec.rb +11 -0
  108. data/spec/models/gateway/pin_gateway_spec.rb +54 -0
  109. data/spec/models/gateway/quickpay_spec.rb +11 -0
  110. data/spec/models/gateway/sage_pay_spec.rb +11 -0
  111. data/spec/models/gateway/secure_pay_au_spec.rb +11 -0
  112. data/spec/models/gateway/stripe_ach_gateway_spec.rb +186 -0
  113. data/spec/models/gateway/stripe_gateway_spec.rb +199 -0
  114. data/spec/models/gateway/usa_epay_transaction_spec.rb +49 -0
  115. data/spec/models/gateway/worldpay_spec.rb +11 -0
  116. data/spec/models/spree/order_spec.rb +79 -0
  117. data/spec/requests/apple_pay_domain_verification.rb +45 -0
  118. data/spec/requests/spree/api/v2/storefront/intents_controller_spec.rb +198 -0
  119. data/spec/spec_helper.rb +10 -0
  120. data/spec/support/order_walktrough.rb +73 -0
  121. data/spec/support/wait_for_stripe.rb +27 -0
  122. data/spec/support/within_stripe_3ds_popup.rb +10 -0
  123. data/spree_gateway.gemspec +37 -0
  124. metadata +277 -0
@@ -0,0 +1,193 @@
1
+ module Spree
2
+ class Gateway::Beanstream < Gateway
3
+ preference :login, :string
4
+ preference :user, :string
5
+ preference :password, :string
6
+ preference :secure_profile_api_key, :string
7
+
8
+ def provider_class
9
+ ActiveMerchant::Billing::BeanstreamGateway
10
+ end
11
+
12
+ def payment_profiles_supported?
13
+ true
14
+ end
15
+
16
+ def create_profile(payment)
17
+ creditcard = payment.source
18
+ if creditcard.gateway_customer_profile_id.nil?
19
+ options = options_for_create_customer_profile(creditcard, {})
20
+ verify_creditcard_name!(creditcard)
21
+ result = provider.store(creditcard, options)
22
+ if result.success?
23
+ creditcard.update(:gateway_customer_profile_id => result.params['customerCode'], :gateway_payment_profile_id => result.params['customer_vault_id'])
24
+ else
25
+ payment.send(:gateway_error, result)
26
+ end
27
+ end
28
+ end
29
+
30
+ def capture(transaction, creditcard, gateway_options)
31
+ beanstream_gateway.capture((transaction.amount*100).round, transaction.response_code, gateway_options)
32
+ end
33
+
34
+ def void(transaction_response, creditcard, gateway_options)
35
+ beanstream_gateway.void(transaction_response, gateway_options)
36
+ end
37
+
38
+ def credit(amount, creditcard, response_code, gateway_options = {})
39
+ amount = (amount * -1) if amount < 0
40
+ beanstream_gateway.credit(amount, response_code, gateway_options)
41
+ end
42
+
43
+ private
44
+ def beanstream_gateway
45
+ ActiveMerchant::Billing::Base.gateway_mode = preferred_server.to_sym
46
+ gateway_options = options
47
+ ActiveMerchant::Billing::BeanstreamGateway.new(gateway_options)
48
+ end
49
+
50
+ def verify_creditcard_name!(creditcard)
51
+ bill_address = creditcard.payments.first.order.bill_address
52
+ creditcard.first_name = bill_address.firstname unless creditcard.first_name?
53
+ creditcard.last_name = bill_address.lastname unless creditcard.last_name?
54
+ end
55
+
56
+ def options_for_create_customer_profile(creditcard, gateway_options)
57
+ order = creditcard.payments.first.order
58
+ address = order.bill_address
59
+ { :email=>order.email,
60
+ :billing_address=>
61
+ { :name=>address.full_name,
62
+ :phone=>address.phone,
63
+ :address1=>address.address1,
64
+ :address2=>address.address2,
65
+ :city=>address.city,
66
+ :state=>address.state_name || address.state.abbr,
67
+ :country=>address.country.iso,
68
+ :zip=>address.zipcode
69
+ }
70
+ }.merge(gateway_options)
71
+ end
72
+
73
+ SECURE_PROFILE_URL = 'https://www.beanstream.com/scripts/payment_profile.asp'
74
+ SP_SERVICE_VERSION = '1.1'
75
+ PROFILE_OPERATIONS = { :new => 'N', :modify => 'M' }
76
+
77
+ ActiveMerchant::Billing::BeanstreamGateway.class_eval do
78
+
79
+ def store(credit_card, options = {})
80
+ post = {}
81
+ add_address(post, options)
82
+ add_credit_card(post, credit_card)
83
+ add_secure_profile_variables(post,options)
84
+ commit(post, true)
85
+ end
86
+
87
+ #can't actually delete a secure profile with the supplicaed API. This function sets the status of the profile to closed (C).
88
+ #Closed profiles will have to removed manually.
89
+ def delete(vault_id)
90
+ update(vault_id, false, { :status => 'C' })
91
+ end
92
+
93
+ #alias_method :unstore, :delete
94
+
95
+ # Update the values (such as CC expiration) stored at
96
+ # the gateway. The CC number must be supplied in the
97
+ # CreditCard object.
98
+ def update(vault_id, credit_card, options = {})
99
+ post = {}
100
+ add_address(post, options)
101
+ add_credit_card(post, credit_card)
102
+ options.merge!({ :vault_id => vault_id, :operation => secure_profile_action(:modify) })
103
+ add_secure_profile_variables(post,options)
104
+ commit(post, true)
105
+ end
106
+
107
+ # CORE #
108
+
109
+ def secure_profile_action(type)
110
+ PROFILE_OPERATIONS[type] || PROFILE_OPERATIONS[:new]
111
+ end
112
+
113
+ def add_credit_card(post, credit_card)
114
+ if credit_card
115
+ if credit_card.has_payment_profile?
116
+ post[:customerCode] = credit_card.gateway_customer_profile_id
117
+ else
118
+ post[:trnCardOwner] = credit_card.name
119
+ post[:trnCardNumber] = credit_card.number
120
+ post[:trnExpMonth] = format(credit_card.month, :two_digits)
121
+ post[:trnExpYear] = format(credit_card.year, :two_digits)
122
+ post[:trnCardCvd] = credit_card.verification_value
123
+ end
124
+ end
125
+ end
126
+
127
+ def add_secure_profile_variables(post, options = {})
128
+ post[:serviceVersion] = SP_SERVICE_VERSION
129
+ post[:responseFormat] = 'QS'
130
+ post[:cardValidation] = (options[:cardValidation].to_i == 1) || '0'
131
+
132
+ post[:operationType] = options[:operationType] || options[:operation] || secure_profile_action(:new)
133
+ post[:customerCode] = options[:billing_id] || options[:vault_id] || false
134
+ post[:status] = options[:status]
135
+ end
136
+
137
+ def commit(params, use_profile_api = false)
138
+ post(post_data(params,use_profile_api),use_profile_api)
139
+ end
140
+
141
+ def post(data, use_profile_api)
142
+ response = parse(ssl_post((use_profile_api ? SECURE_PROFILE_URL : ActiveMerchant::Billing::BeanstreamGateway::URL), data))
143
+ if response[:responseCode].eql?("17") # Found matching card
144
+ response[:responseCode] = "1"
145
+ response[:customerCode] = response[:matchedCustomerCode]
146
+ end
147
+ response[:customer_vault_id] = response[:customerCode] if response[:customerCode]
148
+ build_response(success?(response), message_from(response), response,
149
+ :test => test? || response[:authCode] == 'TEST',
150
+ :authorization => authorization_from(response),
151
+ :cvv_result => ActiveMerchant::Billing::BeanstreamGateway::CVD_CODES[response[:cvdId]],
152
+ :avs_result => { :code => (ActiveMerchant::Billing::BeanstreamGateway::AVS_CODES.include? response[:avsId]) ? ActiveMerchant::Billing::BeanstreamGateway::AVS_CODES[response[:avsId]] : response[:avsId] }
153
+ )
154
+ end
155
+
156
+ def message_from(response)
157
+ response[:messageText] || response[:responseMessage]
158
+ end
159
+
160
+ def success?(response)
161
+ response[:responseType] == 'R' || response[:trnApproved] == '1' || response[:responseCode] == '1'
162
+ end
163
+
164
+ def add_source(post, source)
165
+ if source.is_a?(String) or source.is_a?(Integer)
166
+ post[:customerCode] = source
167
+ else
168
+ if source.respond_to?(:type) && source.type.to_s == 'check'
169
+ add_check(post, source)
170
+ else
171
+ add_credit_card(post, source)
172
+ end
173
+ end
174
+ end
175
+
176
+ def post_data(params, use_profile_api)
177
+ params[:requestType] = 'BACKEND'
178
+ if use_profile_api
179
+ params[:merchantId] = @options[:login]
180
+ params[:passCode] = @options[:secure_profile_api_key]
181
+ else
182
+ params[:username] = @options[:user] if @options[:user]
183
+ params[:password] = @options[:password] if @options[:password]
184
+ params[:merchant_id] = @options[:login]
185
+ end
186
+ params[:vbvEnabled] = '0'
187
+ params[:scEnabled] = '0'
188
+
189
+ params.reject { |k, v| v.blank? }.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
190
+ end
191
+ end
192
+ end
193
+ end
@@ -0,0 +1,184 @@
1
+ module Spree
2
+ class Gateway::BraintreeGateway < Gateway
3
+ preference :environment, :string
4
+ preference :merchant_id, :string
5
+ preference :merchant_account_id, :string
6
+ preference :public_key, :string
7
+ preference :private_key, :string
8
+ preference :client_side_encryption_key, :text
9
+
10
+ CARD_TYPE_MAPPING = {
11
+ 'American Express' => 'american_express',
12
+ 'Diners Club' => 'diners_club',
13
+ 'Discover' => 'discover',
14
+ 'JCB' => 'jcb',
15
+ 'Laser' => 'laser',
16
+ 'Maestro' => 'maestro',
17
+ 'MasterCard' => 'master',
18
+ 'Solo' => 'solo',
19
+ 'Switch' => 'switch',
20
+ 'Visa' => 'visa'
21
+ }
22
+
23
+ def provider
24
+ provider_instance = super
25
+ Braintree::Configuration.custom_user_agent = "Spree #{Spree.version}"
26
+ Braintree::Configuration.environment = preferred_environment.to_sym
27
+ Braintree::Configuration.merchant_id = preferred_merchant_id
28
+ Braintree::Configuration.public_key = preferred_public_key
29
+ Braintree::Configuration.private_key = preferred_private_key
30
+
31
+ provider_instance
32
+ end
33
+
34
+ def provider_class
35
+ ActiveMerchant::Billing::BraintreeBlueGateway
36
+ end
37
+
38
+ def authorize(money, creditcard, options = {})
39
+ adjust_options_for_braintree(creditcard, options)
40
+
41
+ if creditcard.gateway_payment_profile_id
42
+ payment_method = creditcard.gateway_payment_profile_id
43
+ options[:payment_method_token] = true
44
+ else
45
+ payment_method = creditcard.gateway_customer_profile_id || creditcard
46
+ end
47
+
48
+ provider.authorize(money, payment_method, options)
49
+ end
50
+
51
+ def capture(amount, authorization_code, ignored_options = {})
52
+ provider.capture(amount, authorization_code)
53
+ end
54
+
55
+ def create_profile(payment)
56
+ if payment.source.gateway_customer_profile_id.nil? && payment.source.number.present?
57
+ response = provider.store(payment.source, options_for_payment(payment))
58
+
59
+ if response.success?
60
+ payment.source.update!(:gateway_customer_profile_id => response.params['customer_vault_id'])
61
+ cc = response.params['braintree_customer'].fetch('credit_cards',[]).first
62
+ update_card_number(payment.source, cc) if cc
63
+ else
64
+ payment.send(:gateway_error, response.message)
65
+ end
66
+ end
67
+ end
68
+
69
+ def update_card_number(source, cc)
70
+ last_4 = cc['last_4']
71
+ source.last_digits = last_4 if last_4
72
+ source.gateway_payment_profile_id = cc['token']
73
+ source.cc_type = CARD_TYPE_MAPPING[cc['card_type']] if cc['card_type']
74
+ source.save!
75
+ end
76
+
77
+ def credit(*args)
78
+ if args.size == 4
79
+ # enables ability to refund instead of credit
80
+ args.slice!(1,1)
81
+ credit_without_payment_profiles(*args)
82
+ elsif args.size == 3
83
+ credit_without_payment_profiles(*args)
84
+ else
85
+ raise ArgumentError, "Expected 3 or 4 arguments, received #{args.size}"
86
+ end
87
+ end
88
+
89
+ # Braintree now disables credits by default, see https://www.braintreepayments.com/docs/ruby/transactions/credit
90
+ def credit_with_payment_profiles(amount, payment, response_code, option)
91
+ provider.credit(amount, payment)
92
+ end
93
+
94
+ def credit_without_payment_profiles(amount, response_code, options)
95
+ provider # braintree provider needs to be called here to properly configure braintree gem.
96
+ transaction = ::Braintree::Transaction.find(response_code)
97
+ if BigDecimal.new(amount.to_s) == (transaction.amount * 100)
98
+ provider.refund(response_code)
99
+ elsif BigDecimal.new(amount.to_s) < (transaction.amount * 100) # support partial refunds
100
+ provider.refund(amount, response_code)
101
+ else
102
+ raise NotImplementedError
103
+ end
104
+ end
105
+
106
+ def payment_profiles_supported?
107
+ true
108
+ end
109
+
110
+ def purchase(money, creditcard, options = {})
111
+ authorize(money, creditcard, options.merge(:submit_for_settlement => true))
112
+ end
113
+
114
+ def void(response_code, *ignored_options)
115
+ provider.void(response_code)
116
+ end
117
+
118
+ def options
119
+ h = super
120
+ # We need to add merchant_account_id only if present when creating BraintreeBlueGateway
121
+ # Remove it since it is always part of the preferences hash.
122
+ if h[:merchant_account_id].blank?
123
+ h.delete(:merchant_account_id)
124
+ end
125
+ h
126
+ end
127
+
128
+ def cancel(response_code)
129
+ provider
130
+ transaction = ::Braintree::Transaction.find(response_code)
131
+ # From: https://www.braintreepayments.com/docs/ruby/transactions/refund
132
+ # "A transaction can be refunded if its status is settled or settling.
133
+ # If the transaction has not yet begun settlement, it should be voided instead of refunded.
134
+ if transaction.status == Braintree::Transaction::Status::SubmittedForSettlement
135
+ provider.void(response_code)
136
+ else
137
+ provider.refund(response_code)
138
+ end
139
+ end
140
+
141
+ protected
142
+
143
+ def adjust_billing_address(creditcard, options)
144
+ if creditcard.gateway_customer_profile_id
145
+ options.delete(:billing_address)
146
+ end
147
+ end
148
+
149
+ def adjust_options_for_braintree(creditcard, options)
150
+ adjust_billing_address(creditcard, options)
151
+ end
152
+
153
+ def options_for_payment(p)
154
+ o = Hash.new
155
+ o[:email] = p.order.email
156
+
157
+ if p.source.gateway_customer_profile_id.present?
158
+ o[:customer] = p.source.gateway_customer_profile_id
159
+ end
160
+
161
+ if p.order.bill_address
162
+ bill_addr = p.order.bill_address
163
+
164
+ o[:first_name] = bill_addr.firstname
165
+ o[:last_name] = bill_addr.lastname
166
+
167
+ o[:billing_address] = {
168
+ address1: bill_addr.address1,
169
+ address2: bill_addr.address2,
170
+ company: bill_addr.company,
171
+ city: bill_addr.city,
172
+ state: bill_addr.state ? bill_addr.state.name : bill_addr.state_name,
173
+ country_code_alpha3: bill_addr.country.iso3,
174
+ zip: bill_addr.zipcode
175
+ }
176
+ end
177
+
178
+ o[:verify_card] = "true"
179
+
180
+ return o
181
+ end
182
+
183
+ end
184
+ end
@@ -0,0 +1,10 @@
1
+ module Spree
2
+ class Gateway::CardSave < Gateway
3
+ preference :login, :string
4
+ preference :password, :string
5
+
6
+ def provider_class
7
+ ActiveMerchant::Billing::CardSaveGateway
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module Spree
2
+ class Gateway::CyberSource < Gateway
3
+ preference :login, :string
4
+ preference :password, :password
5
+
6
+ def provider_class
7
+ ActiveMerchant::Billing::CyberSourceGateway
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module Spree
2
+ class Gateway::DataCash < Gateway
3
+ preference :login, :string
4
+ preference :password, :string
5
+
6
+ def provider_class
7
+ ActiveMerchant::Billing::DataCashGateway
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module Spree
2
+ class Gateway::Epay < Gateway
3
+ preference :login, :string
4
+ preference :password, :string
5
+
6
+ def provider_class
7
+ ActiveMerchant::Billing::EpayGateway
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,18 @@
1
+ module Spree
2
+ class Gateway::Eway < Gateway
3
+ preference :login, :string
4
+
5
+ # Note: EWay supports purchase method only (no authorize method).
6
+ def auto_capture?
7
+ true
8
+ end
9
+
10
+ def provider_class
11
+ ActiveMerchant::Billing::EwayGateway
12
+ end
13
+
14
+ def options
15
+ super().merge(:test => self.preferred_test_mode)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,14 @@
1
+ module Spree
2
+ class Gateway::EwayRapid < Gateway
3
+ preference :login, :string
4
+ preference :password, :string
5
+
6
+ def provider_class
7
+ ActiveMerchant::Billing::EwayRapidGateway
8
+ end
9
+
10
+ def options
11
+ super().merge(:test => self.preferred_test_mode)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ module Spree
2
+ class Gateway::Maxipago < Gateway
3
+ preference :login, :string # ID
4
+ preference :password, :string # KEY
5
+
6
+ def provider_class
7
+ ActiveMerchant::Billing::MaxipagoGateway
8
+ end
9
+
10
+ def auto_capture?
11
+ true
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,11 @@
1
+ module Spree
2
+ class Gateway::Migs < Gateway
3
+ preference :login, :string
4
+ preference :password, :string
5
+ preference :secure_hash, :string
6
+
7
+ def provider_class
8
+ ActiveMerchant::Billing::MigsGateway
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,10 @@
1
+ module Spree
2
+ class Gateway::Moneris < Gateway
3
+ preference :login, :string
4
+ preference :password, :password
5
+
6
+ def provider_class
7
+ ActiveMerchant::Billing::MonerisGateway
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,14 @@
1
+ module Spree
2
+ class Gateway::PayJunction < Gateway
3
+ preference :login, :string
4
+ preference :password, :string
5
+
6
+ def provider_class
7
+ ActiveMerchant::Billing::PayJunctionGateway
8
+ end
9
+
10
+ def options
11
+ super().merge(:test => self.preferred_test_mode)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,12 @@
1
+ module Spree
2
+ class Gateway::PayPalGateway < Gateway
3
+ preference :login, :string
4
+ preference :password, :string
5
+ preference :signature, :string
6
+ preference :currency_code, :string
7
+
8
+ def provider_class
9
+ ActiveMerchant::Billing::PaypalGateway
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,15 @@
1
+ module Spree
2
+ class Gateway::PayflowPro < Gateway
3
+ preference :login, :string
4
+ preference :password, :password
5
+ preference :partner, :string
6
+
7
+ def provider_class
8
+ ActiveMerchant::Billing::PayflowGateway
9
+ end
10
+
11
+ def options
12
+ super().merge(:test => self.preferred_test_mode)
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,12 @@
1
+ module Spree
2
+ class Gateway::Paymill < Gateway
3
+
4
+ preference :public_key, :string
5
+ preference :private_key, :string
6
+ preference :currency, :string, :default => 'GBP'
7
+
8
+ def provider_class
9
+ ActiveMerchant::Billing::PaymillGateway
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,24 @@
1
+ module Spree
2
+ class Gateway::PayuPolskaGateway < Gateway
3
+ preference :client_id, :string
4
+ preference :merchant_pos_id, :string
5
+ preference :client_secret, :password
6
+ preference :notify_url, :string
7
+
8
+ def provider_class
9
+ ActiveMerchant::Billing::PayuPolskaGateway
10
+ end
11
+
12
+ def payment_source_class
13
+ Check
14
+ end
15
+
16
+ def method_type
17
+ 'payu'
18
+ end
19
+
20
+ def auto_capture?
21
+ false
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,60 @@
1
+ module Spree
2
+ class Gateway::PinGateway < Gateway
3
+ preference :api_key, :string
4
+ preference :currency, :string, :default => 'AUD'
5
+
6
+ def provider_class
7
+ ActiveMerchant::Billing::PinGateway
8
+ end
9
+
10
+ def purchase(money, creditcard, options = {})
11
+ super(money, creditcard.try(:gateway_customer_profile_id) || creditcard.try(:gateway_payment_profile_id) || creditcard, options)
12
+ end
13
+
14
+ def create_profile(payment)
15
+ if payment.source.gateway_customer_profile_id.nil?
16
+ response = provider.store(payment.source, options_for_payment(payment))
17
+
18
+ if response.success?
19
+ payment.source.update!(:gateway_customer_profile_id => response.authorization)
20
+
21
+ cc = response.params['response']['card']
22
+ payment.source.update!(:gateway_payment_profile_id => cc['token']) if cc
23
+ else
24
+ payment.send(:gateway_error, response.message)
25
+ end
26
+ end
27
+ end
28
+
29
+ # Pin does not appear to support authorizing transactions yet
30
+ def auto_capture?
31
+ true
32
+ end
33
+
34
+ def payment_profiles_supported?
35
+ true
36
+ end
37
+
38
+ private
39
+
40
+ def options_for_payment(p)
41
+ o = Hash.new
42
+ o[:email] = p.order.email
43
+
44
+ if p.order.bill_address
45
+ bill_addr = p.order.bill_address
46
+
47
+ o[:billing_address] = {
48
+ address1: bill_addr.address1,
49
+ city: bill_addr.city,
50
+ state: bill_addr.state ? bill_addr.state.name : bill_addr.state_name,
51
+ country: bill_addr.country.iso3,
52
+ zip: bill_addr.zipcode
53
+ }
54
+ end
55
+
56
+ return o
57
+ end
58
+
59
+ end
60
+ end
@@ -0,0 +1,9 @@
1
+ module Spree
2
+ class Gateway::Quickpay < Gateway
3
+ preference :api_key, :string
4
+
5
+ def provider_class
6
+ ActiveMerchant::Billing::QuickpayV10Gateway
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ module Spree
2
+ class Gateway::SagePay < Gateway
3
+ preference :login, :string
4
+ preference :password, :string
5
+ preference :account, :string
6
+
7
+ def provider_class
8
+ ActiveMerchant::Billing::SagePayGateway
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,10 @@
1
+ module Spree
2
+ class Gateway::SecurePayAU < Gateway
3
+ preference :login, :string
4
+ preference :password, :string
5
+
6
+ def provider_class
7
+ ActiveMerchant::Billing::SecurePayAuGateway
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,11 @@
1
+ module Spree
2
+ class Gateway::SpreedlyCoreGateway < Gateway
3
+ preference :login, :string
4
+ preference :password, :string
5
+ preference :gateway_token, :string
6
+
7
+ def provider_class
8
+ ActiveMerchant::Billing::SpreedlyCoreGateway
9
+ end
10
+ end
11
+ end