<p>As usual it is just me being stupid.
The error is accessible with:</p>

<pre><code>{% set error = craft.session.getFlash('error') %}
{{ error }}
</code></pre>

<p>Maybe it will help some other people.</p>

CC BY-SA 4.0
2018-06-08T12:58:51.037Z
2018-06-08T12:58:51.037Z
Syversen
<p>I have a Craft 2 site running commerce who have a small issue with the stripe gateway.</p>

<p>I am using <a href="https://checkout.stripe.com/checkout.js" rel="nofollow noreferrer">https://checkout.stripe.com/checkout.js</a> instead of the standard stripe markup.</p>

<p>JS looks like this (inside the standard commerce/payments/pay form:</p>

<pre><code>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();
});
</code></pre>

<p>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. </p>

<p>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.</p>

<p>Am I missing something? On test mode I can reproduce this using card number 4000000000000341. The cart looks like this in the CP:</p>

<p><a href="https://i.sstatic.net/gqyID.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/gqyID.png" alt="enter image description here"></a></p>

<p>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?</p>

<stripe>
Stripe checkout, card declined but no frontend error
# Stripe checkout, card declined but no frontend error

(Asked by: username_0 on 2018-06-08)

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?

**Tags:** stripe

---

## 1 answers

### Answer by username_0 on 2018-06-08. Score: 5 | Accepted answer

As usual it is just me being stupid.
The error is accessible with:
{% set error = craft.session.getFlash('error') %}
{{ error }}

Maybe it will help some other people.


---

