SuccessValidator.php 958 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Checkout\Model\Session;
  7. /**
  8. * Test if checkout session valid for success action
  9. *
  10. * @api
  11. * @since 100.0.2
  12. */
  13. class SuccessValidator
  14. {
  15. /**
  16. * @var \Magento\Checkout\Model\Session
  17. */
  18. protected $checkoutSession;
  19. /**
  20. * @param \Magento\Checkout\Model\Session $checkoutSession
  21. * @codeCoverageIgnore
  22. */
  23. public function __construct(
  24. \Magento\Checkout\Model\Session $checkoutSession
  25. ) {
  26. $this->checkoutSession = $checkoutSession;
  27. }
  28. /**
  29. * @return bool
  30. */
  31. public function isValid()
  32. {
  33. if (!$this->checkoutSession->getLastSuccessQuoteId()) {
  34. return false;
  35. }
  36. if (!$this->checkoutSession->getLastQuoteId() || !$this->checkoutSession->getLastOrderId()) {
  37. return false;
  38. }
  39. return true;
  40. }
  41. }