Review.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. *
  4. * Copyright © Magento, Inc. All rights reserved.
  5. * See COPYING.txt for license details.
  6. */
  7. namespace Magento\Paypal\Controller\Express\AbstractExpress;
  8. use Magento\Framework\Controller\ResultFactory;
  9. class Review extends \Magento\Paypal\Controller\Express\AbstractExpress
  10. {
  11. /**
  12. * Review order after returning from PayPal
  13. *
  14. * @return void|\Magento\Framework\Controller\Result\Redirect
  15. */
  16. public function execute()
  17. {
  18. try {
  19. $this->_initCheckout();
  20. $this->_checkout->prepareOrderReview($this->_initToken());
  21. $this->_view->loadLayout();
  22. $reviewBlock = $this->_view->getLayout()->getBlock('paypal.express.review');
  23. $reviewBlock->setQuote($this->_getQuote());
  24. $reviewBlock->getChildBlock('details')->setQuote($this->_getQuote());
  25. if ($reviewBlock->getChildBlock('shipping_method')) {
  26. $reviewBlock->getChildBlock('shipping_method')->setQuote($this->_getQuote());
  27. }
  28. $this->_view->renderLayout();
  29. return;
  30. } catch (\Magento\Framework\Exception\LocalizedException $e) {
  31. $this->messageManager->addExceptionMessage(
  32. $e,
  33. $e->getMessage()
  34. );
  35. } catch (\Exception $e) {
  36. $this->messageManager->addExceptionMessage(
  37. $e,
  38. __('We can\'t initialize Express Checkout review.')
  39. );
  40. }
  41. /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
  42. $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
  43. return $resultRedirect->setPath('checkout/cart');
  44. }
  45. }