spree_gateway 3.6.7 → 3.7.0

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: 863b9b04dd9189173d0382f43bae9b7e5860e6140b1ecf07fb5b818c11ca3178
4
- data.tar.gz: fced4c71837f469c500da6b733d902c9f0dd13a1b6d97a29615d8b9c0bfd9956
3
+ metadata.gz: 5bf7f502de95f41992227df814d11998e447bfe6f302d5654e09f99240b023db
4
+ data.tar.gz: 38e633ffafb01bb31934dcdec4df4a9c6444f1c728e1f1d41a623f2ec9514689
5
5
  SHA512:
6
- metadata.gz: a6d568542a74317a781ac77c4c059aea3550370932ea9a0966235fa1d87836512975a59a08b092250a9d9b328ad024b9b34c8854ea8d25924b0b996987b38ff1
7
- data.tar.gz: 0acdd438af4eae4f5837d4c4db21ee345e13b49a6ed41e98b1e79484f1f75ecf38be69f39d0c4532993f0ae32e3f5b642398ba46e428c811af4c747266bb9362
6
+ metadata.gz: 32dfea7c11e4a71f89a75bd092667c381d48b03611e857a86e3c11930100132c0f8d84a44288883d04c96a88557fe02aad27ce43600db56b93c3967ba2021d98
7
+ data.tar.gz: 9a1f8074d43f5feee5b128c8204edb8916f4eb975a0e3463f76e28e5d1a6825b3f79ba261c470a2039c3d1066fe0aa0337e0ea9ffde7e4c96111244316d79828
@@ -1,5 +1,5 @@
1
1
  module SpreeGateway
2
2
  def self.version
3
- '3.6.7'
3
+ '3.7.0'
4
4
  end
5
5
  end
@@ -6,8 +6,8 @@
6
6
  </script>
7
7
 
8
8
  <script>
9
- Spree.stripePaymentMethod = $('#payment_method_' + <%= payment_method.id %>);
10
9
  var mapCC, stripeResponseHandler;
10
+
11
11
  mapCC = function(ccType) {
12
12
  if (ccType === 'MasterCard') {
13
13
  return 'mastercard';
@@ -53,23 +53,27 @@
53
53
  }
54
54
  };
55
55
 
56
- Spree.ready(function() {
57
- Spree.stripePaymentMethod.prepend("<div id='stripeError' class='errorExplanation alert alert-danger' style='display:none'></div>");
58
- return $('#new_payment [data-hook=buttons]').click(function() {
59
- var expiration, params;
60
- $('#stripeError').hide();
61
- Spree.stripePaymentMethod.find('#card_number, #card_expiry, #card_code').removeClass('error');
62
- if (Spree.stripePaymentMethod.is(':visible')) {
63
- expiration = $('.cardExpiry:visible').payment('cardExpiryVal');
64
- params = $.extend({
65
- number: $('.cardNumber:visible').val(),
66
- cvc: $('.cardCode:visible').val(),
67
- exp_month: expiration.month || 0,
68
- exp_year: expiration.year || 0
69
- }, Spree.stripeAdditionalInfo);
70
- Stripe.card.createToken(params, stripeResponseHandler);
71
- return false;
72
- }
56
+ window.addEventListener('DOMContentLoaded', function() {
57
+ Spree.stripePaymentMethod = $('#payment_method_' + <%= payment_method.id %>);
58
+
59
+ Spree.ready(function() {
60
+ Spree.stripePaymentMethod.prepend("<div id='stripeError' class='errorExplanation alert alert-danger' style='display:none'></div>");
61
+ return $('#new_payment [data-hook=buttons]').click(function() {
62
+ var expiration, params;
63
+ $('#stripeError').hide();
64
+ Spree.stripePaymentMethod.find('#card_number, #card_expiry, #card_code').removeClass('error');
65
+ if (Spree.stripePaymentMethod.is(':visible')) {
66
+ expiration = $('.cardExpiry:visible').payment('cardExpiryVal');
67
+ params = $.extend({
68
+ number: $('.cardNumber:visible').val(),
69
+ cvc: $('.cardCode:visible').val(),
70
+ exp_month: expiration.month || 0,
71
+ exp_year: expiration.year || 0
72
+ }, Spree.stripeAdditionalInfo);
73
+ Stripe.card.createToken(params, stripeResponseHandler);
74
+ return false;
75
+ }
76
+ });
73
77
  });
74
78
  });
75
79
  </script>
@@ -6,8 +6,6 @@
6
6
  </script>
7
7
 
8
8
  <script>
9
- Spree.stripePaymentMethod = $('#payment_method_' + <%= payment_method.id %>);
10
-
11
9
  var mapCC, stripeResponseHandler;
12
10
 
13
11
  mapCC = function(ccType) {
@@ -57,23 +55,27 @@
57
55
  }
58
56
  };
59
57
 
60
- Spree.ready(function() {
61
- Spree.stripePaymentMethod.prepend("<div id='stripeError' class='errorExplanation alert alert-danger' style='display:none'></div>");
62
- return $('#checkout_form_payment [data-hook=buttons]').click(function() {
63
- var expiration, params;
64
- $('#stripeError').hide();
65
- Spree.stripePaymentMethod.find('#card_number, #card_expiry, #card_code').removeClass('error');
66
- if (Spree.stripePaymentMethod.is(':visible')) {
67
- expiration = $('.cardExpiry:visible').payment('cardExpiryVal');
68
- params = $.extend({
69
- number: $('.cardNumber:visible').val(),
70
- cvc: $('.cardCode:visible').val(),
71
- exp_month: expiration.month || 0,
72
- exp_year: expiration.year || 0
73
- }, Spree.stripeAdditionalInfo);
74
- Stripe.card.createToken(params, stripeResponseHandler);
75
- return false;
76
- }
58
+ window.addEventListener('DOMContentLoaded', function() {
59
+ Spree.stripePaymentMethod = $('#payment_method_' + <%= payment_method.id %>);
60
+
61
+ Spree.ready(function() {
62
+ Spree.stripePaymentMethod.prepend("<div id='stripeError' class='errorExplanation alert alert-danger' style='display:none'></div>");
63
+ return $('#checkout_form_payment [data-hook=buttons]').click(function() {
64
+ var expiration, params;
65
+ $('#stripeError').hide();
66
+ Spree.stripePaymentMethod.find('#card_number, #card_expiry, #card_code').removeClass('error');
67
+ if (Spree.stripePaymentMethod.is(':visible')) {
68
+ expiration = $('.cardExpiry:visible').payment('cardExpiryVal');
69
+ params = $.extend({
70
+ number: $('.cardNumber:visible').val(),
71
+ cvc: $('.cardCode:visible').val(),
72
+ exp_month: expiration.month || 0,
73
+ exp_year: expiration.year || 0
74
+ }, Spree.stripeAdditionalInfo);
75
+ Stripe.card.createToken(params, stripeResponseHandler);
76
+ return false;
77
+ }
78
+ });
77
79
  });
78
80
  });
79
81
  </script>
@@ -1,14 +1,16 @@
1
1
  <% bill_address ||= @order.bill_address %>
2
2
  <%- if @order.has_checkout_step?('address') -%>
3
3
  <script>
4
- Spree.stripeAdditionalInfo = {
5
- name: "<%= bill_address.full_name %>",
6
- address_line1: "<%= bill_address.address1 %>",
7
- address_line2: "<%= bill_address.address2 %>",
8
- address_city: "<%= bill_address.city %>",
9
- address_state: "<%= bill_address.state_text %>",
10
- address_zip: "<%= bill_address.zipcode %>",
11
- address_country: "<%= bill_address.country %>"
12
- }
4
+ window.addEventListener('DOMContentLoaded', function() {
5
+ Spree.stripeAdditionalInfo = {
6
+ name: "<%= bill_address.full_name %>",
7
+ address_line1: "<%= bill_address.address1 %>",
8
+ address_line2: "<%= bill_address.address2 %>",
9
+ address_city: "<%= bill_address.city %>",
10
+ address_state: "<%= bill_address.state_text %>",
11
+ address_zip: "<%= bill_address.zipcode %>",
12
+ address_country: "<%= bill_address.country %>"
13
+ };
14
+ });
13
15
  </script>
14
16
  <%- end -%>
@@ -7,7 +7,6 @@
7
7
  <script type="text/javascript" src="https://js.stripe.com/v3/"></script>
8
8
 
9
9
  <script>
10
- Spree.stripeApplePayPaymentMethod = $('#payment_method_' + <%= payment_method.id %>);
11
10
  var stripeApplePay = Stripe("<%= payment_method.preferred_publishable_key %>");
12
11
  var elements = stripeApplePay.elements();
13
12
 
@@ -82,14 +81,18 @@
82
81
  form.submit();
83
82
  });
84
83
 
85
- Spree.ready(function() {
86
- Spree.stripeApplePayPaymentMethod.prepend("<div id='stripeApplePayError' class='errorExplanation alert alert-danger' style='display:none'></div>");
87
- var form = document.getElementById('checkout_form_payment');
88
- form.addEventListener('submit', function(e) {
89
- if (Spree.stripeApplePayPaymentMethod.is(':visible')) {
90
- $('#stripeApplePayError').hide();
91
- e.preventDefault();
92
- }
84
+ window.addEventListener('DOMContentLoaded', function() {
85
+ Spree.stripeApplePayPaymentMethod = $('#payment_method_' + <%= payment_method.id %>);
86
+
87
+ Spree.ready(function() {
88
+ Spree.stripeApplePayPaymentMethod.prepend("<div id='stripeApplePayError' class='errorExplanation alert alert-danger' style='display:none'></div>");
89
+ var form = document.getElementById('checkout_form_payment');
90
+ form.addEventListener('submit', function(e) {
91
+ if (Spree.stripeApplePayPaymentMethod.is(':visible')) {
92
+ $('#stripeApplePayError').hide();
93
+ e.preventDefault();
94
+ }
95
+ });
93
96
  });
94
97
  });
95
98
  </script>
@@ -24,7 +24,6 @@
24
24
  <script type="text/javascript" src="https://js.stripe.com/v3/"></script>
25
25
 
26
26
  <script>
27
- Spree.stripeElementsPaymentMethod = $('#payment_method_' + <%= payment_method.id %>);
28
27
  var stripeElements = Stripe("<%= payment_method.preferred_publishable_key %>");
29
28
  var elements = stripeElements.elements();
30
29
 
@@ -55,6 +54,22 @@
55
54
  });
56
55
  card.mount('#card-element');
57
56
 
57
+ window.addEventListener('DOMContentLoaded', function() {
58
+ Spree.stripeElementsPaymentMethod = $('#payment_method_' + <%= payment_method.id %>);
59
+
60
+ Spree.ready(function() {
61
+ Spree.stripeElementsPaymentMethod.prepend("<div id='stripeElementsError' class='errorExplanation alert alert-danger' style='display:none'></div>");
62
+ var form = document.getElementById('checkout_form_payment');
63
+ form.addEventListener('submit', function(e) {
64
+ if (Spree.stripeElementsPaymentMethod.is(':visible')) {
65
+ $('#stripeElementsError').hide();
66
+ e.preventDefault();
67
+ createStripeElementsToken();
68
+ }
69
+ });
70
+ });
71
+ });
72
+
58
73
  function addCreditCardFieldToForm(form, name, value) {
59
74
  var hiddenInput = document.createElement('input');
60
75
 
@@ -87,18 +102,7 @@
87
102
  }
88
103
  });
89
104
  };
90
-
91
- Spree.ready(function() {
92
- Spree.stripeElementsPaymentMethod.prepend("<div id='stripeElementsError' class='errorExplanation alert alert-danger' style='display:none'></div>");
93
- var form = document.getElementById('checkout_form_payment');
94
- form.addEventListener('submit', function(e) {
95
- if (Spree.stripeElementsPaymentMethod.is(':visible')) {
96
- $('#stripeElementsError').hide();
97
- e.preventDefault();
98
- createStripeElementsToken();
99
- }
100
- });
101
- });
105
+
102
106
  </script>
103
107
 
104
108
  <%= render 'spree/checkout/payment/stripe_additional_info' %>
@@ -29,6 +29,7 @@ describe "Stripe checkout", type: :feature do
29
29
  Spree::CheckoutController.any_instance.stub(:current_order => order)
30
30
  Spree::CheckoutController.any_instance.stub(:try_spree_current_user => user)
31
31
  Spree::CheckoutController.any_instance.stub(:skip_state_validation? => true)
32
+ Spree::OrdersController.any_instance.stub(try_spree_current_user: user)
32
33
 
33
34
  # Capybara should wait up to 10 seconds for async. changes to be applied
34
35
  Capybara.default_max_wait_time = 10
@@ -42,34 +43,38 @@ describe "Stripe checkout", type: :feature do
42
43
 
43
44
  # This will pass the CC data to the server and the StripeGateway class handles it
44
45
  it "can process a valid payment (without JS)" do
45
- fill_in "Card Number", :with => "4242 4242 4242 4242"
46
- fill_in "Card Code", :with => "123"
47
- fill_in "Expiration", :with => "01 / #{Time.now.year + 1}"
46
+ fill_in 'card_number', with: '4242 4242 4242 4242'
47
+ fill_in 'card_code', with: '123'
48
+ fill_in 'card_expiry', with: "01 / #{Time.current.year + 1}"
48
49
  click_button "Save and Continue"
49
50
  expect(page.current_url).to include("/checkout/confirm")
50
51
  click_button "Place Order"
51
- expect(page).to have_content("Your order has been processed successfully")
52
+ order = Spree::Order.complete.last
53
+ expect(page.current_url).to include("/orders/#{order.number}")
54
+ expect(page).to have_content(order.number)
52
55
  end
53
56
 
54
57
  # This will fetch a token from Stripe.com and then pass that to the webserver.
55
58
  # The server then processes the payment using that token.
56
59
  it "can process a valid payment (with JS)", :js => true do
57
- fill_in "Card Number", :with => "4242 4242 4242 4242"
60
+ fill_in 'card_number', with: '4242 4242 4242 4242'
58
61
  # Otherwise ccType field does not get updated correctly
59
62
  page.execute_script("$('.cardNumber').trigger('change')")
60
- fill_in "Card Code", :with => "123"
61
- fill_in "Expiration", :with => "01 / #{Time.now.year + 1}"
63
+ fill_in 'card_code', with: '123'
64
+ fill_in 'card_expiry', with: "01 / #{Time.current.year + 1}"
62
65
  click_button "Save and Continue"
63
66
  wait_for_stripe # Wait for Stripe API to return + form to submit
64
67
  expect(page).to have_css('#checkout_form_confirm')
65
68
  expect(page.current_url).to include("/checkout/confirm")
66
69
  click_button "Place Order"
67
- expect(page).to have_content("Your order has been processed 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)
68
73
  end
69
74
 
70
75
  it "shows an error with an invalid credit card number", :js => true do
71
76
  # Card number is NOT valid. Fails Luhn checksum
72
- fill_in "Card Number", :with => "4242 4242 4242 4249"
77
+ fill_in 'card_number', with: '4242 4242 4242 4249'
73
78
  click_button "Save and Continue"
74
79
  wait_for_stripe
75
80
  expect(page).to have_content("Your card number is incorrect")
@@ -77,9 +82,9 @@ describe "Stripe checkout", type: :feature do
77
82
  end
78
83
 
79
84
  it "shows an error with invalid security fields", :js => true do
80
- fill_in "Card Number", :with => "4242 4242 4242 4242"
81
- fill_in "Expiration", :with => "01 / #{Time.now.year + 1}"
82
- fill_in "Card Code", :with => "99"
85
+ fill_in 'card_number', with: '4242 4242 4242 4242'
86
+ fill_in 'card_expiry', with: "01 / #{Time.current.year + 1}"
87
+ fill_in 'card_code', with: '99'
83
88
  click_button "Save and Continue"
84
89
  wait_for_stripe
85
90
  expect(page).to have_content("Your card's security code is invalid.")
@@ -87,9 +92,9 @@ describe "Stripe checkout", type: :feature do
87
92
  end
88
93
 
89
94
  it "shows an error with invalid expiry month field", :js => true do
90
- fill_in "Card Number", :with => "4242 4242 4242 4242"
91
- fill_in "Expiration", :with => "00 / #{Time.now.year + 1}"
92
- fill_in "Card Code", :with => "123"
95
+ fill_in 'card_number', with: '4242 4242 4242 4242'
96
+ fill_in 'card_expiry', :with => "00 / #{Time.now.year + 1}"
97
+ fill_in 'card_code', with: '123'
93
98
  click_button "Save and Continue"
94
99
  wait_for_stripe
95
100
  expect(page).to have_content("Your card's expiration month is invalid.")
@@ -97,9 +102,9 @@ describe "Stripe checkout", type: :feature do
97
102
  end
98
103
 
99
104
  it "shows an error with invalid expiry year field", :js => true do
100
- fill_in "Card Number", :with => "4242 4242 4242 4242"
101
- fill_in "Expiration", :with => "12 / "
102
- fill_in "Card Code", :with => "123"
105
+ fill_in 'card_number', with: '4242 4242 4242 4242'
106
+ fill_in 'card_expiry', with: '12 / '
107
+ fill_in 'card_code', with: '123'
103
108
  click_button "Save and Continue"
104
109
  wait_for_stripe
105
110
  expect(page).to have_content("Your card's expiration year is invalid.")
@@ -48,6 +48,7 @@ RSpec.configure do |config|
48
48
  DatabaseCleaner.strategy = RSpec.current_example.metadata[:js] ? :truncation : :transaction
49
49
  DatabaseCleaner.start
50
50
  reset_spree_preferences
51
+ create(:store)
51
52
  end
52
53
 
53
54
  config.after do
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.6.7
4
+ version: 3.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Spree Commerce
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-10 00:00:00.000000000 Z
11
+ date: 2020-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: spree_core