lib/views/frontend/spree/checkout/payment/_stripe.html.erb in spree_gateway-3.7.0 vs lib/views/frontend/spree/checkout/payment/_stripe.html.erb in spree_gateway-3.7.1
- old
+ new
@@ -53,30 +53,33 @@
Spree.stripePaymentMethod.append("<input type='hidden' class='stripeToken' name='payment_source[" + paymentMethodId + "][year]' value='" + response.card.exp_year + "'/>");
return Spree.stripePaymentMethod.parents("form").trigger('submit');
}
};
- window.addEventListener('DOMContentLoaded', function() {
+ window.addEventListener('DOMContentLoaded', function () {
Spree.stripePaymentMethod = $('#payment_method_' + <%= payment_method.id %>);
+ Spree.stripePaymentMethod.prepend("<div id='stripeError' class='errorExplanation alert alert-danger' style='display:none'></div>");
- Spree.ready(function() {
- Spree.stripePaymentMethod.prepend("<div id='stripeError' class='errorExplanation alert alert-danger' style='display:none'></div>");
- return $('#checkout_form_payment [data-hook=buttons]').click(function() {
- var expiration, params;
- $('#stripeError').hide();
- Spree.stripePaymentMethod.find('#card_number, #card_expiry, #card_code').removeClass('error');
- if (Spree.stripePaymentMethod.is(':visible')) {
- expiration = $('.cardExpiry:visible').payment('cardExpiryVal');
- params = $.extend({
- number: $('.cardNumber:visible').val(),
- cvc: $('.cardCode:visible').val(),
- exp_month: expiration.month || 0,
- exp_year: expiration.year || 0
- }, Spree.stripeAdditionalInfo);
- Stripe.card.createToken(params, stripeResponseHandler);
- return false;
- }
- });
+ $('#checkout_form_payment [data-hook=buttons]').click(function (e) {
+
+ var expiration, params;
+ $('#stripeError').hide();
+ Spree.stripePaymentMethod.find('#card_number, #card_expiry, #card_code').removeClass('error');
+ if (Spree.stripePaymentMethod.is(':visible')) {
+ e.preventDefault();
+
+ expiration = $('.cardExpiry:visible').payment('cardExpiryVal');
+ params = $.extend({
+ number: $('.cardNumber:visible').val(),
+ cvc: $('.cardCode:visible').val(),
+ exp_month: expiration.month || 0,
+ exp_year: expiration.year || 0
+ }, Spree.stripeAdditionalInfo);
+
+ Stripe.card.createToken(params, stripeResponseHandler);
+
+ return false;
+ }
});
});
</script>
<%= render 'spree/checkout/payment/stripe_additional_info', bill_address: @order.bill_address %>