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

Fix inability to place PayPal guest order when Automatic Assignment to Customer Group is enabled #25405

Conversation

xylodev
Copy link
Member

@xylodev xylodev commented Oct 31, 2019

One of our shops reported that customers are unable to place a guest orders using the PayPal Express payment method. After some investigation it found out that this issue is caused by wiping out the customer email address from the quote model during the automatic assignment to the customer group. Moreover, the inability of placing the order is the case only when the PayPal is triggered from the cart by clicking "Checkout with PayPal" button. When one tries to make a guest order using PayPal in the payment method step in the checkout, the order is placed correctly due to the obvious reason, the e-mail address is explicitly set by the buyer during the 1st step of the checkout and thus it is correctly propagated to the corresponding customer object. This isn't the case when PayPal is started from the cart level.

Description (*)

This PR implements setting an e-mail address on the customer object assigned to quote, which is prepared for the furthr processing by PayPal module when the checkout is recognized as a guest one. The e-mail address is set only when the corresponding customer object doesn't have it set yet.

Fixed Issues (if relevant)

  1. Fixes Unable to place a guest order with PayPal Express when Enable Automatic Assignment to Customer Group is enabled #25399 : Unable to place a guest order with PayPal Express when Enable Automatic Assignment to Customer Group is enabled

Manual testing scenarios (*)

  1. Configure and enable PayPal Express payment method, especially make sure that the button is shown in the cart
  2. In the Magento admin configuration, go to Customers > Customer Configuration and set Enable Automatic Assignment to Customer Group to Yes
  3. Make sure you are NOT logged in to your Magento customer account
  4. Put any product to the cart and go to the cart page
  5. Click "Checkout with PayPal" button, next login to your PayPal account and select payment instrument
  6. Once you are redirected back to the order review page, select a shipping method and click "Place Order" button
  7. The expected result is the order success page and the payment correctly processed by PayPal

Questions or comments

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

This change sets an e-mail address on the customer model assigned to the
guest quote prepared for further processing by PayPal module. It
circumvents inability to place a guest order with PayPal Express when
Automatic Asignment to Customer Group is enabled.

Fixes magento#25399
@m2-assistant
Copy link

m2-assistant bot commented Oct 31, 2019

Hi @xylodev. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.3-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Guide documentation.

@xylodev
Copy link
Member Author

xylodev commented Oct 31, 2019

@magento give me test instance

@magento-engcom-team
Copy link
Contributor

Hi @xylodev. Thank you for your request. I'm working on Magento instance for you

@magento-engcom-team
Copy link
Contributor

Hi @xylodev, here is your new Magento instance.
Admin access: https://pr-25405.instances.magento-community.engineering/admin
Login: admin Password: 123123q

@xylodev
Copy link
Member Author

xylodev commented Oct 31, 2019

I can confirm that the issue is resolved on the provided test instance

@aleron75 aleron75 self-assigned this Nov 5, 2019
@aleron75
Copy link
Contributor

aleron75 commented Nov 5, 2019

Hello @xylodev thank you for your contribution!

Due to Magento Definition of Done all code must be covered by tests.

For this specific case, you should cover your fix by automated tests with the scenario which leads to an issue. Tests should fail on the mainline and pass with your fix.

A starting point could be extending the \Magento\Paypal\Test\Unit\Model\Express\CheckoutTest.

Thank you again!

@aleron75 aleron75 added the Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests label Nov 6, 2019
@sidolov sidolov changed the base branch from 2.3-develop to 2.4-develop December 5, 2019 17:16
@askmikeyd
Copy link

I was having the same issue and I don't think the proposed solution is the way to go. This only solves it for Paypal but this issue exists when using other payment methods as a guest. A better solution needs to be done in the Magento Core. My fix for it was to set "Enable Automatic Assignment to Customer Group" to "Yes" at the website level as that is where my customer is created and set it to "No" at the store level which is what is checked when placing a guest order.

@sidolov sidolov added Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Severity: S2 Major restrictions or short-term circumventions are required until a fix is available. labels Aug 18, 2020
@sidolov
Copy link
Contributor

sidolov commented Aug 19, 2020

@xylodev do you have plans to cover another checkout scenario? Looks like the issue is fixed for PayPal only.

@xylodev
Copy link
Member Author

xylodev commented Aug 20, 2020

@sidolov I will review this issue next week and, depending on the review outcome, I will try to provide more general fix with the test coverage

Copy link
Contributor

@sidolov sidolov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Waiting for additional coverage of all scenarios.

@engcom-Charlie
Copy link
Contributor

@magento run all tests

@magento-engcom-team
Copy link
Contributor

Hi @gabrieldagama, thank you for the review.
ENGCOM-8173 has been created to process this Pull Request

@engcom-Alfa
Copy link
Contributor

@magento give me test instance

@magento-deployment-service
Copy link

Hi @engcom-Alfa. Thank you for your request. I'm working on Magento instance for you.

@magento-deployment-service
Copy link

@engcom-Alfa
Copy link
Contributor

✔️ QA Passed

Manual testing scenario:

  1. Configure and enable PayPal Express payment method, especially make sure that the button is shown in the cart;
  2. In the Magento admin configuration, go to Customers > Customer Configuration and set Enable Automatic Assignment to Customer Group to Yes;
  3. Make sure you are NOT logged in to your Magento customer account;
  4. Put any product to the cart and go to the cart page;
  5. Click the "Checkout with PayPal" button, next login to your PayPal account, and select payment instrument;
  6. Once you are redirected back to the order review page, select a shipping method and click the "Place Order" button;

Before: ✖️ The payment is processed successfully on PayPal gateway, but the order is not created in Magento because of "Failed address validation: %1" error

Screenshot from 2020-09-15 15-16-38

After: ✔️ The payment correctly processed by PayPal and the order is successfully created

Screenshot from 2020-09-15 15-11-37

Also, was tested with disabled Automatic Assignment to Customer Group, placing an order from payment method step, from the cart page and everything works as expected.

@m2-assistant
Copy link

m2-assistant bot commented Sep 18, 2020

Hi @xylodev, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests Component: Quote Partner: creativestyle partners-contribution Pull Request is created by Magento Partner Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: accept QA: Added to Regression Scope Scenario was analysed and added to Regression Testing Scope Release Line: 2.4 Severity: S2 Major restrictions or short-term circumventions are required until a fix is available.
Projects
Archived in project
9 participants