Answers.Body: <p>This is how I got the errors to show:</p>
  
  <pre><code>{% if charge is defined and (charge.getErrors or charge.user) %}
      &lt;div&gt;
          {% if charge.getErrors %}
              {% for error in charge.getErrors('general') %}
                  {{ error }}
              {% endfor %}
              {% for key, error in charge.getErrors %}
                  {% if key != 'general' %}
                      {{ error[0] }}
                  {% endif %}
              {% endfor %}
          {% endif %}
          {% if charge.user %}
              {% for key, error in charge.user.getErrors %}
                  {% if key != 'general' %}
                      {{ error[0] }}
                  {% endif %}
              {% endfor %}
          {% endif %}
      &lt;/div&gt;
  {% endif %}
  </code></pre>
  
  <p>And then included:</p>
  
  <pre><code>&lt;div id="payment-errors"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>Before the submit button (as they are loaded using JS)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-08-23T15:54:22.107Z
Answers.LastActivityDate: 2018-08-23T15:54:22.107Z
Answers.UserDisplayName: KevAdamson
Answers.Body: <p>You have to insert this below your textfields </p>
  
  <pre><code>{% if charge is defined %}
      {% for error in charge.getErrors('FieldNameHere') %}
          &lt;ul class="errors"&gt;&lt;li&gt;{{ error }}&lt;/li&gt;&lt;/ul&gt;
      {% endfor %}
  {% endif %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-22T05:10:33.943Z
Answers.LastActivityDate: 2017-11-22T22:13:35.017Z
Answers.LastEditDate: 2017-11-22T22:13:35.017Z
Answers.UserDisplayName: ChooeyCraft
Body: <p>I am using the <a href="https://squarebit.co.uk/software/craft/charge/" rel="nofollow noreferrer">Charge</a> plugin.  They payment process happens in a modal.  If I enter in a bad number from one of the stripe test numbers and submit, when the payment fails the modal goes away and no errors are shown.  The errors are not getting loaded into the div set for payment errors.  I do get the errors before form submit but that doesn't help with a bad card or something.</p>
  
  <p>I am getting the error in the cp and can see it but I cannot find anything in their documentation to log this to the view.</p>
  
  <p>I have read <a href="https://squarebit.co.uk/software/craft/charge/usage/quickstart/using-stripe-js" rel="nofollow noreferrer">here</a> quite a bit and also viewed thier example and I am not doing anything different.  But for some reason I cannot get the declined error to show on the entry page once it returns.</p>
  
  <p>this is the script</p>
  
  <pre><code>&lt;script&gt;
    (function () {
      Stripe.setPublishableKey('{{ craft.charge.getPublicKey() }}');
      $(this).charge('#charge-form', '#payment-errors', '.charge-indicator');
    })();
  &lt;/script&gt;
  </code></pre>
  
  <p>Form is almost exactly the same as their example except that I have a few custom fields (those are not the fields with errors in them).</p>
  
  <p>If anyone has any experience with this plugin that can shed some light on how to return a declined card error or any errors that occur after form submission it would be greatly appreciated.</p>
  
  <p>I see this in the cp</p>
  
  <p><a href="https://i.sstatic.net/IdUAe.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/IdUAe.png" alt="enter image description here"></a></p>
  
Tags: <craft-pro><plugin-charge>
Title: Charge plugin not showing errors on payment fail
ThreadText: # Charge plugin not showing errors on payment fail
  
  (Asked by: username_0 on 2016-11-02)
  
  I am using the [Charge](https://squarebit.co.uk/software/craft/charge/) plugin. They payment process happens in a modal. If I enter in a bad number from one of the stripe test numbers and submit, when the payment fails the modal goes away and no errors are shown. The errors are not getting loaded into the div set for payment errors. I do get the errors before form submit but that doesn't help with a bad card or something.
  
  I am getting the error in the cp and can see it but I cannot find anything in their documentation to log this to the view.
  
  I have read [here](https://squarebit.co.uk/software/craft/charge/usage/quickstart/using-stripe-js) quite a bit and also viewed thier example and I am not doing anything different. But for some reason I cannot get the declined error to show on the entry page once it returns.
  
  this is the script
  
  ```
  <script>
    (function () {
      Stripe.setPublishableKey('{{ craft.charge.getPublicKey() }}');
      $(this).charge('#charge-form', '#payment-errors', '.charge-indicator');
    })();
  </script>
  
  ```
  
  Form is almost exactly the same as their example except that I have a few custom fields (those are not the fields with errors in them).
  
  If anyone has any experience with this plugin that can shed some light on how to return a declined card error or any errors that occur after form submission it would be greatly appreciated.
  
  I see this in the cp
  
  [![enter image description here](https://i.sstatic.net/IdUAe.png)](https://i.sstatic.net/IdUAe.png)
  
  **Tags:** craft-pro, plugin-charge
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2018-08-23. Score: 2
  
  This is how I got the errors to show:
  
  ```
  {% if charge is defined and (charge.getErrors or charge.user) %}
      <div>
          {% if charge.getErrors %}
              {% for error in charge.getErrors('general') %}
                  {{ error }}
              {% endfor %}
              {% for key, error in charge.getErrors %}
                  {% if key != 'general' %}
                      {{ error[0] }}
                  {% endif %}
              {% endfor %}
          {% endif %}
          {% if charge.user %}
              {% for key, error in charge.user.getErrors %}
                  {% if key != 'general' %}
                      {{ error[0] }}
                  {% endif %}
              {% endfor %}
          {% endif %}
      </div>
  {% endif %}
  
  ```
  
  And then included:
  
  ```
  <div id="payment-errors"></div>
  
  ```
  
  Before the submit button (as they are loaded using JS)
  
  
  ---
  
  ### Answer by username_2 on 2017-11-22. Score: 1
  
  You have to insert this below your textfields
  
  ```
  {% if charge is defined %}
      {% for error in charge.getErrors('FieldNameHere') %}
          <ul class="errors"><li>{{ error }}</li></ul>
      {% endfor %}
  {% endif %}
  
  ```
  
  
  ---
  
  