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

Magento PayPal checkout fails if email sending fails / other payment does not #13133

Merged
merged 2 commits into from
Aug 14, 2018

Conversation

driskell
Copy link
Contributor

Description

If PayPal checkout is used and, for whatever reason, the email sender throws an exception (maybe third-party integration fails to send), the PayPal order is still placed but the user is shown Something went wrong message and ends up in review page.

This is in contrast to a cash payment or other payment method where the order is placed successfully.

This is because other payment methods run through this checkout, that wraps orderSender in a try/catch:
https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/Checkout/Model/Type/Onepage.php#L731

This PR replicates that try/catch for PayPal.

Manual testing scenarios

  1. Edit OrderSender to throw an Exception to simulate failed integration email send
  2. Checkout with PayPal
  3. Order is created but you are sent with error to review page
  4. Do same with cash checkout
  5. Order is successful

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 on Travis CI are green)

@orlangur orlangur self-assigned this Jan 12, 2018
@orlangur orlangur added this to the January 2018 milestone Jan 12, 2018
@@ -809,7 +809,11 @@ public function place($token, $shippingMethodCode = null)
case \Magento\Sales\Model\Order::STATE_PROCESSING:
case \Magento\Sales\Model\Order::STATE_COMPLETE:
case \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW:
$this->orderSender->send($order);
try {
$this->orderSender->send($order);
Copy link
Contributor

Choose a reason for hiding this comment

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

Code changes look good to me 👍

Please cover new logic with unit test, make an orderSender mock so that send is throwing exception and then assert exception was logged.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@orlangur I tried to start doing this but it looks like it is not as simple as I thought. No tests exist for the placeOrder at this time so I'd need a quote management mock, an order mock as it returns an order, and then the order sender mock, and I'm not willing to commit so much time to learn all that and learn how to run individual tests.

If you can provide an existing test for placeOrder I'd likely be able to commit the time to build on it. But at the moment it's not something I'd be willing to proceed with further.

@magento-cicd2
Copy link
Contributor

magento-cicd2 commented Aug 7, 2018

CLA assistant check
All committers have signed the CLA.

@sidolov
Copy link
Contributor

sidolov commented Aug 7, 2018

Hi @driskell , please, sign CLA, otherwise, we can't process your pull request

@driskell
Copy link
Contributor Author

driskell commented Aug 7, 2018

Done!

@magento-engcom-team
Copy link
Contributor

@driskell thank you for contributing. Please accept Community Contributors team invitation here to gain extended permissions for this repository.

@driskell
Copy link
Contributor Author

driskell commented Aug 8, 2018

Thanks!

@magento-engcom-team magento-engcom-team merged commit 0770db2 into magento:2.2-develop Aug 14, 2018
magento-engcom-team pushed a commit that referenced this pull request Aug 14, 2018
@magento-engcom-team
Copy link
Contributor

Hi @driskell. Thank you for your contribution.
We will aim to release these changes as part of 2.2.7.
Please check the release notes for final confirmation.

Please, consider to port this solution to 2.3 release line.
You may use Porting tool to port commits automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants