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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b54b6ec2e6137ae258ac3d108c715f3a8bf2e534c8f3ee13946529831fdf6c8e
4
- data.tar.gz: 95e413abf6077ee0ed9cf92d260be0ad44de0888334d94b6d60b8b68002e85fd
3
+ metadata.gz: 82e672befb08ae277659eec1f7686002af0b6f66b1f8ecb467649ab29667aee2
4
+ data.tar.gz: 47d5a54c20d7987569af842d50f471e6f3eea69647f6807865191c55e97f61cc
5
5
  SHA512:
6
- metadata.gz: b94ebcae1a0004d780547e34f73764093a84ab49a36a6c31bbc5177b7094c6c609a545da6684d262eb65155550c8c6eb1eb528118a1258ef2b090512c862afa7
7
- data.tar.gz: 2facdc1ebd849fe10fffb1b2ab0daebef9e90d7178bcad1a29fd3cd896935fc12c2f828dd48e01644557f3abf21320b76402c150ba8399b309fbbc5d9a83a668
6
+ metadata.gz: 5efb8b8ce887c92a222bf0b4c4b53b0ea16ee45f6efff3ad2908acdc5e3383139b778362be57ed858d15a0497df4d6aa37fa2c8f56ddee81f334945bcb67fe9f
7
+ data.tar.gz: fb61b3afbfc998e819bd11cf5d1f53c782e0e486c5b0fea6c43710fba74664398384badff68298a593b715185da3eaa68727e18b3d575dc5f14511d232d7f437
@@ -15,20 +15,26 @@ services:
15
15
  language: ruby
16
16
 
17
17
  rvm:
18
- - 2.6
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
- # - gemfiles/spree_4_1.gemfile
26
- - gemfiles/spree_4_2.gemfile
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
- - gemfile: gemfiles/spree_master.gemfile
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-4-1' do
2
- gem 'spree', '~> 4.1.0'
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-2' do
7
- gem 'spree', '~> 4.2.0.beta'
7
+ appraise 'spree-4-1' do
8
+ gem 'spree', '~> 4.1.0'
8
9
  gem 'rails-controller-testing'
9
10
  end
10
11
 
@@ -0,0 +1,10 @@
1
+ module Spree
2
+ module CreditCardDecorator
3
+ def set_last_digits
4
+ self.last_digits ||= number.to_s.length <= 4 ? number : number.to_s.slice(-4..-1)
5
+ end
6
+
7
+ end
8
+ end
9
+
10
+ ::Spree::CreditCard.prepend(::Spree::CreditCardDecorator)
@@ -9,7 +9,7 @@ module Spree
9
9
  Check
10
10
  end
11
11
 
12
- def verify(source, **gateway_options)
12
+ def verify(source, gateway_options)
13
13
  provider.verify(source, gateway_options)
14
14
  end
15
15
 
@@ -1,7 +1,9 @@
1
1
  module Spree
2
2
  module PaymentDecorator
3
3
  def handle_response(response, success_state, failure_state)
4
- self.intent_client_key = response.params['client_secret'] if response.params['client_secret'] && response.success?
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
- form.elements["commit"].disabled = false;
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
- form.elements["commit"].disabled = false;
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
  });
@@ -3,6 +3,7 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "rails-controller-testing"
6
- gem "spree", "~> 4.2.0.beta"
6
+ gem "spree", "~> 3.7.0"
7
+ gem "sass-rails"
7
8
 
8
9
  gemspec path: "../"
@@ -2,4 +2,3 @@ require 'spree_core'
2
2
  require 'spree_gateway/engine'
3
3
  require 'spree_gateway/version'
4
4
  require 'spree_extension'
5
- require 'deface'
@@ -1,5 +1,5 @@
1
1
  module SpreeGateway
2
2
  def self.version
3
- '3.9.2'
3
+ '3.9.3'
4
4
  end
5
5
  end
@@ -1,53 +1,43 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'Admin Panel Stripe elements payment', type: :feature, :js => true do
3
+ describe 'Admin Panel Stripe elements payment', type: :feature do
4
4
  stub_authorization!
5
5
 
6
- let!(:country) { create(:country, :states_required => true) }
7
- let!(:state) { create(:state, :country => country) }
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) { create(:stock_location) }
10
- let!(:mug) { create(:product, :name => 'RoR Mug') }
11
- let!(:zone) { create(: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
- :name => 'Stripe Element',
15
- :preferred_secret_key => 'sk_test_VCZnDv3GLU15TRvn8i2EsaAN',
16
- :preferred_publishable_key => 'pk_test_Cuf0PNtiAkkMpTVC2gwYDMIg'
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
- expect(page).to have_content("Credit card Name can't be blank")
36
- expect(page).to have_current_path spree.admin_order_payments_path(order.number)
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
- expect(page.body).to have_content('Payment has been successfully created!')
44
- expect(page).to have_current_path spree.admin_order_payments_path(order.number)
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 *', '#card_number1', 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 *', '#card_expiry1', card_expiry)
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)", :js => true do
60
- fill_in 'card_number', with: '4242 4242 4242 4242'
61
- # Otherwise ccType field does not get updated correctly
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", :js => true do
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
- expect(page).to have_content("Your card number is incorrect")
81
- expect(page).to have_css('.has-error #card_number.error')
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", :js => true do
85
- fill_in 'card_number', with: '4242 4242 4242 4242'
86
- fill_in 'card_expiry', with: "01 / #{Time.current.year + 1}"
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", :js => true do
97
- skip if Spree.version.to_f >= 4.2
98
- fill_in 'card_number', with: '4242 4242 4242 4242'
99
- fill_in 'card_expiry', :with => "00 / #{Time.now.year + 1}"
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", :js => true do
108
- fill_in 'card_number', with: '4242 4242 4242 4242'
109
- fill_in 'card_expiry', with: '12 / '
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
- name: 'Stripe',
10
- preferred_secret_key: 'sk_test_VCZnDv3GLU15TRvn8i2EsaAN',
11
- preferred_publishable_key: 'pk_test_Cuf0PNtiAkkMpTVC2gwYDMIg',
12
- preferred_intents: preferred_intents
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
- click_link 'checkout'
34
- click_button 'Place Order'
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
- it 'should place order without 3ds authentication' do
44
- expect(page).to have_content('Order placed successfully')
45
- order = Spree::Order.complete.last
46
- expect(page.current_url).to include("/orders/#{order.number}")
47
- expect(page).to have_content(order.number)
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
- it 'should not place the order' do
55
- expect(page).to have_content('Your card was declined. This transaction requires authentication.')
56
- expect(Spree::Order.complete.last).to be_nil
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
- it 'should successfully place order without 3ds authentication' do
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
- 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)
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
- it 'should place order after 3ds authentication' do
81
- within_stripe_3ds_popup do
82
- click_button('Complete')
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
- expect(page).to have_content('Order placed successfully')
86
- order = Spree::Order.complete.last
87
- expect(page.current_url).to include("/orders/#{order.number}")
88
- expect(page).to have_content(order.number)
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
- expect(page).to_not have_content('Order placed successfully')
99
- expect(page).to have_content('We are unable to authenticate your payment method.')
100
- expect(page).to have_content('Please choose a different payment method and try again.')
101
- expect(Spree::Order.complete.last).to be_nil
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
@@ -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.2
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: 2020-11-09 00:00:00.000000000 Z
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.2
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.2
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.1.2
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