archetype_spree_gateway 3.9.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +21 -0
- data/.rspec +3 -0
- data/.travis.yml +39 -0
- data/Gemfile +9 -0
- data/Guardfile +9 -0
- data/LICENSE.md +26 -0
- data/README.md +105 -0
- data/Rakefile +15 -0
- data/app/models/spree/billing_integration.rb +21 -0
- data/app/models/spree/check.rb +41 -0
- data/app/models/spree/gateway/authorize_net.rb +45 -0
- data/app/models/spree/gateway/authorize_net_cim.rb +213 -0
- data/app/models/spree/gateway/balanced_gateway.rb +64 -0
- data/app/models/spree/gateway/banwire.rb +15 -0
- data/app/models/spree/gateway/beanstream.rb +193 -0
- data/app/models/spree/gateway/braintree_gateway.rb +184 -0
- data/app/models/spree/gateway/card_save.rb +10 -0
- data/app/models/spree/gateway/cyber_source.rb +10 -0
- data/app/models/spree/gateway/data_cash.rb +10 -0
- data/app/models/spree/gateway/epay.rb +10 -0
- data/app/models/spree/gateway/eway.rb +18 -0
- data/app/models/spree/gateway/eway_rapid.rb +14 -0
- data/app/models/spree/gateway/maxipago.rb +14 -0
- data/app/models/spree/gateway/migs.rb +11 -0
- data/app/models/spree/gateway/moneris.rb +10 -0
- data/app/models/spree/gateway/pay_junction.rb +14 -0
- data/app/models/spree/gateway/pay_pal_gateway.rb +12 -0
- data/app/models/spree/gateway/payflow_pro.rb +15 -0
- data/app/models/spree/gateway/paymill.rb +12 -0
- data/app/models/spree/gateway/payu_polska_gateway.rb +24 -0
- data/app/models/spree/gateway/pin_gateway.rb +60 -0
- data/app/models/spree/gateway/quickpay.rb +9 -0
- data/app/models/spree/gateway/sage_pay.rb +11 -0
- data/app/models/spree/gateway/secure_pay_au.rb +10 -0
- data/app/models/spree/gateway/spreedly_core_gateway.rb +11 -0
- data/app/models/spree/gateway/stripe_ach_gateway.rb +60 -0
- data/app/models/spree/gateway/stripe_apple_pay_gateway.rb +10 -0
- data/app/models/spree/gateway/stripe_elements_gateway.rb +61 -0
- data/app/models/spree/gateway/stripe_gateway.rb +151 -0
- data/app/models/spree/gateway/usa_epay_transaction.rb +9 -0
- data/app/models/spree/gateway/worldpay.rb +91 -0
- data/app/models/spree/payu_polska.rb +41 -0
- data/app/models/spree_gateway/apple_pay_order_decorator.rb +20 -0
- data/app/models/spree_gateway/apple_pay_payment_decorator.rb +9 -0
- data/app/models/spree_gateway/credit_card_decorator.rb +10 -0
- data/app/models/spree_gateway/order_decorator.rb +28 -0
- data/app/models/spree_gateway/payment_decorator.rb +36 -0
- data/app/views/spree/checkout/_payment_confirm.html.erb +39 -0
- data/app/views/spree/checkout/_payu.html +12 -0
- data/config/initializers/inflections.rb +3 -0
- data/config/initializers/spree_permitted_attributes.rb +5 -0
- data/config/locales/bg.yml +4 -0
- data/config/locales/de.yml +4 -0
- data/config/locales/en.yml +47 -0
- data/config/locales/sv.yml +4 -0
- data/config/routes.rb +19 -0
- data/db/migrate/20200317135551_add_spree_check_payment_source.rb +22 -0
- data/db/migrate/20200422114908_add_intent_key_to_payment.rb +5 -0
- data/lib/active_merchant/billing/stripe_gateway_decorator.rb +33 -0
- data/lib/controllers/spree/api/v2/storefront/intents_controller.rb +45 -0
- data/lib/controllers/spree/apple_pay_domain_verification_controller.rb +11 -0
- data/lib/generators/spree_gateway/install/install_generator.rb +19 -0
- data/lib/spree_frontend/controllers/spree/checkout_controller_decorator.rb +19 -0
- data/lib/spree_gateway/engine.rb +80 -0
- data/lib/spree_gateway/version.rb +5 -0
- data/lib/spree_gateway.rb +4 -0
- data/lib/views/backend/spree/admin/log_entries/_braintree.html.erb +31 -0
- data/lib/views/backend/spree/admin/log_entries/_stripe.html.erb +28 -0
- data/lib/views/backend/spree/admin/payments/source_forms/_quickcheckout.html.erb +8 -0
- data/lib/views/backend/spree/admin/payments/source_forms/_stripe.html.erb +79 -0
- data/lib/views/backend/spree/admin/payments/source_forms/_stripe_ach.html.erb +86 -0
- data/lib/views/backend/spree/admin/payments/source_forms/_stripe_apple_pay.html.erb +0 -0
- data/lib/views/backend/spree/admin/payments/source_forms/_stripe_elements.html.erb +79 -0
- data/lib/views/backend/spree/admin/payments/source_views/_stripe.html.erb +1 -0
- data/lib/views/backend/spree/admin/payments/source_views/_stripe_ach.html.erb +21 -0
- data/lib/views/backend/spree/admin/payments/source_views/_stripe_apple_pay.html.erb +1 -0
- data/lib/views/backend/spree/admin/payments/source_views/_stripe_elements.html.erb +1 -0
- data/lib/views/frontend/spree/checkout/payment/_stripe.html.erb +86 -0
- data/lib/views/frontend/spree/checkout/payment/_stripe_ach.html.erb +81 -0
- data/lib/views/frontend/spree/checkout/payment/_stripe_ach_verify.html.erb +16 -0
- data/lib/views/frontend/spree/checkout/payment/_stripe_additional_info.html.erb +16 -0
- data/lib/views/frontend/spree/checkout/payment/_stripe_apple_pay.html.erb +109 -0
- data/lib/views/frontend/spree/checkout/payment/_stripe_elements.html.erb +110 -0
- data/script/rails +7 -0
- data/spec/factories/check_factory.rb +10 -0
- data/spec/features/admin/stripe_elements_payment_spec.rb +100 -0
- data/spec/features/stripe_checkout_spec.rb +130 -0
- data/spec/features/stripe_elements_3ds_checkout_spec.rb +225 -0
- data/spec/models/gateway/authorize_net_cim_spec.rb +29 -0
- data/spec/models/gateway/authorize_net_spec.rb +23 -0
- data/spec/models/gateway/balanced_gateway_spec.rb +17 -0
- data/spec/models/gateway/banwire_spec.rb +11 -0
- data/spec/models/gateway/beanstream_spec.rb +17 -0
- data/spec/models/gateway/braintree_gateway_spec.rb +420 -0
- data/spec/models/gateway/card_save_spec.rb +11 -0
- data/spec/models/gateway/cyber_source_spec.rb +11 -0
- data/spec/models/gateway/data_cash_spec.rb +11 -0
- data/spec/models/gateway/epay_spec.rb +11 -0
- data/spec/models/gateway/eway_rapid_spec.rb +23 -0
- data/spec/models/gateway/eway_spec.rb +29 -0
- data/spec/models/gateway/maxipago_spec.rb +17 -0
- data/spec/models/gateway/moneris_spec.rb +11 -0
- data/spec/models/gateway/pay_junction_spec.rb +23 -0
- data/spec/models/gateway/pay_pal_spec.rb +11 -0
- data/spec/models/gateway/payflow_pro_spec.rb +23 -0
- data/spec/models/gateway/paymill_spec.rb +11 -0
- data/spec/models/gateway/pin_gateway_spec.rb +54 -0
- data/spec/models/gateway/quickpay_spec.rb +11 -0
- data/spec/models/gateway/sage_pay_spec.rb +11 -0
- data/spec/models/gateway/secure_pay_au_spec.rb +11 -0
- data/spec/models/gateway/stripe_ach_gateway_spec.rb +186 -0
- data/spec/models/gateway/stripe_gateway_spec.rb +199 -0
- data/spec/models/gateway/usa_epay_transaction_spec.rb +49 -0
- data/spec/models/gateway/worldpay_spec.rb +11 -0
- data/spec/models/spree/order_spec.rb +79 -0
- data/spec/requests/apple_pay_domain_verification.rb +45 -0
- data/spec/requests/spree/api/v2/storefront/intents_controller_spec.rb +198 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/support/order_walktrough.rb +73 -0
- data/spec/support/wait_for_stripe.rb +27 -0
- data/spec/support/within_stripe_3ds_popup.rb +10 -0
- data/spree_gateway.gemspec +37 -0
- metadata +277 -0
@@ -0,0 +1,225 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe 'Stripe Elements 3ds checkout', type: :feature, js: true do
|
6
|
+
let!(:product) { create(:product, name: 'RoR Mug') }
|
7
|
+
let!(:stripe_payment_method) do
|
8
|
+
Spree::Gateway::StripeElementsGateway.create!(
|
9
|
+
name: 'Stripe',
|
10
|
+
preferred_secret_key: 'sk_test_VCZnDv3GLU15TRvn8i2EsaAN',
|
11
|
+
preferred_publishable_key: 'pk_test_Cuf0PNtiAkkMpTVC2gwYDMIg',
|
12
|
+
preferred_intents: preferred_intents,
|
13
|
+
stores: [::Spree::Store.default]
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
before do
|
18
|
+
user = create(:user)
|
19
|
+
order = OrderWalkthrough.up_to(:confirm)
|
20
|
+
expect(order).to receive(:confirmation_required?).and_return(true).at_least(:once)
|
21
|
+
|
22
|
+
order.reload
|
23
|
+
order.user = user
|
24
|
+
payment = order.payments.first
|
25
|
+
payment.source = create(:credit_card, number: card_number)
|
26
|
+
payment.save!
|
27
|
+
|
28
|
+
allow_any_instance_of(Spree::CheckoutController).to receive_messages(current_order: order)
|
29
|
+
allow_any_instance_of(Spree::CheckoutController).to receive_messages(try_spree_current_user: user)
|
30
|
+
allow_any_instance_of(Spree::CheckoutController).to receive_messages(skip_state_validation?: true)
|
31
|
+
allow_any_instance_of(Spree::OrdersController).to receive_messages(try_spree_current_user: user)
|
32
|
+
|
33
|
+
add_to_cart(product)
|
34
|
+
|
35
|
+
if Spree.version.to_f >= 3.7 and Spree.version.to_f < 4.1
|
36
|
+
find("#checkout-link").click
|
37
|
+
else
|
38
|
+
click_link 'checkout'
|
39
|
+
click_button 'Place Order'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe 'when intents are disabled' do
|
44
|
+
let(:preferred_intents) { false }
|
45
|
+
|
46
|
+
context 'and credit card does not require 3ds authentication' do
|
47
|
+
let(:card_number) { '4242424242424242' }
|
48
|
+
|
49
|
+
if Spree.version.to_f >= 3.7 and Spree.version.to_f < 4.1
|
50
|
+
it 'should place order without 3ds authentication', driver: :selenium_chrome_headless do
|
51
|
+
click_button 'Save and Continue'
|
52
|
+
click_button 'Save and Continue'
|
53
|
+
|
54
|
+
within_frame 0 do
|
55
|
+
fill_in 'cardnumber', with: card_number
|
56
|
+
fill_in 'exp-date', with: "01 / #{Time.current.strftime('%y').to_i + 3}"
|
57
|
+
fill_in 'cvc', with: "222"
|
58
|
+
end
|
59
|
+
|
60
|
+
click_button 'Save and Continue'
|
61
|
+
click_button 'Place Order'
|
62
|
+
|
63
|
+
expect(page).to have_content('Your order has been processed successfully')
|
64
|
+
order = Spree::Order.complete.last
|
65
|
+
expect(page.current_url).to include("/orders/#{order.number}")
|
66
|
+
expect(page).to have_content(order.number)
|
67
|
+
end
|
68
|
+
else
|
69
|
+
it 'should place order without 3ds authentication' do
|
70
|
+
expect(page).to have_content('Order placed successfully')
|
71
|
+
order = Spree::Order.complete.last
|
72
|
+
expect(page.current_url).to include("/orders/#{order.number}")
|
73
|
+
expect(page).to have_content(order.number)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
context 'and credit card does require 3ds authentication' do
|
79
|
+
let(:card_number) { '4000000000003220' }
|
80
|
+
|
81
|
+
if Spree.version.to_f >= 3.7 and Spree.version.to_f < 4.1
|
82
|
+
it 'should not place the order', driver: :selenium_chrome_headless do
|
83
|
+
click_button 'Save and Continue'
|
84
|
+
click_button 'Save and Continue'
|
85
|
+
|
86
|
+
within_frame 0 do
|
87
|
+
fill_in 'cardnumber', with: card_number
|
88
|
+
fill_in 'exp-date', with: "01 / #{Time.current.strftime('%y').to_i + 3}"
|
89
|
+
fill_in 'cvc', with: "222"
|
90
|
+
end
|
91
|
+
|
92
|
+
click_button 'Save and Continue'
|
93
|
+
click_button 'Place Order'
|
94
|
+
|
95
|
+
expect(page).to have_content('Your card was declined. This transaction requires authentication.')
|
96
|
+
expect(Spree::Order.complete.last).to be_nil
|
97
|
+
end
|
98
|
+
|
99
|
+
else
|
100
|
+
it 'should not place the order' do
|
101
|
+
expect(page).to have_content('Your card was declined. This transaction requires authentication.')
|
102
|
+
expect(Spree::Order.complete.last).to be_nil
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
describe 'when intents are enabled' do
|
109
|
+
let(:preferred_intents) { true }
|
110
|
+
|
111
|
+
context 'and credit card does not require 3ds authentication' do
|
112
|
+
let(:card_number) { '4242424242424242' }
|
113
|
+
|
114
|
+
if Spree.version.to_f >= 3.7 and Spree.version.to_f < 4.1
|
115
|
+
it 'should successfully place order without 3ds authentication', driver: :selenium_chrome_headless do
|
116
|
+
click_button 'Save and Continue'
|
117
|
+
click_button 'Save and Continue'
|
118
|
+
|
119
|
+
within_frame 0 do
|
120
|
+
fill_in 'cardnumber', with: card_number
|
121
|
+
fill_in 'exp-date', with: "01 / #{Time.current.strftime('%y').to_i + 3}"
|
122
|
+
fill_in 'cvc', with: "222"
|
123
|
+
end
|
124
|
+
|
125
|
+
click_button 'Save and Continue'
|
126
|
+
click_button 'Place Order'
|
127
|
+
|
128
|
+
expect(page).to have_content('Your order has been processed successfully')
|
129
|
+
order = Spree::Order.complete.last
|
130
|
+
expect(page.current_url).to include("/orders/#{order.number}")
|
131
|
+
expect(page).to have_content(order.number)
|
132
|
+
end
|
133
|
+
else
|
134
|
+
it 'should successfully place order without 3ds authentication' do
|
135
|
+
expect(page).to have_content('Order placed successfully')
|
136
|
+
order = Spree::Order.complete.last
|
137
|
+
expect(page.current_url).to include("/orders/#{order.number}")
|
138
|
+
expect(page).to have_content(order.number)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
context 'when credit card does require 3ds authentication' do
|
144
|
+
let(:card_number) { '4000000000003220' }
|
145
|
+
|
146
|
+
context 'and authentication is successful' do
|
147
|
+
if Spree.version.to_f >= 3.7 and Spree.version.to_f < 4.1
|
148
|
+
it 'should place order after 3ds authentication', driver: :selenium_chrome_headless do
|
149
|
+
click_button 'Save and Continue'
|
150
|
+
click_button 'Save and Continue'
|
151
|
+
|
152
|
+
within_frame 0 do
|
153
|
+
fill_in 'cardnumber', with: card_number
|
154
|
+
fill_in 'exp-date', with: "01 / #{Time.current.strftime('%y').to_i + 3}"
|
155
|
+
fill_in 'cvc', with: "222"
|
156
|
+
end
|
157
|
+
|
158
|
+
click_button 'Save and Continue'
|
159
|
+
click_button 'Place Order'
|
160
|
+
|
161
|
+
within_stripe_3ds_popup do
|
162
|
+
click_button('Complete')
|
163
|
+
end
|
164
|
+
|
165
|
+
expect(page).to have_content('Your order has been processed successfully')
|
166
|
+
order = Spree::Order.complete.last
|
167
|
+
expect(page.current_url).to include("/orders/#{order.number}")
|
168
|
+
expect(page).to have_content(order.number)
|
169
|
+
end
|
170
|
+
|
171
|
+
else
|
172
|
+
it 'should place order after 3ds authentication' do
|
173
|
+
within_stripe_3ds_popup do
|
174
|
+
click_button('Complete')
|
175
|
+
end
|
176
|
+
|
177
|
+
expect(page).to have_content('Order placed successfully')
|
178
|
+
order = Spree::Order.complete.last
|
179
|
+
expect(page.current_url).to include("/orders/#{order.number}")
|
180
|
+
expect(page).to have_content(order.number)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
context 'and authentication is unsuccessful' do
|
186
|
+
|
187
|
+
if Spree.version.to_f >= 3.7 and Spree.version.to_f < 4.1
|
188
|
+
it 'should not place order after 3ds authentication', driver: :selenium_chrome_headless do
|
189
|
+
click_button 'Save and Continue'
|
190
|
+
click_button 'Save and Continue'
|
191
|
+
|
192
|
+
within_frame 0 do
|
193
|
+
fill_in 'cardnumber', with: card_number
|
194
|
+
fill_in 'exp-date', with: "01 / #{Time.current.strftime('%y').to_i + 3}"
|
195
|
+
fill_in 'cvc', with: "222"
|
196
|
+
end
|
197
|
+
|
198
|
+
click_button 'Save and Continue'
|
199
|
+
click_button 'Place Order'
|
200
|
+
|
201
|
+
within_stripe_3ds_popup do
|
202
|
+
click_button('Fail')
|
203
|
+
end
|
204
|
+
|
205
|
+
expect(page).to_not have_content('Order placed successfully')
|
206
|
+
expect(page).to have_content('We are unable to authenticate your payment method.')
|
207
|
+
expect(page).to have_content('Please choose a different payment method and try again.')
|
208
|
+
expect(Spree::Order.complete.last).to be_nil
|
209
|
+
end
|
210
|
+
else
|
211
|
+
it 'should not place order after 3ds authentication' do
|
212
|
+
within_stripe_3ds_popup do
|
213
|
+
click_button('Fail')
|
214
|
+
end
|
215
|
+
|
216
|
+
expect(page).to_not have_content('Order placed successfully')
|
217
|
+
expect(page).to have_content('We are unable to authenticate your payment method.')
|
218
|
+
expect(page).to have_content('Please choose a different payment method and try again.')
|
219
|
+
expect(Spree::Order.complete.last).to be_nil
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
225
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Spree::Gateway::AuthorizeNetCim do
|
4
|
+
let (:gateway) { described_class.new }
|
5
|
+
|
6
|
+
context '.provider_class' do
|
7
|
+
it 'is a AuthorizeNetCim gateway' do
|
8
|
+
expect(gateway.provider_class).to eq ::Spree::Gateway::AuthorizeNetCim
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
context '.payment_profiles_supported?' do
|
13
|
+
it 'return true' do
|
14
|
+
expect(subject.payment_profiles_supported?).to be true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe 'options' do
|
19
|
+
it 'include :test => true when test server is "test"' do
|
20
|
+
gateway.preferred_server = "test"
|
21
|
+
expect(gateway.options[:test]).to be true
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'does not include :test when test server is "live"' do
|
25
|
+
gateway.preferred_server = "live"
|
26
|
+
expect(gateway.options[:test]).to be_nil
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Spree::Gateway::AuthorizeNet do
|
4
|
+
let (:gateway) { described_class.create!(name: 'Authorize.net', stores: [::Spree::Store.default]) }
|
5
|
+
|
6
|
+
context '.provider_class' do
|
7
|
+
it 'is a AuthorizeNet gateway' do
|
8
|
+
expect(gateway.provider_class).to eq ::ActiveMerchant::Billing::AuthorizeNetGateway
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'options' do
|
13
|
+
it 'include :test => true when server is "test"' do
|
14
|
+
gateway.preferred_server = "test"
|
15
|
+
expect(gateway.options[:test]).to be true
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'does not include :test when server is "live"' do
|
19
|
+
gateway.preferred_server = "live"
|
20
|
+
expect(gateway.options[:test]).to be false
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Spree::Gateway::BalancedGateway do
|
4
|
+
let(:gateway) { described_class.create!(name: 'Balanced', stores: [::Spree::Store.default]) }
|
5
|
+
|
6
|
+
context '.provider_class' do
|
7
|
+
it 'is a Balanced gateway' do
|
8
|
+
expect(gateway.provider_class).to eq ::ActiveMerchant::Billing::BalancedGateway
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
context '.payment_profiles_supported?' do
|
13
|
+
it 'return true' do
|
14
|
+
expect(gateway.payment_profiles_supported?).to be true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Spree::Gateway::Banwire do
|
4
|
+
let(:gateway) { described_class.create!(name: 'Banwire', stores: [::Spree::Store.default]) }
|
5
|
+
|
6
|
+
context '.provider_class' do
|
7
|
+
it 'is a Banwire gateway' do
|
8
|
+
expect(gateway.provider_class).to eq ::ActiveMerchant::Billing::BanwireGateway
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Spree::Gateway::Beanstream do
|
4
|
+
let(:gateway) { described_class.create!(name: 'Beanstream', stores: [::Spree::Store.default]) }
|
5
|
+
|
6
|
+
context '.provider_class' do
|
7
|
+
it 'is a Beanstream gateway' do
|
8
|
+
expect(gateway.provider_class).to eq ::ActiveMerchant::Billing::BeanstreamGateway
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
context '.payment_profiles_supported?' do
|
13
|
+
it 'return true' do
|
14
|
+
expect(gateway.payment_profiles_supported?).to be true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|