1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?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;
}
}