6
6
namespace Magento \Authorizenet \Model ;
7
7
8
8
use Magento \Authorizenet \Model \TransactionService ;
9
+ use Magento \Framework \HTTP \ZendClientFactory ;
9
10
10
11
/**
11
12
* @SuppressWarnings(PHPMD.TooManyFields)
@@ -97,6 +98,11 @@ abstract class Authorizenet extends \Magento\Payment\Model\Method\Cc
97
98
*/
98
99
protected $ _debugReplacePrivateDataKeys = ['merchantAuthentication ' , 'x_login ' ];
99
100
101
+ /**
102
+ * @var \Magento\Framework\HTTP\ZendClientFactory
103
+ */
104
+ protected $ httpClientFactory ;
105
+
100
106
/**
101
107
* @param \Magento\Framework\Model\Context $context
102
108
* @param \Magento\Framework\Registry $registry
@@ -111,6 +117,7 @@ abstract class Authorizenet extends \Magento\Payment\Model\Method\Cc
111
117
* @param \Magento\Authorizenet\Model\Request\Factory $requestFactory
112
118
* @param \Magento\Authorizenet\Model\Response\Factory $responseFactory
113
119
* @param \Magento\Authorizenet\Model\TransactionService $transactionService
120
+ * @param \Magento\Framework\HTTP\ZendClientFactory $httpClientFactory
114
121
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
115
122
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
116
123
* @param array $data
@@ -130,6 +137,7 @@ public function __construct(
130
137
\Magento \Authorizenet \Model \Request \Factory $ requestFactory ,
131
138
\Magento \Authorizenet \Model \Response \Factory $ responseFactory ,
132
139
TransactionService $ transactionService ,
140
+ ZendClientFactory $ httpClientFactory ,
133
141
\Magento \Framework \Model \ResourceModel \AbstractResource $ resource = null ,
134
142
\Magento \Framework \Data \Collection \AbstractDb $ resourceCollection = null ,
135
143
array $ data = []
@@ -138,6 +146,7 @@ public function __construct(
138
146
$ this ->requestFactory = $ requestFactory ;
139
147
$ this ->responseFactory = $ responseFactory ;
140
148
$ this ->transactionService = $ transactionService ;
149
+ $ this ->httpClientFactory = $ httpClientFactory ;
141
150
142
151
parent ::__construct (
143
152
$ context ,
@@ -370,7 +379,8 @@ protected function buildRequest(\Magento\Framework\DataObject $payment)
370
379
protected function postRequest (\Magento \Authorizenet \Model \Request $ request )
371
380
{
372
381
$ result = $ this ->responseFactory ->create ();
373
- $ client = new \Magento \Framework \HTTP \ZendClient ();
382
+ /** @var \Magento\Framework\HTTP\ZendClient $client */
383
+ $ client = $ this ->httpClientFactory ->create ();
374
384
$ url = $ this ->getConfigData ('cgi_url ' ) ?: self ::CGI_URL ;
375
385
$ debugData = ['url ' => $ url , 'request ' => $ request ->getData ()];
376
386
$ client ->setUri ($ url );
0 commit comments