Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-08T12:58:51.037Z
Answers.LastActivityDate: 2018-06-08T12:58:51.037Z
Answers.UserDisplayName: Syversen
Body: <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>
  
Tags: <stripe>
Title: Stripe checkout, card declined but no frontend error
ThreadText: # 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:
  
  [![enter image description here](https://i.sstatic.net/gqyID.png)](https://i.sstatic.net/gqyID.png)
  
  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.
  
  
  ---
  
  