• Resolved kimsf

    (@kimsf)


    Recently Stripe has not been allowing spaces at end of email addresses. This plugin needs to trim the space at the end of emails before passing it on to stripe.

    
      "error": {
        "type": "invalid_request_error",
        "message": "Invalid email address: [email protected] ",
        "param": "owner[email]"
      }
    

    As you can see after .com is a space which shouldn’t be there.

    For anyone else having this issue put the following code at the bottom of your checkout page and be sure to select the text tab (not visual tab) since it’s javascript.

     <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    
    <script>var x = document.getElementById("customer_details");
    x.addEventListener("blur", RemoveBillEmailSpace, true);
    function RemoveBillEmailSpace() { 
        document.getElementById("billing_email").value = document.getElementById("billing_email").value.replace(/^\s+|\s+$/g, "");
    $('#billing_email').trigger("change");
    }</script>
    • This topic was modified 7 years ago by kimsf.
    • This topic was modified 7 years ago by kimsf.
Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Contributor royho

    (@royho)

    Do you recall what payment method was used to get that error?

    Thread Starter kimsf

    (@kimsf)

    this plugin and Stripe of course. Woocommerce allows a space at the end of email addresses but stripe doesn’t.

    Plugin Contributor royho

    (@royho)

    Right but Stripe has many payment methods. Which one? Credit card? SEPA? Bancontact…etc…

    Thread Starter kimsf

    (@kimsf)

    Credit Card of course.

    Also I figured out that the plugin doesn’t stop an email has a space in the middle of it which will also get the charge denied by Stripe.

    Here’s code that fixes that which is better than the code I first posted.

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    
    <script>var x = document.getElementById("customer_details");
    x.addEventListener("blur", RemoveBillEmailSpace, true);
    function RemoveBillEmailSpace() { 
        document.getElementById("billing_email").value = document.getElementById("billing_email").value.replace(/ /, '');
    $('#billing_email').trigger("change");
    }</script>
    • This reply was modified 7 years ago by kimsf.
    Plugin Contributor royho

    (@royho)

    Hmmm I just did a back to back test with multiple spaces in the email and I did not get any errors while checking out with credit card. Anything specific way to replicate this?

    Thread Starter kimsf

    (@kimsf)

    How I replicate it is by putting in an e-mail address with spaces during checkout, filling out all the other fields, then entering in a test credit card, and then trying to check out. Stripe in the log shows 400 ERR and when I click it to get details at the bottom of it shows this:

    Response body

    "error": {
        "type": "invalid_request_error",
        "message": "Invalid email address: [email protected] ",
        "param": "owner[email]"
      }

    Now I do have plugins such as storefront powerpack and checkout field editor that could possibly remove validation of the field I dunno. Also apparently it’s possible to check out without the “@” in the email. It appears the field accepts anything but Stripe won’t and thus returns an error.

    It also appears that this stripe plugin will try to charge the card before checking if any of the fields on checkout are set correctly. So for example if the address field is required but I enter in nothing and then try to charge a credit card the plugin will go ahead and try to charge it but then after doing that run validation of the fields and deny the charge.

    • This reply was modified 7 years ago by kimsf.
    • This reply was modified 7 years ago by kimsf.
    Plugin Contributor royho

    (@royho)

    Ok then it sounds like you have a plugin that may be conflicting with this. Because by default, all fields should be validated before it even goes to Stripe. You can confirm this by deactivating all plugins except WC/Stripe.

    Thread Starter kimsf

    (@kimsf)

    Hmm then I’ll disable plugins or run vanilla woocommerce and see if the issue is still there.

    I’ve also updated the code to avoid jquery error and other issues:

    <script src="/wp-includes/js/jquery/jquery.js"></script>
    <script>var x = document.getElementById("customer_details");
    x.addEventListener("input", RemoveBillEmailSpace, true);
    function RemoveBillEmailSpace() { 
        document.getElementById("billing_email").value = document.getElementById("billing_email").value.replace(/ /, '');
    }</script>
    Plugin Contributor royho

    (@royho)

    That code you have could potentially cause issues because you’re loading jQuery when it is already enqueued by WP. Also your script can actually just use this https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim instead of replace.

    cyrudan

    (@cyrudan)

    Hey kimsf,

    Did you ever find a solution to this because I’m getting exactly the same problem, even after deactivating plugins

    D Smith a11n

    (@dsmithweb)

    Automattic Happiness Engineer

    Hi @cyrudan!

    In general, please start a new topic for your question. Have you temporarily disabled *all* plugins except Stripe and WooCommerce core?

    It could be code somewhere in your theme conflicting. If you temporarily change themes to Twenty Seventeen, does that make a difference?

    Plugin Support stephjacq a11n

    (@stephjacq)

    Automattic Happiness Engineer

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Stripe not allowing spaces at end of Email’ is closed to new replies.