From c92995b6deb1c4b1c0d5b3a39d34969d63e2dab2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89bano=20Lopes?= Date: Thu, 26 Jan 2023 18:50:28 +0000 Subject: [PATCH] 5.3.0: Webhook pre_auth validation. Fix on pre_auth case creation. Fix on purchase observer. --- Controller/Webhooks/Index.php | 2 +- Observer/PreAuth.php | 6 +----- Observer/Purchase.php | 6 ++++++ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Controller/Webhooks/Index.php b/Controller/Webhooks/Index.php index c23b09e6..0cae9054 100644 --- a/Controller/Webhooks/Index.php +++ b/Controller/Webhooks/Index.php @@ -240,7 +240,7 @@ public function processRequest($request, $hash, $topic) ) { $httpCode = Http::STATUS_CODE_400; throw new LocalizedException(__("Case {$caseId} it is not ready to be updated")); - } elseif ($case->getMagentoStatus() == Casedata::PRE_AUTH) { + } elseif ($case->getPolicyName() === Casedata::PRE_AUTH) { $httpCode = Http::STATUS_CODE_200; throw new LocalizedException( __("Case {$caseId} already completed by synchronous response, no action will be taken") diff --git a/Observer/PreAuth.php b/Observer/PreAuth.php index 73befd9c..2ad87574 100644 --- a/Observer/PreAuth.php +++ b/Observer/PreAuth.php @@ -287,11 +287,7 @@ public function execute(Observer $observer) $case->setCheckoutToken($caseFromQuote['checkoutId']); $case->setQuoteId($quote->getId()); $case->setOrderIncrement($quote->getReservedOrderId()); - $entries = $case->getEntriesText(); - - if (isset($entries) === false) { - $case->setEntriesText(""); - } + $case->setEntriesText(""); if (isset($caseResponse->scaEvaluation)) { $case->setEntries( diff --git a/Observer/Purchase.php b/Observer/Purchase.php index 230a195b..665b94a5 100644 --- a/Observer/Purchase.php +++ b/Observer/Purchase.php @@ -256,6 +256,12 @@ public function execute(Observer $observer, $checkOwnEventsMethods = true) if ($case->isEmpty()) { $this->casedataResourceModel->load($case, $order->getQuoteId(), 'quote_id'); + + if (empty($case->getData('order_id')) === false && + $case->getData('order_id') !== $order->getId()) { + $case = $this->casedataFactory->create(); + } + $recipient = $this->purchaseHelper->makeRecipient($order); $recipientJson = $this->jsonSerializer->serialize($recipient); $hashToValidateReroute = sha1($recipientJson);