Skip to content

Commit

Permalink
Mark order payment as canceled upon exceptional Adyen API response
Browse files Browse the repository at this point in the history
ISSUE: CS-3178
  • Loading branch information
goran-stamenkovski-logeecom committed May 25, 2022
1 parent b2e280b commit f77edd8
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions Controllers/Frontend/Adyen.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ public function ajaxDoPaymentAction(): void
'content' => $ex->getMessage(),
]
));

$this->basketService->cancelAndRestoreByOrderNumber($context->getOrder()->getNumber());
}
}

Expand Down Expand Up @@ -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);
}
}

/**
Expand Down

0 comments on commit f77edd8

Please sign in to comment.