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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
/**
*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\Authorizenet\Controller\Directpost\Payment;
use Magento\Authorizenet\Helper\DataFactory;
use Magento\Authorizenet\Model\Directpost;
use Magento\Authorizenet\Model\DirectpostFactory;
use Magento\Framework\App\Action\Context;
use Magento\Framework\App\CsrfAwareActionInterface;
use Magento\Framework\App\Request\InvalidRequestException;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Controller\ResultFactory;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Registry;
use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Framework\App\Action\HttpPostActionInterface;
use Psr\Log\LoggerInterface;
/**
* Class BackendResponse
* @deprecated 100.3.1 Authorize.net is removing all support for this payment method
*/
class BackendResponse extends \Magento\Authorizenet\Controller\Directpost\Payment implements
CsrfAwareActionInterface,
HttpGetActionInterface,
HttpPostActionInterface
{
/**
* @var LoggerInterface
*/
private $logger;
/**
* @var DirectpostFactory
*/
private $directpostFactory;
/**
* BackendResponse constructor.
*
* @param Context $context
* @param Registry $coreRegistry
* @param DataFactory $dataFactory
* @param DirectpostFactory $directpostFactory
* @param LoggerInterface|null $logger
*/
public function __construct(
Context $context,
Registry $coreRegistry,
DataFactory $dataFactory,
DirectpostFactory $directpostFactory,
LoggerInterface $logger = null
) {
parent::__construct($context, $coreRegistry, $dataFactory);
$this->directpostFactory = $directpostFactory ?: $this->_objectManager->create(DirectpostFactory::class);
$this->logger = $logger ?: $this->_objectManager->get(LoggerInterface::class);
}
/**
* @inheritDoc
*/
public function createCsrfValidationException(
RequestInterface $request
): ?InvalidRequestException {
return null;
}
/**
* @inheritDoc
*/
public function validateForCsrf(RequestInterface $request): ?bool
{
return true;
}
/**
* Response action.
*
* Action for Authorize.net SIM Relay Request.
*
* @return \Magento\Framework\Controller\ResultInterface
*/
public function execute()
{
$data = $this->getRequest()->getParams();
/** @var Directpost $paymentMethod */
$paymentMethod = $this->directpostFactory->create();
if (!empty($data['store_id'])) {
$paymentMethod->setStore($data['store_id']);
}
$paymentMethod->setResponseData($data);
try {
$paymentMethod->validateResponse();
} catch (LocalizedException $e) {
$this->logger->critical($e->getMessage());
return $this->_redirect('noroute');
}
$this->_responseAction('adminhtml');
return $this->resultFactory->create(ResultFactory::TYPE_PAGE);
}
}