31 $httpClientFactoryMock = $this->getHttpClientFactoryMock();
33 $this->authorizenetMock = $this->getMockBuilder(\
Magento\Authorizenet\Model\Directpost::class)
34 ->disableOriginalConstructor()
37 $this->authorizenetMock->method(
'getConfigData')
39 [
'login',
'test login'],
40 [
'trans_key',
'test key'],
41 [
'cgi_url_td',
'https://apitest.authorize.net/xml/v1/request.api']
45 $xmlSecurity = $objectManagerHelper->getObject(\
Magento\Framework\Xml\Security::class);
46 $this->transactionService = $objectManagerHelper->getObject(
47 \
Magento\Authorizenet\Model\TransactionService::class,
49 'xmlSecurityHelper' => $xmlSecurity,
50 'httpClientFactory' => $httpClientFactoryMock
67 $document = $this->getResponseBody(
74 $this->httpClientMock->expects(static::once())
76 ->willReturn($document);
78 $result = $this->transactionService->getTransactionDetails($this->authorizenetMock, $transactionId);
80 static::assertEquals($responseCode, (
string)
$result->transaction->responseCode);
81 static::assertEquals($responseCode, (
string)
$result->transaction->responseReasonCode);
82 static::assertEquals($responseStatus, (
string)
$result->transaction->transactionStatus);
93 'transactionId' =>
'9941997799',
94 'resultStatus' =>
'Successful.',
95 'responseStatus' =>
'voided',
105 private function getHttpClientFactoryMock()
107 $this->httpClientMock = $this->getMockBuilder(\
Magento\Framework\HTTP\ZendClient::class)
108 ->disableOriginalConstructor()
109 ->setMethods([
'request',
'getBody',
'__wakeup'])
112 $this->httpClientMock->expects(static::once())
116 $httpClientFactoryMock = $this->getMockBuilder(\
Magento\Framework\HTTP\ZendClientFactory::class)
117 ->disableOriginalConstructor()
118 ->setMethods([
'create'])
121 $httpClientFactoryMock->expects(static::once())
123 ->willReturn($this->httpClientMock);
124 return $httpClientFactoryMock;
136 private function getResponseBody($transactionId, $resultCode, $resultStatus, $responseStatus, $responseCode)
139 '<?xml version="1.0" encoding="utf-8"?> 140 <getTransactionDetailsResponse 141 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 142 xmlns:xsd="http://www.w3.org/2001/XMLSchema" 143 xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"> 145 <resultCode>%s</resultCode> 152 <transId>%s</transId> 153 <transactionType>authOnlyTransaction</transactionType> 154 <transactionStatus>%s</transactionStatus> 155 <responseCode>%s</responseCode> 156 <responseReasonCode>%s</responseReasonCode> 158 </getTransactionDetailsResponse>',
const PAYMENT_UPDATE_STATUS_CODE_SUCCESS
dataProviderTransaction()
testLoadVoidedTransactionDetails($transactionId, $resultStatus, $responseStatus, $responseCode)