Success.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Checkout\Controller\Onepage;
  7. use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
  8. /**
  9. * Onepage checkout success controller class
  10. */
  11. class Success extends \Magento\Checkout\Controller\Onepage implements HttpGetActionInterface
  12. {
  13. /**
  14. * Order success action
  15. *
  16. * @return \Magento\Framework\Controller\ResultInterface
  17. */
  18. public function execute()
  19. {
  20. $session = $this->getOnepage()->getCheckout();
  21. if (!$this->_objectManager->get(\Magento\Checkout\Model\Session\SuccessValidator::class)->isValid()) {
  22. return $this->resultRedirectFactory->create()->setPath('checkout/cart');
  23. }
  24. $session->clearQuote();
  25. //@todo: Refactor it to match CQRS
  26. $resultPage = $this->resultPageFactory->create();
  27. $this->_eventManager->dispatch(
  28. 'checkout_onepage_controller_success_action',
  29. [
  30. 'order_ids' => [$session->getLastOrderId()],
  31. 'order' => $session->getLastRealOrder()
  32. ]
  33. );
  34. return $resultPage;
  35. }
  36. }