spree_gateway 3.9.2 → 3.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +10 -4
- data/Appraisals +5 -4
- data/app/models/spree/credit_card_decorator.rb +10 -0
- data/app/models/spree/gateway/stripe_ach_gateway.rb +1 -1
- data/app/models/spree/payment_decorator.rb +3 -1
- data/app/views/spree/checkout/_payment_confirm.html.erb +7 -2
- data/gemfiles/{spree_4_2.gemfile → spree_3_7.gemfile} +2 -1
- data/lib/spree_gateway.rb +0 -1
- data/lib/spree_gateway/version.rb +1 -1
- data/spec/features/admin/stripe_elements_payment_spec.rb +19 -29
- data/spec/features/stripe_checkout_spec.rb +28 -20
- data/spec/features/stripe_elements_3ds_checkout_spec.rb +152 -34
- data/spec/support/order_walktrough.rb +73 -0
- data/spree_gateway.gemspec +0 -1
- metadata +9 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82e672befb08ae277659eec1f7686002af0b6f66b1f8ecb467649ab29667aee2
|
4
|
+
data.tar.gz: 47d5a54c20d7987569af842d50f471e6f3eea69647f6807865191c55e97f61cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5efb8b8ce887c92a222bf0b4c4b53b0ea16ee45f6efff3ad2908acdc5e3383139b778362be57ed858d15a0497df4d6aa37fa2c8f56ddee81f334945bcb67fe9f
|
7
|
+
data.tar.gz: fb61b3afbfc998e819bd11cf5d1f53c782e0e486c5b0fea6c43710fba74664398384badff68298a593b715185da3eaa68727e18b3d575dc5f14511d232d7f437
|
data/.travis.yml
CHANGED
@@ -15,20 +15,26 @@ services:
|
|
15
15
|
language: ruby
|
16
16
|
|
17
17
|
rvm:
|
18
|
-
- 2.
|
18
|
+
- 2.7
|
19
|
+
- 3.0
|
19
20
|
|
20
21
|
env:
|
21
22
|
- DB=mysql
|
22
23
|
- DB=postgres
|
23
24
|
|
24
25
|
gemfile:
|
25
|
-
|
26
|
-
- gemfiles/
|
26
|
+
- gemfiles/spree_3_7.gemfile
|
27
|
+
- gemfiles/spree_4_1.gemfile
|
27
28
|
- gemfiles/spree_master.gemfile
|
28
29
|
|
29
30
|
jobs:
|
30
31
|
allow_failures:
|
31
|
-
|
32
|
+
- gemfile: gemfiles/spree_master.gemfile
|
33
|
+
exclude:
|
34
|
+
- rvm: 3.0
|
35
|
+
gemfile: gemfiles/spree_4_1.gemfile
|
36
|
+
- rvm: 3.0
|
37
|
+
gemfile: gemfiles/spree_3_7.gemfile
|
32
38
|
|
33
39
|
before_install:
|
34
40
|
- mysql -u root -e "GRANT ALL ON *.* TO 'travis'@'%';"
|
data/Appraisals
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
-
appraise 'spree-
|
2
|
-
gem 'spree', '~>
|
1
|
+
appraise 'spree-3-7' do
|
2
|
+
gem 'spree', '~> 3.7.0'
|
3
3
|
gem 'rails-controller-testing'
|
4
|
+
gem 'sass-rails'
|
4
5
|
end
|
5
6
|
|
6
|
-
appraise 'spree-4-
|
7
|
-
gem 'spree', '~> 4.
|
7
|
+
appraise 'spree-4-1' do
|
8
|
+
gem 'spree', '~> 4.1.0'
|
8
9
|
gem 'rails-controller-testing'
|
9
10
|
end
|
10
11
|
|
@@ -1,7 +1,9 @@
|
|
1
1
|
module Spree
|
2
2
|
module PaymentDecorator
|
3
3
|
def handle_response(response, success_state, failure_state)
|
4
|
-
|
4
|
+
if response.success? && response.respond_to?(:params)
|
5
|
+
self.intent_client_key = response.params['client_secret'] if response.params['client_secret']
|
6
|
+
end
|
5
7
|
super
|
6
8
|
end
|
7
9
|
|
@@ -9,12 +9,17 @@
|
|
9
9
|
|
10
10
|
function confirmCardPaymentResponseHandler(response) {
|
11
11
|
$.post("/api/v2/storefront/intents/handle_response", { response: response, order_token: "<%= @order.token %>" }).done(function (result) {
|
12
|
-
|
12
|
+
// conditional needs for spree 3.7
|
13
|
+
if(form.elements["commit"]) {
|
14
|
+
form.elements["commit"].disabled = false;
|
15
|
+
}
|
13
16
|
$('#successBox').html(result.message);
|
14
17
|
$('#successBox').show();
|
15
18
|
form.submit();
|
16
19
|
}).fail(function(result) {
|
17
|
-
|
20
|
+
if(form.elements["commit"]) {
|
21
|
+
form.elements["commit"].disabled = false;
|
22
|
+
}
|
18
23
|
$('#errorBox').html(result.responseJSON.error);
|
19
24
|
$('#errorBox').show();
|
20
25
|
});
|
data/lib/spree_gateway.rb
CHANGED
@@ -1,53 +1,43 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe 'Admin Panel Stripe elements payment', type: :feature
|
3
|
+
describe 'Admin Panel Stripe elements payment', type: :feature do
|
4
4
|
stub_authorization!
|
5
5
|
|
6
|
-
let!(:country)
|
7
|
-
let!(:state)
|
6
|
+
let!(:country) { create(:country, states_required: true) }
|
7
|
+
let!(:state) { create(:state, country: country) }
|
8
8
|
let!(:shipping_method) { create(:shipping_method) }
|
9
|
-
let!(:stock_location)
|
10
|
-
let!(:mug)
|
11
|
-
let!(:zone)
|
9
|
+
let!(:stock_location) { create(:stock_location) }
|
10
|
+
let!(:mug) { create(:product, name: 'RoR Mug') }
|
11
|
+
let!(:zone) { create(:zone) }
|
12
12
|
let!(:stripe_elements_payment_method) do
|
13
13
|
Spree::Gateway::StripeElementsGateway.create!(
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
name: 'Stripe Element',
|
15
|
+
preferred_secret_key: 'sk_test_VCZnDv3GLU15TRvn8i2EsaAN',
|
16
|
+
preferred_publishable_key: 'pk_test_Cuf0PNtiAkkMpTVC2gwYDMIg'
|
17
17
|
)
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
let!(:order) { OrderWalkthrough.up_to(:payment) }
|
21
21
|
before { visit spree.new_admin_order_payment_path(order.number) }
|
22
22
|
|
23
23
|
it 'can process a valid payment' do
|
24
24
|
fill_in_stripe_payment
|
25
25
|
wait_for { !page.has_current_path?(spree.admin_order_payments_path(order.number)) }
|
26
|
-
|
26
|
+
|
27
27
|
expect(page.body).to have_content('Payment has been successfully created!')
|
28
28
|
expect(page).to have_current_path spree.admin_order_payments_path(order.number)
|
29
29
|
end
|
30
|
-
|
31
|
-
if Spree.version.to_f >= 4.1
|
32
|
-
it 'shows an error with an invalid card name' do
|
33
|
-
fill_in_stripe_payment(true)
|
34
30
|
|
35
|
-
|
36
|
-
|
37
|
-
end
|
38
|
-
else
|
39
|
-
it 'can proces valid payment with invalid card name' do
|
40
|
-
fill_in_stripe_payment(true)
|
41
|
-
wait_for { !page.has_current_path?(spree.admin_order_payments_path(order.number)) }
|
31
|
+
it 'shows an error with an invalid card name' do
|
32
|
+
fill_in_stripe_payment(true)
|
42
33
|
|
43
|
-
|
44
|
-
|
45
|
-
end
|
34
|
+
expect(page).to have_content("Credit card Name can't be blank")
|
35
|
+
expect(page).to have_current_path spree.admin_order_payments_path(order.number)
|
46
36
|
end
|
47
37
|
|
48
38
|
it 'shows an error with an invalid card number' do
|
49
39
|
fill_in_stripe_payment(false, true)
|
50
|
-
|
40
|
+
|
51
41
|
expect(page).to have_content('The card number is not a valid credit card number.')
|
52
42
|
expect(page).to have_current_path spree.new_admin_order_payment_path(order.number)
|
53
43
|
end
|
@@ -62,7 +52,7 @@ describe 'Admin Panel Stripe elements payment', type: :feature, :js => true do
|
|
62
52
|
it 'shows an error with an invalid card expiration' do
|
63
53
|
fill_in_stripe_payment(false, false, false, true)
|
64
54
|
|
65
|
-
if Spree.version.to_f >= 4.1
|
55
|
+
if Spree.version.to_f >= 4.1 || Spree.version.to_f >= 3.7
|
66
56
|
expect(page).to have_content('Credit card Month is not a number')
|
67
57
|
expect(page).to have_content('Credit card Year is not a number')
|
68
58
|
expect(page).to have_current_path spree.admin_order_payments_path(order.number)
|
@@ -83,7 +73,7 @@ describe 'Admin Panel Stripe elements payment', type: :feature, :js => true do
|
|
83
73
|
|
84
74
|
def fill_in_card_number(invalid_number)
|
85
75
|
number = invalid_number ? '123' : '4242 4242 4242 4242'
|
86
|
-
fill_in_field('Card Number *',
|
76
|
+
fill_in_field('Card Number *', "#card_number#{stripe_elements_payment_method.id}", number)
|
87
77
|
end
|
88
78
|
|
89
79
|
def fill_in_card_expiration(invalid_expiration)
|
@@ -91,7 +81,7 @@ describe 'Admin Panel Stripe elements payment', type: :feature, :js => true do
|
|
91
81
|
invalid_expiry = Spree.version.to_f >= 4.2 ? '01/' : '01 / '
|
92
82
|
|
93
83
|
card_expiry = invalid_expiration ? invalid_expiry : valid_expiry
|
94
|
-
fill_in_field('Expiration *',
|
84
|
+
fill_in_field('Expiration *', "#card_expiry#{stripe_elements_payment_method.id}", card_expiry)
|
95
85
|
end
|
96
86
|
|
97
87
|
def fill_in_cvc(invalid_code)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe "Stripe checkout", type: :feature do
|
3
|
+
describe "Stripe checkout", type: :feature, js: true do
|
4
4
|
let!(:country) { create(:country, :states_required => true) }
|
5
5
|
let!(:state) { create(:state, :country => country) }
|
6
6
|
let!(:shipping_method) { create(:shipping_method) }
|
@@ -42,7 +42,7 @@ describe "Stripe checkout", type: :feature do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
# This will pass the CC data to the server and the StripeGateway class handles it
|
45
|
-
it "can process a valid payment (without JS)" do
|
45
|
+
it "can process a valid payment (without JS)", js: false do
|
46
46
|
fill_in 'card_number', with: '4242 4242 4242 4242'
|
47
47
|
fill_in 'card_code', with: '123'
|
48
48
|
fill_in 'card_expiry', with: "01 / #{Time.current.year + 1}"
|
@@ -56,12 +56,10 @@ describe "Stripe checkout", type: :feature do
|
|
56
56
|
|
57
57
|
# This will fetch a token from Stripe.com and then pass that to the webserver.
|
58
58
|
# The server then processes the payment using that token.
|
59
|
-
it "can process a valid payment (with JS)"
|
60
|
-
|
61
|
-
|
62
|
-
page.execute_script("$('.cardNumber').trigger('change')")
|
59
|
+
it "can process a valid payment (with JS)" do
|
60
|
+
fill_in_with_force('card_number', with: "4242424242424242")
|
61
|
+
fill_in_with_force('card_expiry', with: "01 / #{Time.current.year + 1}")
|
63
62
|
fill_in 'card_code', with: '123'
|
64
|
-
fill_in 'card_expiry', with: "01 / #{Time.current.year + 1}"
|
65
63
|
click_button "Save and Continue"
|
66
64
|
wait_for_stripe # Wait for Stripe API to return + form to submit
|
67
65
|
expect(page).to have_css('#checkout_form_confirm')
|
@@ -72,18 +70,23 @@ describe "Stripe checkout", type: :feature do
|
|
72
70
|
expect(page).to have_content(order.number)
|
73
71
|
end
|
74
72
|
|
75
|
-
it "shows an error with an invalid credit card number"
|
73
|
+
it "shows an error with an invalid credit card number" do
|
76
74
|
# Card number is NOT valid. Fails Luhn checksum
|
77
75
|
fill_in 'card_number', with: '4242 4242 4242 4249'
|
78
76
|
click_button "Save and Continue"
|
79
77
|
wait_for_stripe
|
80
|
-
|
81
|
-
|
78
|
+
if Spree.version.to_f >= 3.7 and Spree.version.to_f <= 4.1
|
79
|
+
expect(page).to have_content("The card number is not a valid credit card number")
|
80
|
+
end
|
81
|
+
if Spree.version.to_f >= 4.2
|
82
|
+
expect(page).to have_content("Your card number is incorrect")
|
83
|
+
expect(page).to have_css('.has-error #card_number.error')
|
84
|
+
end
|
82
85
|
end
|
83
86
|
|
84
|
-
it "shows an error with invalid security fields"
|
85
|
-
|
86
|
-
|
87
|
+
it "shows an error with invalid security fields" do
|
88
|
+
fill_in_with_force('card_number', with: "4242424242424242")
|
89
|
+
fill_in_with_force('card_expiry', with: "01 / #{Time.current.year + 1}")
|
87
90
|
fill_in 'card_code', with: '99'
|
88
91
|
click_button "Save and Continue"
|
89
92
|
wait_for_stripe
|
@@ -93,10 +96,10 @@ describe "Stripe checkout", type: :feature do
|
|
93
96
|
|
94
97
|
# this scenario will not occur on Spree 4.2 due to swapping jquery.payment to cleave
|
95
98
|
# see https://github.com/spree/spree/pull/10363
|
96
|
-
it "shows an error with invalid expiry month field"
|
97
|
-
skip if Spree.version.to_f >= 4.2
|
98
|
-
|
99
|
-
|
99
|
+
it "shows an error with invalid expiry month field" do
|
100
|
+
skip if Spree.version.to_f >= 4.2
|
101
|
+
fill_in_with_force('card_number', with: "4242424242424242")
|
102
|
+
fill_in_with_force('card_expiry', with: "00 / #{Time.current.year + 1}")
|
100
103
|
fill_in 'card_code', with: '123'
|
101
104
|
click_button "Save and Continue"
|
102
105
|
wait_for_stripe
|
@@ -104,9 +107,9 @@ describe "Stripe checkout", type: :feature do
|
|
104
107
|
expect(page).to have_css('.has-error #card_expiry.error')
|
105
108
|
end
|
106
109
|
|
107
|
-
it "shows an error with invalid expiry year field"
|
108
|
-
|
109
|
-
|
110
|
+
it "shows an error with invalid expiry year field" do
|
111
|
+
fill_in_with_force('card_number', with: "4242424242424242")
|
112
|
+
fill_in_with_force('card_expiry', with: "12 / ")
|
110
113
|
fill_in 'card_code', with: '123'
|
111
114
|
click_button "Save and Continue"
|
112
115
|
wait_for_stripe
|
@@ -114,3 +117,8 @@ describe "Stripe checkout", type: :feature do
|
|
114
117
|
expect(page).to have_css('.has-error #card_expiry.error')
|
115
118
|
end
|
116
119
|
end
|
120
|
+
|
121
|
+
def fill_in_with_force(locator, with:)
|
122
|
+
field_id = find_field(locator)[:id]
|
123
|
+
page.execute_script("document.getElementById('#{field_id}').value = '#{with}';")
|
124
|
+
end
|
@@ -6,10 +6,10 @@ describe 'Stripe Elements 3ds checkout', type: :feature, js: true do
|
|
6
6
|
let!(:product) { create(:product, name: 'RoR Mug') }
|
7
7
|
let!(:stripe_payment_method) do
|
8
8
|
Spree::Gateway::StripeElementsGateway.create!(
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
name: 'Stripe',
|
10
|
+
preferred_secret_key: 'sk_test_VCZnDv3GLU15TRvn8i2EsaAN',
|
11
|
+
preferred_publishable_key: 'pk_test_Cuf0PNtiAkkMpTVC2gwYDMIg',
|
12
|
+
preferred_intents: preferred_intents
|
13
13
|
)
|
14
14
|
end
|
15
15
|
|
@@ -30,8 +30,13 @@ describe 'Stripe Elements 3ds checkout', type: :feature, js: true do
|
|
30
30
|
allow_any_instance_of(Spree::OrdersController).to receive_messages(try_spree_current_user: user)
|
31
31
|
|
32
32
|
add_to_cart(product)
|
33
|
-
|
34
|
-
|
33
|
+
|
34
|
+
if Spree.version.to_f >= 3.7 and Spree.version.to_f < 4.1
|
35
|
+
find("#checkout-link").click
|
36
|
+
else
|
37
|
+
click_link 'checkout'
|
38
|
+
click_button 'Place Order'
|
39
|
+
end
|
35
40
|
end
|
36
41
|
|
37
42
|
describe 'when intents are disabled' do
|
@@ -40,20 +45,61 @@ describe 'Stripe Elements 3ds checkout', type: :feature, js: true do
|
|
40
45
|
context 'and credit card does not require 3ds authentication' do
|
41
46
|
let(:card_number) { '4242424242424242' }
|
42
47
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
+
if Spree.version.to_f >= 3.7 and Spree.version.to_f < 4.1
|
49
|
+
it 'should place order without 3ds authentication', driver: :selenium_chrome_headless do
|
50
|
+
click_button 'Save and Continue'
|
51
|
+
click_button 'Save and Continue'
|
52
|
+
|
53
|
+
within_frame 0 do
|
54
|
+
fill_in 'cardnumber', with: card_number
|
55
|
+
fill_in 'exp-date', with: "01 / #{Time.current.strftime('%y').to_i + 3}"
|
56
|
+
fill_in 'cvc', with: "222"
|
57
|
+
end
|
58
|
+
|
59
|
+
click_button 'Save and Continue'
|
60
|
+
click_button 'Place Order'
|
61
|
+
|
62
|
+
expect(page).to have_content('Your order has been processed successfully')
|
63
|
+
order = Spree::Order.complete.last
|
64
|
+
expect(page.current_url).to include("/orders/#{order.number}")
|
65
|
+
expect(page).to have_content(order.number)
|
66
|
+
end
|
67
|
+
else
|
68
|
+
it 'should place order without 3ds authentication' do
|
69
|
+
expect(page).to have_content('Order placed successfully')
|
70
|
+
order = Spree::Order.complete.last
|
71
|
+
expect(page.current_url).to include("/orders/#{order.number}")
|
72
|
+
expect(page).to have_content(order.number)
|
73
|
+
end
|
48
74
|
end
|
49
75
|
end
|
50
76
|
|
51
77
|
context 'and credit card does require 3ds authentication' do
|
52
78
|
let(:card_number) { '4000000000003220' }
|
53
79
|
|
54
|
-
|
55
|
-
|
56
|
-
|
80
|
+
if Spree.version.to_f >= 3.7 and Spree.version.to_f < 4.1
|
81
|
+
it 'should not place the order', driver: :selenium_chrome_headless do
|
82
|
+
click_button 'Save and Continue'
|
83
|
+
click_button 'Save and Continue'
|
84
|
+
|
85
|
+
within_frame 0 do
|
86
|
+
fill_in 'cardnumber', with: card_number
|
87
|
+
fill_in 'exp-date', with: "01 / #{Time.current.strftime('%y').to_i + 3}"
|
88
|
+
fill_in 'cvc', with: "222"
|
89
|
+
end
|
90
|
+
|
91
|
+
click_button 'Save and Continue'
|
92
|
+
click_button 'Place Order'
|
93
|
+
|
94
|
+
expect(page).to have_content('Your card was declined. This transaction requires authentication.')
|
95
|
+
expect(Spree::Order.complete.last).to be_nil
|
96
|
+
end
|
97
|
+
|
98
|
+
else
|
99
|
+
it 'should not place the order' do
|
100
|
+
expect(page).to have_content('Your card was declined. This transaction requires authentication.')
|
101
|
+
expect(Spree::Order.complete.last).to be_nil
|
102
|
+
end
|
57
103
|
end
|
58
104
|
end
|
59
105
|
end
|
@@ -64,12 +110,32 @@ describe 'Stripe Elements 3ds checkout', type: :feature, js: true do
|
|
64
110
|
context 'and credit card does not require 3ds authentication' do
|
65
111
|
let(:card_number) { '4242424242424242' }
|
66
112
|
|
67
|
-
|
113
|
+
if Spree.version.to_f >= 3.7 and Spree.version.to_f < 4.1
|
114
|
+
it 'should successfully place order without 3ds authentication', driver: :selenium_chrome_headless do
|
115
|
+
click_button 'Save and Continue'
|
116
|
+
click_button 'Save and Continue'
|
117
|
+
|
118
|
+
within_frame 0 do
|
119
|
+
fill_in 'cardnumber', with: card_number
|
120
|
+
fill_in 'exp-date', with: "01 / #{Time.current.strftime('%y').to_i + 3}"
|
121
|
+
fill_in 'cvc', with: "222"
|
122
|
+
end
|
123
|
+
|
124
|
+
click_button 'Save and Continue'
|
125
|
+
click_button 'Place Order'
|
68
126
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
127
|
+
expect(page).to have_content('Your order has been processed successfully')
|
128
|
+
order = Spree::Order.complete.last
|
129
|
+
expect(page.current_url).to include("/orders/#{order.number}")
|
130
|
+
expect(page).to have_content(order.number)
|
131
|
+
end
|
132
|
+
else
|
133
|
+
it 'should successfully place order without 3ds authentication' do
|
134
|
+
expect(page).to have_content('Order placed successfully')
|
135
|
+
order = Spree::Order.complete.last
|
136
|
+
expect(page.current_url).to include("/orders/#{order.number}")
|
137
|
+
expect(page).to have_content(order.number)
|
138
|
+
end
|
73
139
|
end
|
74
140
|
end
|
75
141
|
|
@@ -77,28 +143,80 @@ describe 'Stripe Elements 3ds checkout', type: :feature, js: true do
|
|
77
143
|
let(:card_number) { '4000000000003220' }
|
78
144
|
|
79
145
|
context 'and authentication is successful' do
|
80
|
-
|
81
|
-
|
82
|
-
click_button
|
146
|
+
if Spree.version.to_f >= 3.7 and Spree.version.to_f < 4.1
|
147
|
+
it 'should place order after 3ds authentication', driver: :selenium_chrome_headless do
|
148
|
+
click_button 'Save and Continue'
|
149
|
+
click_button 'Save and Continue'
|
150
|
+
|
151
|
+
within_frame 0 do
|
152
|
+
fill_in 'cardnumber', with: card_number
|
153
|
+
fill_in 'exp-date', with: "01 / #{Time.current.strftime('%y').to_i + 3}"
|
154
|
+
fill_in 'cvc', with: "222"
|
155
|
+
end
|
156
|
+
|
157
|
+
click_button 'Save and Continue'
|
158
|
+
click_button 'Place Order'
|
159
|
+
|
160
|
+
within_stripe_3ds_popup do
|
161
|
+
click_button('Complete')
|
162
|
+
end
|
163
|
+
|
164
|
+
expect(page).to have_content('Your order has been processed successfully')
|
165
|
+
order = Spree::Order.complete.last
|
166
|
+
expect(page.current_url).to include("/orders/#{order.number}")
|
167
|
+
expect(page).to have_content(order.number)
|
83
168
|
end
|
84
169
|
|
85
|
-
|
86
|
-
order
|
87
|
-
|
88
|
-
|
170
|
+
else
|
171
|
+
it 'should place order after 3ds authentication' do
|
172
|
+
within_stripe_3ds_popup do
|
173
|
+
click_button('Complete')
|
174
|
+
end
|
175
|
+
|
176
|
+
expect(page).to have_content('Order placed successfully')
|
177
|
+
order = Spree::Order.complete.last
|
178
|
+
expect(page.current_url).to include("/orders/#{order.number}")
|
179
|
+
expect(page).to have_content(order.number)
|
180
|
+
end
|
89
181
|
end
|
90
182
|
end
|
91
183
|
|
92
184
|
context 'and authentication is unsuccessful' do
|
93
|
-
it 'should not place order after 3ds authentication' do
|
94
|
-
within_stripe_3ds_popup do
|
95
|
-
click_button('Fail')
|
96
|
-
end
|
97
185
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
186
|
+
if Spree.version.to_f >= 3.7 and Spree.version.to_f < 4.1
|
187
|
+
it 'should not place order after 3ds authentication', driver: :selenium_chrome_headless do
|
188
|
+
click_button 'Save and Continue'
|
189
|
+
click_button 'Save and Continue'
|
190
|
+
|
191
|
+
within_frame 0 do
|
192
|
+
fill_in 'cardnumber', with: card_number
|
193
|
+
fill_in 'exp-date', with: "01 / #{Time.current.strftime('%y').to_i + 3}"
|
194
|
+
fill_in 'cvc', with: "222"
|
195
|
+
end
|
196
|
+
|
197
|
+
click_button 'Save and Continue'
|
198
|
+
click_button 'Place Order'
|
199
|
+
|
200
|
+
within_stripe_3ds_popup do
|
201
|
+
click_button('Fail')
|
202
|
+
end
|
203
|
+
|
204
|
+
expect(page).to_not have_content('Order placed successfully')
|
205
|
+
expect(page).to have_content('We are unable to authenticate your payment method.')
|
206
|
+
expect(page).to have_content('Please choose a different payment method and try again.')
|
207
|
+
expect(Spree::Order.complete.last).to be_nil
|
208
|
+
end
|
209
|
+
else
|
210
|
+
it 'should not place order after 3ds authentication' do
|
211
|
+
within_stripe_3ds_popup do
|
212
|
+
click_button('Fail')
|
213
|
+
end
|
214
|
+
|
215
|
+
expect(page).to_not have_content('Order placed successfully')
|
216
|
+
expect(page).to have_content('We are unable to authenticate your payment method.')
|
217
|
+
expect(page).to have_content('Please choose a different payment method and try again.')
|
218
|
+
expect(Spree::Order.complete.last).to be_nil
|
219
|
+
end
|
102
220
|
end
|
103
221
|
end
|
104
222
|
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
class OrderWalkthrough
|
2
|
+
def self.up_to(state)
|
3
|
+
# A default store must exist to provide store settings
|
4
|
+
store = Spree::Store.default || FactoryBot.create(:store, default: true)
|
5
|
+
|
6
|
+
# A payment method must exist for an order to proceed through the Address state
|
7
|
+
unless Spree::PaymentMethod.exists?
|
8
|
+
FactoryBot.create(:check_payment_method)
|
9
|
+
end
|
10
|
+
|
11
|
+
# Need to create a valid zone too...
|
12
|
+
zone = FactoryBot.create(:zone)
|
13
|
+
country = FactoryBot.create(:country)
|
14
|
+
zone.members << Spree::ZoneMember.create(zoneable: country)
|
15
|
+
country.states << FactoryBot.create(:state, country: country)
|
16
|
+
|
17
|
+
# A shipping method must exist for rates to be displayed on checkout page
|
18
|
+
unless Spree::ShippingMethod.exists?
|
19
|
+
FactoryBot.create(:shipping_method).tap do |sm|
|
20
|
+
sm.calculator.preferred_amount = 10
|
21
|
+
sm.calculator.preferred_currency = store.default_currency
|
22
|
+
sm.calculator.save
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
order = Spree::Order.create!(email: 'spree@example.com')
|
27
|
+
add_line_item!(order)
|
28
|
+
order.next!
|
29
|
+
|
30
|
+
end_state_position = states.index(state.to_sym)
|
31
|
+
states[0...end_state_position].each do |state|
|
32
|
+
send(state, order)
|
33
|
+
end
|
34
|
+
|
35
|
+
order
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def self.add_line_item!(order)
|
41
|
+
FactoryBot.create(:line_item, order: order)
|
42
|
+
order.reload
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.address(order)
|
46
|
+
order.bill_address = FactoryBot.create(:address, country_id: Spree::Zone.global.members.first.zoneable.id)
|
47
|
+
order.ship_address = FactoryBot.create(:address, country_id: Spree::Zone.global.members.first.zoneable.id)
|
48
|
+
order.next!
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.delivery(order)
|
52
|
+
order.next!
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.payment(order)
|
56
|
+
FactoryBot.create :payment,
|
57
|
+
order: order,
|
58
|
+
payment_method: Spree::PaymentMethod.first,
|
59
|
+
amount: order.total
|
60
|
+
|
61
|
+
# TODO: maybe look at some way of making this payment_state change automatic
|
62
|
+
order.payment_state = 'paid'
|
63
|
+
order.next!
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.complete(_order)
|
67
|
+
# noop?
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.states
|
71
|
+
[:address, :delivery, :payment, :complete]
|
72
|
+
end
|
73
|
+
end
|
data/spree_gateway.gemspec
CHANGED
@@ -31,7 +31,6 @@ Gem::Specification.new do |s|
|
|
31
31
|
spree_version = '>= 3.7.0', '< 5.0'
|
32
32
|
s.add_dependency 'spree_core', spree_version
|
33
33
|
s.add_dependency 'spree_extension'
|
34
|
-
s.add_dependency 'deface'
|
35
34
|
|
36
35
|
s.add_development_dependency 'braintree', '~>2.78'
|
37
36
|
s.add_development_dependency 'rspec-activemodel-mocks'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_gateway
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.9.
|
4
|
+
version: 3.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Spree Commerce
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: spree_core
|
@@ -44,20 +44,6 @@ dependencies:
|
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '0'
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: deface
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
51
|
-
- - ">="
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '0'
|
54
|
-
type: :runtime
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
requirements:
|
58
|
-
- - ">="
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: '0'
|
61
47
|
- !ruby/object:Gem::Dependency
|
62
48
|
name: braintree
|
63
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -119,6 +105,7 @@ files:
|
|
119
105
|
- app/models/spree/apple_pay_payment_decorator.rb
|
120
106
|
- app/models/spree/billing_integration.rb
|
121
107
|
- app/models/spree/check.rb
|
108
|
+
- app/models/spree/credit_card_decorator.rb
|
122
109
|
- app/models/spree/gateway/authorize_net.rb
|
123
110
|
- app/models/spree/gateway/authorize_net_cim.rb
|
124
111
|
- app/models/spree/gateway/balanced_gateway.rb
|
@@ -166,8 +153,8 @@ files:
|
|
166
153
|
- db/migrate/20131112133401_migrate_stripe_preferences.rb
|
167
154
|
- db/migrate/20200317135551_add_spree_check_payment_source.rb
|
168
155
|
- db/migrate/20200422114908_add_intent_key_to_payment.rb
|
156
|
+
- gemfiles/spree_3_7.gemfile
|
169
157
|
- gemfiles/spree_4_1.gemfile
|
170
|
-
- gemfiles/spree_4_2.gemfile
|
171
158
|
- gemfiles/spree_master.gemfile
|
172
159
|
- lib/active_merchant/billing/stripe_gateway_decorator.rb
|
173
160
|
- lib/controllers/spree/api/v2/storefront/intents_controller.rb
|
@@ -228,6 +215,7 @@ files:
|
|
228
215
|
- spec/models/spree/order_spec.rb
|
229
216
|
- spec/requests/apple_pay_domain_verification.rb
|
230
217
|
- spec/spec_helper.rb
|
218
|
+
- spec/support/order_walktrough.rb
|
231
219
|
- spec/support/wait_for_stripe.rb
|
232
220
|
- spec/support/within_stripe_3ds_popup.rb
|
233
221
|
- spree_gateway.gemspec
|
@@ -236,9 +224,9 @@ licenses:
|
|
236
224
|
- BSD-3-Clause
|
237
225
|
metadata:
|
238
226
|
bug_tracker_uri: https://github.com/spree/spree_gateway/issues
|
239
|
-
changelog_uri: https://github.com/spree/spree_gateway/releases/tag/v3.9.
|
227
|
+
changelog_uri: https://github.com/spree/spree_gateway/releases/tag/v3.9.3
|
240
228
|
documentation_uri: https://guides.spreecommerce.org/
|
241
|
-
source_code_uri: https://github.com/spree/spree_gateway/tree/v3.9.
|
229
|
+
source_code_uri: https://github.com/spree/spree_gateway/tree/v3.9.3
|
242
230
|
post_install_message:
|
243
231
|
rdoc_options: []
|
244
232
|
require_paths:
|
@@ -255,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
255
243
|
version: '0'
|
256
244
|
requirements:
|
257
245
|
- none
|
258
|
-
rubygems_version: 3.
|
246
|
+
rubygems_version: 3.2.3
|
259
247
|
signing_key:
|
260
248
|
specification_version: 4
|
261
249
|
summary: Additional Payment Gateways for Spree Commerce
|
@@ -293,5 +281,6 @@ test_files:
|
|
293
281
|
- spec/models/spree/order_spec.rb
|
294
282
|
- spec/requests/apple_pay_domain_verification.rb
|
295
283
|
- spec/spec_helper.rb
|
284
|
+
- spec/support/order_walktrough.rb
|
296
285
|
- spec/support/wait_for_stripe.rb
|
297
286
|
- spec/support/within_stripe_3ds_popup.rb
|