diff --git a/Controllers/Frontend/Adyen.php b/Controllers/Frontend/Adyen.php index edbdf049..bb70223e 100644 --- a/Controllers/Frontend/Adyen.php +++ b/Controllers/Frontend/Adyen.php @@ -77,6 +77,8 @@ public function ajaxDoPaymentAction(): void 'content' => $ex->getMessage(), ] )); + + $this->basketService->cancelAndRestoreByOrderNumber($context->getOrder()->getNumber()); } } @@ -230,11 +232,21 @@ private function getShopperInfo(): array */ private function handlePaymentData($paymentInfo): void { - if (PaymentResultCode::exists((string) ($paymentInfo['resultCode'] ?? ''))) { + $rawResultCode = (string) ($paymentInfo['resultCode'] ?? ''); + if (!PaymentResultCode::exists($rawResultCode)) { + $this->handlePaymentDataError($paymentInfo); return; } - $this->handlePaymentDataError($paymentInfo); + $resultCode = PaymentResultCode::load((string) ($paymentInfo['resultCode'] ?? '')); + if ( + !$resultCode->equals(PaymentResultCode::authorised()) && + !$resultCode->equals(PaymentResultCode::identifyShopper()) && + !$resultCode->equals(PaymentResultCode::challengeShopper()) && + !$resultCode->equals(PaymentResultCode::redirectShopper()) + ) { + $this->handlePaymentDataError($paymentInfo); + } } /**