Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/MAG-806' into v5.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ebanolopes committed Jan 12, 2023
2 parents e65d676 + e5d2b4b commit d632ab2
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions Observer/PreAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Signifyd\Connect\Observer;

use Magento\Framework\Event\ManagerInterface as EventManager;
use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\Exception\LocalizedException;
Expand Down Expand Up @@ -95,11 +94,6 @@ class PreAuth implements ObserverInterface
*/
protected $objectManagerInterface;

/**
* @var EventManager
*/
protected $eventManager;

/**
* PreAuth constructor.
* @param Logger $logger
Expand All @@ -116,7 +110,6 @@ class PreAuth implements ObserverInterface
* @param JsonSerializer $jsonSerializer
* @param ConfigHelper $configHelper
* @param ObjectManagerInterface $objectManagerInterface
* @param EventManager $eventManager
*/
public function __construct(
Logger $logger,
Expand All @@ -132,8 +125,7 @@ public function __construct(
RequestHttp $requestHttp,
JsonSerializer $jsonSerializer,
ConfigHelper $configHelper,
ObjectManagerInterface $objectManagerInterface,
EventManager $eventManager
ObjectManagerInterface $objectManagerInterface
) {
$this->logger = $logger;
$this->purchaseHelper = $purchaseHelper;
Expand All @@ -149,7 +141,6 @@ public function __construct(
$this->jsonSerializer = $jsonSerializer;
$this->configHelper = $configHelper;
$this->objectManagerInterface = $objectManagerInterface;
$this->eventManager = $eventManager;
}

public function execute(Observer $observer)
Expand Down Expand Up @@ -327,17 +318,22 @@ public function execute(Observer $observer)
return;
}

$stopCheckoutProcess = isset($caseResponse) &&
is_object($caseResponse) &&
$caseAction == 'REJECT';

$this->eventManager->dispatch('signifyd_pre_auth_result', [
'case' => $caseResponse,
'stop_checkout_process' => $stopCheckoutProcess
]);
$stopCheckoutProcess = $this->getStopCheckoutProcess($caseResponse, $caseAction);

if ($stopCheckoutProcess) {
throw new LocalizedException(__($policyRejectMessage));
}
}

/**
* @param $caseResponse
* @param $caseAction
* @return bool
*/
public function getStopCheckoutProcess($caseResponse, $caseAction)
{
return isset($caseResponse) &&
is_object($caseResponse) &&
$caseAction == 'REJECT';
}
}

0 comments on commit d632ab2

Please sign in to comment.