pagantis /
magento-2X
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Copyright © 2016 Magento. All rights reserved. |
||
| 4 | * See COPYING.txt for license details. |
||
| 5 | */ |
||
| 6 | namespace Pagantis\Pagantis\Gateway\Response; |
||
| 7 | |||
| 8 | use Magento\Payment\Gateway\Data\PaymentDataObjectInterface; |
||
| 9 | use Magento\Payment\Gateway\Response\HandlerInterface; |
||
| 10 | use Magento\Sales\Model\Order\Payment; |
||
| 11 | |||
| 12 | class FraudHandler implements HandlerInterface |
||
| 13 | { |
||
| 14 | const FRAUD_MSG_LIST = 'FRAUD_MSG_LIST'; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Handles fraud messages |
||
| 18 | * |
||
| 19 | * @param array $handlingSubject |
||
| 20 | * @param array $response |
||
| 21 | * @return void |
||
| 22 | */ |
||
| 23 | public function handle(array $handlingSubject, array $response) |
||
| 24 | { |
||
| 25 | if (!isset($response[self::FRAUD_MSG_LIST]) || !is_array($response[self::FRAUD_MSG_LIST])) { |
||
| 26 | return; |
||
| 27 | } |
||
| 28 | |||
| 29 | if (!isset($handlingSubject['payment']) |
||
| 30 | || !$handlingSubject['payment'] instanceof PaymentDataObjectInterface |
||
| 31 | ) { |
||
| 32 | throw new \InvalidArgumentException('Payment data object should be provided'); |
||
| 33 | } |
||
| 34 | |||
| 35 | /** @var PaymentDataObjectInterface $paymentDO */ |
||
| 36 | $paymentDO = $handlingSubject['payment']; |
||
| 37 | $payment = $paymentDO->getPayment(); |
||
| 38 | |||
| 39 | $payment->setAdditionalInformation( |
||
| 40 | self::FRAUD_MSG_LIST, |
||
| 41 | (array)$response[self::FRAUD_MSG_LIST] |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 42 | ); |
||
| 43 | |||
| 44 | /** @var $payment Payment */ |
||
| 45 | $payment->setIsTransactionPending(true); |
||
| 46 | $payment->setIsFraudDetected(true); |
||
| 47 | } |
||
| 48 | } |
||
| 49 |