24 private $responseMock;
29 private $fraudHandler;
34 private $paypalInfoManagerMock;
38 $this->paymentMock = $this->getMockBuilder(\
Magento\
Payment\Model\InfoInterface::class)
40 $this->responseMock = $this->getMockBuilder(\
Magento\Framework\DataObject::class)
41 ->disableOriginalConstructor()
43 $this->paypalInfoManagerMock = $this->getMockBuilder(\
Magento\Paypal\Model\Info::class)
44 ->disableOriginalConstructor()
48 $this->paypalInfoManagerMock,
49 new \
Magento\Framework\Xml\Security()
55 $this->responseMock->expects($this->once())
58 ->willReturn(Payflowpro::STATUS_APPROVED);
60 $this->paypalInfoManagerMock->expects($this->never())
61 ->method(
'importToPayment');
63 $this->fraudHandler->handle($this->paymentMock, $this->responseMock);
71 $this->responseMock->expects($this->atLeastOnce())
81 $this->paymentMock->expects($this->once())
82 ->method(
'getAdditionalInformation')
84 ->willReturn($existingFrauds);
85 $this->paypalInfoManagerMock->expects($this->once())
86 ->method(
'importToPayment')
93 $this->fraudHandler->handle($this->paymentMock, $this->responseMock);
102 [
'Fraud message',
null,
null, [
'RESPMSG' =>
'Fraud message']],
105 '<?xml version="1.0"?>',
106 [
'RESPMSG' =>
'Existing fraud message'],
107 [
'RESPMSG' =>
'Existing fraud message']
111 $this->getRulesXmlString(),
113 'Total Purchase Price Ceiling' =>
'Existing fraud message',
114 'RESPMSG' =>
'Existing fraud message' 117 $this->getRulesExpectedDictionary(),
119 'Total Purchase Price Ceiling' =>
'Existing fraud message',
120 'RESPMSG' =>
'Existing fraud message' 133 private function getRulesXmlString(
$fileName =
'fps_prexmldata.xml')
143 private function getRulesExpectedDictionary()
146 'Total Purchase Price Ceiling' =>
147 'The purchase amount of 7501 is greater than the ceiling value set of 7500',
148 'Total ItemCeiling' =>
149 '16 items were ordered, which is overthe maximum allowed quantity of 15',
150 'Shipping/BillingMismatch' =>
151 'Thebilling and shipping addresses did not match',
152 'BIN Risk List Match' =>
153 'The card number is in a high risk bin list',
154 'Zip Risk List Match' =>
155 'High risk shipping zip',
156 'USPS Address Validation Failure' =>
157 'The billing address is not a valid USAddress' 166 $file =
__DIR__ .
'/_files/xxe-xml.txt';
167 $rulesString = str_replace(
'{file}', $file, $this->getRulesXmlString(
'xxe_fps_prexmldata.xml'));
169 $this->responseMock->expects($this->atLeastOnce())
178 $this->paymentMock->expects($this->once())
179 ->method(
'getAdditionalInformation')
183 'Total Purchase Price Ceiling' =>
'Existing fraud message',
184 'RESPMSG' =>
'Existing fraud message' 188 $this->paypalInfoManagerMock->expects($this->once())
189 ->method(
'importToPayment')
193 'RESPMSG' =>
'Existing fraud message',
194 'Total Purchase Price Ceiling' =>
'Existing fraud message' 199 $this->fraudHandler->handle($this->paymentMock, $this->responseMock);
handleMessagesDataProvider()
defined('TESTS_BP')||define('TESTS_BP' __DIR__
testHandleApprovedTransaction()
const RESPONSE_CODE_FRAUDSERVICE_FILTER
testHandle($message, $rulesString, $existingFrauds, $expectedMessage)