Skip to content

Commit

Permalink
5.3.0: Webhook pre_auth validation.
Browse files Browse the repository at this point in the history
Fix on pre_auth case creation.
Fix on purchase observer.
  • Loading branch information
ebanolopes committed Jan 26, 2023
1 parent d632ab2 commit c92995b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Controller/Webhooks/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 1 addition & 5 deletions Observer/PreAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 6 additions & 0 deletions Observer/Purchase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c92995b

Please sign in to comment.