woocommerce / woocommerce-gateway-stripe

The official Stripe Payment Gateway for WooCommerce
https://wordpress.org/plugins/woocommerce-gateway-stripe/
234 stars 206 forks source link

Orders with invalid emails get rejected even if email isn't required #1058

Open Firebird75 opened 5 years ago

Firebird75 commented 5 years ago

This is a follow-up of https://wordpress.org/support/topic/orders-with-invalid-emails-rejected/

There is an issue with Stripe payment gateway for Woocommerce. It will reject orders in the following scenario : 1/ Email entered isn’t a valid email (even if email has been set to not be required) 2/ Email entered is valid but contain a trailing space

I have used Woocommerce filters to make the email not required. User can put it if they want to but this isn’t mandatory. It is up to them. If the field is left empty, the order goes through correctly. But in the 2 scenarios described above, the order won’t go through which isn’t good. A user can sometime put a trailing space without noticing it. Then, some people don’t know what an email address is or just don’t have one so they will either leave the field empty or just put a dummy value. In both cases, this should be accepted as the email field was set as not required via hooks.

Right now, in the two scenarios, Stripe is rejecting the order. I'd suggest to not pass the email to Stripe when it is detected as invalid and to remove trailing space.

Here is the code used to make the email field not mandatory : add_filter('woocommerce_checkout_fields','custom_override_checkout_fields');

function custom_override_checkout_fields($fields) { $fields['billing']['billing_email']['required'] = false;

return $fields;

}

jrodger commented 5 years ago

Hey,

Thanks for following up on your forum post and taking the time to write up this issue.

2/ Email entered is valid but contain a trailing space

Taking the last scenario first, I'm not able to reproduce the behaviour you're seeing with my setup. Using an email address with a trailing space like email@example.com results in the order being placed successfully. With debug logging turned on I can see that the email address is sent to Stripe with the trailing space trimmed off.

If we can figure out why you're seeing that fail though, I agree, it's not desirable and shouldn't prevent the order being placed.

1/ Email entered isn’t a valid email (even if email has been set to not be required)

I can see how validating the email address could confuse customers if they don't understand what an email address is exactly. However, I think the current behaviour does make sense. As you've pointed out, the email address is passed through to Stripe and if it's invalid we get something like this back:

image

So the error is clear, and the field that failed validation is highlighted red. In fact, even before the customer clicks "Place Order" that field will highlight red to hint that something might be wrong.

My concern with changing that behaviour is the impact it would have on a customer who did want to provide their email address. If they mis-typed it then the order would be placed and the email address ignored, even though they intended to supply it.

I don't think any of this behaviour changed recently, but just in case we're testing on different version, I carried out these tests on:

WordPress: 5.2.4
WooCommerce: 3.7.0
WooCommerce Stripe Gateway: 4.3.0
Storefront Theme: 2.5.3
Firebird75 commented 5 years ago

Hello James,

Thanks for the quick follow-up!

I did my test with Woocommerce 3.7.0 and Woocommerce Stripe Gateway 4.2.5 (previous release vs yours). I have just tested again and was able to reproduce the issue 100% of the time. I have put one trailing space and it is sent out to Stripe with the space (checked in the network panel in FF).

Your concern for the second scenario is pretty legit. Still I am not sure if it is really a good behavior to reject a full order because of an error in the email. Since I have turned off the email requirement (ie not making it mandatory anymore), I got 20% increases in orders. Now with that change 30% don't include an email. My customer base is pretty old so I guess some don't have an email and some others don't want to share it.

With tools such as smartlook, you can see what people are doing on the site. I can't tell you how many people have problems to fill in all the fields in the order page. People are trying again and again. They don't understand the error even if I have customized the message to make them more explicit.

My suggestion would be to add an option to allow orders to go through even if the email is invalid. Then, flag that the email is invalid in the panel. This leaves me the option to call the customer to get the valid email if I want/need. Another way to handle that would be to put a message to say : "Your order has been received but your email is invalid. Please reach out to XXX to correct your email if you want to receive the order details by email."

allendav commented 5 years ago

I also think that if the user enters an invalid email address we should retain the current behavior of not allowing the order to be placed, even if the email is not required.

I would be open to allowing filtering of the message displayed to users, e.g. allowing plugin devs to change it to "Invalid email address provided. Email is NOT required. Please correct or clear."

Is that possible today with existing filters, @jrodger ?

Firebird75 commented 5 years ago

Let's take the business view here. Woocommerce is an eCommerce plugin. We should remove every UX roadblock that could prevent an order from happening. From that point of view, I believe a filter isn't enough. We should have an option to disable email check or clear it if it is invalid before it goes to Stripe.

If you aren't convinced, make a try on few sites. I was very amazed to the sudden increase in orders on my ecommerce from the day where I have stopped making email mandatory. It fixed a part of the problem. Now just need to be able to completely bypass the checks so that invalid emails don't throw an error.

Right way to do it :