Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
RiskDataHandler.php
Go to the documentation of this file.
1 <?php
7 
11 
16 {
20  const RISK_DATA_ID = 'riskDataId';
21 
25  const RISK_DATA_DECISION = 'riskDataDecision';
26 
30  private static $statusReview = 'Review';
31 
35  private $subjectReader;
36 
42  public function __construct(SubjectReader $subjectReader)
43  {
44  $this->subjectReader = $subjectReader;
45  }
46 
54  public function handle(array $handlingSubject, array $response)
55  {
56  $paymentDO = $this->subjectReader->readPayment($handlingSubject);
57 
59  $transaction = $this->subjectReader->readTransaction($response);
60 
61  if (!isset($transaction->riskData)) {
62  return;
63  }
64 
65  $payment = $paymentDO->getPayment();
67 
68  $payment->setAdditionalInformation(self::RISK_DATA_ID, $transaction->riskData->id);
69  $payment->setAdditionalInformation(self::RISK_DATA_DECISION, $transaction->riskData->decision);
70 
71  // mark payment as fraud
72  if ($transaction->riskData->decision === self::$statusReview) {
73  $payment->setIsFraudDetected(true);
74  }
75  }
76 }
$transaction
$response
Definition: 404.php:11
handle(array $handlingSubject, array $response)
$payment
Definition: order.php:17
static assertOrderPayment(InfoInterface $paymentInfo)