Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when I checkout, magento2 tip me Email has a wrong format~ please~ #16101

Closed
forwells opened this issue Jun 14, 2018 · 34 comments
Closed

when I checkout, magento2 tip me Email has a wrong format~ please~ #16101

forwells opened this issue Jun 14, 2018 · 34 comments
Labels
Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Progress: needs update

Comments

@forwells
Copy link

forwells commented Jun 14, 2018

Preconditions

  1. magento 2.2.2
  2. And I use a clean installation

Steps to reproduce

  1. add one simple products to cart
  2. proceessed to checkout
  3. and wait for complete order

Expected result

  1. [Screenshots, logs or description]
    success to checkout or redirect to checkout url

Actual result

  1. magento tip me Email has a wrong format , I'm not sure wether where has some problem
  2. [Screenshots, logs or description]

image

20200326~

I don't remember the specific solution process about the last issue, but today, I encountered this problem again in Magento 2.3.3. Next, I will solve this problem anyway, and update the effective solution of this problem Program

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Jun 14, 2018
@kkrieger85 kkrieger85 self-assigned this Jun 17, 2018
@kkrieger85
Copy link

@forwells What does your email look like?

Magento uses default php function 'filter_var' to validate email.
Maybe you can test your used email with this snippet:

$c = 'YOUR_EMAIL';
$sanitized_c = filter_var($c, FILTER_SANITIZE_EMAIL);
if (filter_var($sanitized_c, FILTER_VALIDATE_EMAIL)) {
    echo "Before: $c\n";
    echo "After:  $sanitized_c\n";    
}

@DanielRuf
Copy link
Contributor

Which PHP version do you use?

@forwells
Copy link
Author

forwells commented Jun 19, 2018

@kkrieger85
Thanks,
This happens in a payment extension. When I click on the place order button as a visitor, the personal information I include in the payment form, including address information, is not stored in the quote table. I'm not sure what caused this.

@forwells
Copy link
Author

forwells commented Jun 19, 2018

@DanielRuf
I use PHP 7.0.28

@DanielRuf
Copy link
Contributor

Can you test the code snippet against the problematic email address on 3v4l.org?

@forwells
Copy link
Author

@DanielRuf
This problem is not an issue with the format of the e-mail. Instead, when the place order button is clicked, the quote table cannot save the e-mail address that the visitor fills in the first step of the shopping cart with the click. . .

@kkrieger85
Copy link

@forwells Can you please update the Steps to reproduce section? Please describe in detail how someone can reproduce your issue. I tested with your current steps and can not reproduce this issue.

@forwells
Copy link
Author

forwells commented Jun 20, 2018

@kkrieger85
This is where the problem occurs,
ng 0_978w2l4w 7ioe8g7y
when I place order , the cart tip me the format of email is wrong, and I check it in process, the email is blank in quote table , so, when I click next button in step 1, the process is not memory the guest or customer email in quote table , I can't find the place where the email can be memory...

so, I add a custom field to the step 1 t :(guest/customer infomation list), yes, it's checkout_buyer_email,so it can be memory in quote table replace the customer_email field...

@magento-engcom-team
Copy link
Contributor

@forwells It's still unclear, what kind of email does not pass validation and how to reproduce this with a clean installation. Please attempt to update the steps in such a way that anyone can reproduce the problem.

Thank you

@ilievski
Copy link

we have a very similar problem, however our steps are different:

Magento 2.19

Steps to reproduce:

  1. Add to cart
  2. Proceed to checkout
  3. Log in
  4. Select Shipping
  5. Press Place order button

Expected result:
Order to be successfully placed and Thank you page to load

Actual Result:
Error :We cannot save the address. Email has wrong format .
(Please see screenshot :http://prntscr.com/k5p8tj)

After reviewing logs, we determined that the email address was not sent to the payment gateway along with the rest of the billing info, so Our payment gateway (Braintree) response back to M2 for e-mail address is "NULL"

This issue occurs for us only for 1 or 2 customers a day while hundreds of other Logged in customers do not have this issue at all

@Aaron-Lewis
Copy link

Hi.

We are having a similar problem as well, "Email has a wrong Format".

We set up a watch in the code to return what value was been sent to SagePay payment gateway.

Server logs was telling us Email Address value was returning NULL.

Looking in the database we discovered table 'sales_order_address' email address column had NULL references for some customers details who entered different shipping address to billing address. This behavior was odd as not all customers who had completely different shipping information to billing information, had NULL in shipping email address column.

This is as far as we have got so far, but if any one more information on this issue, then let us know.

Site is built on Magento 2.17

@AndyJAllen
Copy link

I am experiencing the same problem on Magento 2.2.5, using the same steps as ilievski. The problem only happens when you sign in AFTER adding the product to the cart.

@ghost
Copy link

ghost commented Sep 6, 2018

@AndyJAllen @Aaron-Lewis @ilievski @forwells
We cannot reproduce this issue. Can anyone reproduce it on the clean Magento 2 installation and provide updated steps?

@deepakkn85
Copy link

I got the same issue while trying to place an order using REST API. I tried in Magento 2.2.5. Any updates on this issue?

@ghost
Copy link

ghost commented Sep 13, 2018

@deepakkn85, please provide steps to reproduce.

@AndyJAllen
Copy link

I ended up figuring this out. You have to go into the database and fix an e-mail field that is not set for a pending order from the past. Apparently this happens during one of the upgrades in 2.2, but after you set the email field it works moving forward. The problem should not happen to new accounts, but just accounts that already existed prior to the upgrade of M2.

@deepakkn85
Copy link

deepakkn85 commented Sep 14, 2018

@engcom-backlog-pb : Please see the attached screenshots of parameters used to create order and final request to create order. Please let me know if I am missing anything here, which caused the issue.

add-item

billing-details

shipping-payment

create-order-request

The response on I am getting is attached below.

response

Thanks in advance!

@ghost
Copy link

ghost commented Sep 14, 2018

@deepakkn85, thank you for the update. We were not able to reproduce this issue by following the steps you provided.

@ghost ghost closed this as completed Sep 14, 2018
@deepakkn85
Copy link

@engcom-backlog-pb : Then what could be the possible reason for the response which I am getting? I have shared the screenshot of the same in my previous thread.

@zestbeauty
Copy link

we have a very similar problem, however our steps are different:

Magento 2.19

Steps to reproduce:

  1. Add to cart
  2. Proceed to checkout
  3. Log in
  4. Select Shipping
  5. Press Place order button

Expected result:
Order to be successfully placed and Thank you page to load

Actual Result:
Error :We cannot save the address. Email has wrong format .
(Please see screenshot :http://prntscr.com/k5p8tj)

After reviewing logs, we determined that the email address was not sent to the payment gateway along with the rest of the billing info, so Our payment gateway (Braintree) response back to M2 for e-mail address is "NULL"

This issue occurs for us only for 1 or 2 customers a day while hundreds of other Logged in customers do not have this issue at all

We have the exact same issue. Have you managed to resolve this?
Thanks

@HenningBeck
Copy link

We experienced the same problem today during our test. This is the first time we see the error after about 100 test purchases.

We run on Magento 2.2.6 and use the procedure

  1. Log in
  2. Add to cart
  3. Checkout
  4. Add card info and Place order now

As indicated above, the problem seems to be in the cart. We could bypass the problem by emptying the cart and add the product again.

We started using Magento on this version, so the cart has not been processed by an upgrade.

@zestbeauty
Copy link

zestbeauty commented Oct 9, 2018

Is this issue related to this
Magento_Sales module fails to upgrade (email has a wrong format) #14964

If so would this fix the issue?

update sales_order_address a left join sales_order_address b on a.parent_id = b.parent_id set a.email = b.email where a.email is null

@zestbeauty
Copy link

@ilievski
Would it be possible if anyone could reply, as we really need to know if anyone has fixed this?

@AndyJAllen
Are you able to explain more detail of how you fixed this?

@ilievski
Copy link

HI @zestbeauty ...
we didn't managed to find general solution for the problem, but we did found the cause and temporarily solved it.
Basically the problem was with the customer session data, where in some cases the information for email, or even billing or shipping address was getting overwritten or deleted when customer login on checkout.
We never figured out why this was happening, however a temporary solution was to always delete customer session when they are using login on checkout. Basically emptying their cart if they decide to login on checkout. Not a perfect solution but solved Our Problem.

@AidanThreadgold
Copy link

Hi @ilievski - you mentioned;

After reviewing logs, we determined that the email address was not sent to the payment gateway along with the rest of the billing info, so Our payment gateway (Braintree) response back to M2 for e-mail address is "NULL"

Are you able to share any of those logs or the process by which you came to identify that it was the payment method at fault here?

Thanks,

@zestbeauty
Copy link

We are still suffering from this issue. It appears that it only happens on customer accounts that login and that where created in M1 and migrated from M1 to M2

@AndyJAllen
Copy link

We are still suffering from this issue. It appears that it only happens on customer accounts that login and that where created in M1 and migrated from M1 to M2

In my case it was because I migrated from 2.1.x to 2.2.x... I deleted the account, recreated it, and the problem went away. I also noticed while the problem existed, it created an authorization through Paypal Payflow Pro for each failure.

@forwells
Copy link
Author

Here will explain why this problem occurs and how to deal with it.
Generally, such abnormal problems do not occur during the native Magento2.x checkout process.General problems occur when custom products are added to the shopping cart, and then the shopping cart (Quote) data is processed and generated programmatically Orders, unfortunately, in such a complicated construction of Magento2 (especially in the core part of the shopping cart, although everything seems more complicated, especially the construction of complex modules, such as operational data processing), sorry, it's a long way off.
The following explains how to deal with this problem.
Since our premise is to customize the quote, then the solution is explained in a custom way:
1, add products to cart
     > In quote_address we can see the email, name, etc. of customer
     > If it is a custom process, the operation we have done is one-sided, not a complete process, which is the root cause of the problem.
  2, wrong email address comes from
\vendor\magento\module-quote\Model\QuoteManagement.php
method: submitQuote

$shippingAddress = $this->quoteAddressToOrderAddress->convert( $quote->getShippingAddress(), [ 'address_type' => 'shipping', 'email' => $quote->getCustomerEmail() ] );
$quote->getCustomerEmail() => NULL
so, we should check the customer_email in quote table is it a NULL type value?
And provide a right value for it , and program will go on

@Arsalanulhaq
Copy link

What was the solution of it? Please tell me. Suddenly I am also facing the same issue, in Magento 2.3.2. I checked in this \vendor\magento\module-quote\Model\QuoteManagement.php
customer data is appearing empty.

@DanielRuf
Copy link
Contributor

@Arsalanulhaq check the previous comments.

Also please open a new issue and provide all details so we can reproduce it on a vanilla Magento 2 instance.

@Arsalanulhaq
Copy link

The previous comments doesn't seem to provide the solution. I'll create a new issue also.

@VZeroCool
Copy link

VZeroCool commented Jun 1, 2020

This is still reproducible in Magento 2.3.3, I can able to reproduce while using API,
Create quote for customer for default store, Add to cart for default store

Use V1/carts/mine/ with other store because we've scenario where after adding product to cart from english customer switched store and viewing cart in arabic store.

This API returns product names in english even though passing store code in API.

To resolve this I used "PUT" request with V1/carts/mine and payload is like,

{ "quote": { "id": 8475, "store_id": 2, "customer": { "id": 158 } } }

This thing work but after this doesn't allow me to place an order. Keep getting "
"message": "Failed address validation: Email has a wrong format","

This PUT request removed email address from quote table. and due to that this error coming up.

"trace": "#0 /var/www/html/magento/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Checkout\Model\PaymentInformationManagement->savePaymentInformationAndPlaceOrder(8477, Object(Magento\Quote\Model\Quote\Payment\Interceptor), Object(Magento\Quote\Model\Quote\Address)) #1 /var/www/html/magento/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Checkout\Model\PaymentInformationManagement\Interceptor->___callParent('savePaymentInfo...', Array) #2 /var/www/html/magento/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Checkout\Model\PaymentInformationManagement\Interceptor->Magento\Framework\Interception\{closure}(8477, Object(Magento\Quote\Model\Quote\Payment\Interceptor), Object(Magento\Quote\Model\Quote\Address)) #3 /var/www/html/magento/generated/code/Magento/Checkout/Model/PaymentInformationManagement/Interceptor.php(26): Magento\Checkout\Model\PaymentInformationManagement\Interceptor->___callPlugins('savePaymentInfo...', Array, Array) #4 [internal function]: Magento\Checkout\Model\PaymentInformationManagement\Interceptor->savePaymentInformationAndPlaceOrder(8477, Object(Magento\Quote\Model\Quote\Payment\Interceptor), Object(Magento\Quote\Model\Quote\Address)) #5 /var/www/html/magento/vendor/magento/module-webapi/Controller/Rest/SynchronousRequestProcessor.php(95): call_user_func_array(Array, Array) #6 /var/www/html/magento/vendor/magento/module-webapi/Controller/Rest.php(188): Magento\Webapi\Controller\Rest\SynchronousRequestProcessor->process(Object(Magento\Framework\Webapi\Rest\Request\Proxy)) #7 /var/www/html/magento/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Webapi\Controller\Rest->dispatch(Object(Magento\Framework\App\Request\Http)) #8 /var/www/html/magento/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Webapi\Controller\Rest\Interceptor->___callParent('dispatch', Array) #9 /var/www/html/magento/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Webapi\Controller\Rest\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http)) #10 /var/www/html/magento/generated/code/Magento/Webapi/Controller/Rest/Interceptor.php(26): Magento\Webapi\Controller\Rest\Interceptor->___callPlugins('dispatch', Array, Array) #11 /var/www/html/magento/vendor/magento/framework/App/Http.php(137): Magento\Webapi\Controller\Rest\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http)) #12 /var/www/html/magento/generated/code/Magento/Framework/App/Http/Interceptor.php(24): Magento\Framework\App\Http->launch() #13 /var/www/html/magento/vendor/magento/framework/App/Bootstrap.php(261): Magento\Framework\App\Http\Interceptor->launch() #14 /var/www/html/magento/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor)) #15 {main}" }

FINDINGS

Error message comes from Magento\Quote\Model\SubmitQuoteValidator::validateOrder
but at validator method Magento\Sales\Model\Order\Address\Validator::validate
Address object returns null for email.

Array
(
    [vat_id] => 
    [vat_is_valid] => 
    [vat_request_id] => 
    [vat_request_date] => 
    [vat_request_success] => 
    [customer_address_id] => 
    [prefix] => 
    [firstname] => Zero
    [middlename] => 
    [lastname] => Cool
    [suffix] => 
    [company] => 
    [street] => Wall Street
    [city] => Riyadh
    [region] => Madina
    [region_id] => 
    [postcode] => 12345
    [country_id] => SA
    [telephone] => 1234567890
    [fax] => 
    [email] => 
    [address_type] => shipping
    [quote_address_id] => 17701
    [parent_id] => 
)

Afte this I went to DB and checked quote table where email is null my quote ID but I remember that I post email within payload.

Adding email to quote will solve the problem but this is kinda weird that update quote from one store to other creates this problem. There's total 2 issue I would like to address here, Why get cart not returning then store specific data ? Why updating quote is creating this error ?

@DanielRuf @magento-engcom-team

@1stoked21
Copy link

The previous comments doesn't seem to provide the solution. I'll create a new issue also.

What is the issue number?

@stefanskotte
Copy link

stefanskotte commented Jan 24, 2021

The previous comments doesn't seem to provide the solution. I'll create a new issue also.

What is the issue number?

I just want to chime in here with my two cents - I was getting the same problems, but it was related to not specifying that I was using a guest to checkout:

	$quote->setCustomerFirstname("Guest First Name");
			$quote->setCustomerLastname("Guest Last Name");
			$quote->setCustomerEmail("guest@123.com");
			$quote->setCustomerIsGuest(true);

			// Set billing and shipping addresses
			$quote->getBillingAddress()->addData($orderData['shipping_address']);
			$quote->getShippingAddress()->addData($orderData['shipping_address']);

ref: https://magento.stackexchange.com/questions/248637/how-to-create-guest-order-programmatically-for-guest-user

Maybe this helps someone :)

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Progress: needs update
Projects
None yet
Development

No branches or pull requests