I have a Craft 2 site running commerce who have a small issue with the stripe gateway.
I am using https://checkout.stripe.com/checkout.js instead of the standard stripe markup.
JS looks like this (inside the standard commerce/payments/pay form:
var handler = StripeCheckout.configure({
key: '{{ cart.paymentMethod.settings.publishableKey ?? '' }}',
image: '',
locale: 'auto',
token: function(token) {
// You can access the token ID with `token.id`.
var stripeToken = token.id;
// Get the token ID to your server-side code for use.
document.getElementById('stripe-token').value = stripeToken;
document.getElementById('payment-form').submit();
}
});
document.getElementById('paymentButton').addEventListener('click', function(evt) {
// Open Checkout with further options:
handler.open({
name: '{{ siteName }}',
email: '{{ cart.email }}',
currency: '{{ cart.paymentCurrency }}',
description: 'Membership',
amount: {{ cart.totalPrice|commerceCurrency(cart.paymentCurrency,convert=true,format=false) * 100 }}
});
evt.preventDefault();
});
// Close Checkout on page navigation:
window.addEventListener('popstate', function() {
handler.close();
});
Currently, in some cases, the card is declined, but the popup from stripe acts as if everything is ok. You get a green check-mark when submitting, and then the checkout page just reloads instead of going to the order overview.
I am looking on network and console in Chrome, and cant see any responses or error messages. And in the basic checkout page from commerce I dont see any error array for the payment gateway.
Am I missing something? On test mode I can reproduce this using card number 4000000000000341. The cart looks like this in the CP:
Usually when the card gets declined there is a notification in the stripe popup. But not in this case. And as you can see from the picture Craft is well aware that the payment got declined. Is there any way for me to notify the customer of this? Instead of just having the checkout page reload?