Cancel.php 949 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. *
  4. * Copyright © Magento, Inc. All rights reserved.
  5. * See COPYING.txt for license details.
  6. */
  7. namespace Magento\Paypal\Controller\Hostedpro;
  8. use Magento\Framework\App\Action\Context;
  9. use Magento\Paypal\Helper\Checkout;
  10. class Cancel extends \Magento\Framework\App\Action\Action
  11. {
  12. /**
  13. * @var Checkout
  14. */
  15. private $checkoutHelper;
  16. /**
  17. * @param Context $context
  18. * @param Checkout $checkoutHelper
  19. */
  20. public function __construct(
  21. Context $context,
  22. Checkout $checkoutHelper
  23. ) {
  24. parent::__construct($context);
  25. $this->checkoutHelper = $checkoutHelper;
  26. }
  27. /**
  28. * Customer canceled payment on gateway side.
  29. *
  30. * @return void
  31. */
  32. public function execute()
  33. {
  34. $this->checkoutHelper->cancelCurrentOrder('');
  35. $this->checkoutHelper->restoreQuote();
  36. $this->_redirect('checkout', ['_fragment' => 'payment']);
  37. }
  38. }