CloseTransactionHandler.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. declare(strict_types=1);
  7. namespace Magento\AuthorizenetAcceptjs\Gateway\Response;
  8. use Magento\AuthorizenetAcceptjs\Gateway\SubjectReader;
  9. use Magento\Payment\Gateway\Response\HandlerInterface;
  10. use Magento\Sales\Model\Order\Payment;
  11. /**
  12. * Processes payment information from a void transaction response
  13. */
  14. class CloseTransactionHandler implements HandlerInterface
  15. {
  16. /**
  17. * @var SubjectReader
  18. */
  19. private $subjectReader;
  20. /**
  21. * @param SubjectReader $subjectReader
  22. */
  23. public function __construct(SubjectReader $subjectReader)
  24. {
  25. $this->subjectReader = $subjectReader;
  26. }
  27. /**
  28. * @inheritdoc
  29. */
  30. public function handle(array $handlingSubject, array $response): void
  31. {
  32. $paymentDO = $this->subjectReader->readPayment($handlingSubject);
  33. $payment = $paymentDO->getPayment();
  34. if ($payment instanceof Payment) {
  35. $payment->setIsTransactionClosed(true);
  36. $payment->setShouldCloseParentTransaction(true);
  37. }
  38. }
  39. }