123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- declare(strict_types=1);
- namespace Magento\AuthorizenetAcceptjs\Gateway\Command;
- use Magento\AuthorizenetAcceptjs\Gateway\Config;
- use Magento\AuthorizenetAcceptjs\Gateway\SubjectReader;
- use Magento\Payment\Gateway\Command\CommandPool;
- use Magento\Payment\Gateway\Command\CommandPoolInterface;
- use Magento\Payment\Gateway\CommandInterface;
- use Magento\Payment\Gateway\Response\HandlerInterface;
- /**
- * Syncs the transaction status with authorize.net
- */
- class FetchTransactionInfoCommand implements CommandInterface
- {
- /**
- * @var CommandPool
- */
- private $commandPool;
- /**
- * @var SubjectReader
- */
- private $subjectReader;
- /**
- * @var Config
- */
- private $config;
- /**
- * @var HandlerInterface|null
- */
- private $handler;
- /**
- * @param CommandPoolInterface $commandPool
- * @param SubjectReader $subjectReader
- * @param Config $config
- * @param HandlerInterface|null $handler
- */
- public function __construct(
- CommandPoolInterface $commandPool,
- SubjectReader $subjectReader,
- Config $config,
- HandlerInterface $handler = null
- ) {
- $this->commandPool = $commandPool;
- $this->subjectReader = $subjectReader;
- $this->config = $config;
- $this->handler = $handler;
- }
- /**
- * @inheritdoc
- */
- public function execute(array $commandSubject): array
- {
- $paymentDO = $this->subjectReader->readPayment($commandSubject);
- $order = $paymentDO->getOrder();
- $command = $this->commandPool->get('get_transaction_details');
- $result = $command->execute($commandSubject);
- $response = $result->get();
- if ($this->handler) {
- $this->handler->handle($commandSubject, $response);
- }
- $additionalInformationKeys = $this->config->getTransactionInfoSyncKeys($order->getStoreId());
- $rawDetails = [];
- foreach ($additionalInformationKeys as $key) {
- if (isset($response['transaction'][$key])) {
- $rawDetails[$key] = $response['transaction'][$key];
- }
- }
- return $rawDetails;
- }
- }
|