Skip to content

Commit 42adb91

Browse files
authored
Changes in CheckoutConfirmPage hook (#45)
1 parent 239ea6a commit 42adb91

File tree

1 file changed

+30
-10
lines changed

1 file changed

+30
-10
lines changed

frontend/hooks/CheckoutConfirmPage.php

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,38 @@ class CheckoutConfirmPage
99
{
1010
public function execute(): void
1111
{
12-
if (isset($_SESSION['Zahlungsart']) && $_SESSION['Zahlungsart']->cAnbieter == 'Mondu') {
13-
if (isset($GLOBALS['step']) && $GLOBALS['step'] == 'Bestaetigung') {
14-
if (!isset($_SESSION['monduOrderUuid']) || empty($_SESSION['monduOrderUuid']) || $_GET['payment'] != 'accepted') {
15-
$orderService = new OrderService();
16-
$orderData = $orderService->token($_SESSION['Zahlungsart']->cModulId);
17-
18-
header('Location: ' . $orderData['hosted_checkout_url'], true, 303);
19-
exit;
20-
}
21-
}
12+
if (!$this->isMonduPayment() || !$this->isConfirmStep()) return;
13+
14+
if ($_GET['payment'] !== 'accepted' && $_SERVER['REQUEST_METHOD'] === 'GET') {
15+
header('Location: ' . Shop::Container()->getLinkService()->getStaticRoute('bestellvorgang.php') . '?editZahlungsart=1');
16+
}
17+
18+
if ($_GET['payment'] == 'accepted' || !$this->isMonduOrderSessionMissing()) return;
19+
20+
if ($_GET['monduCreateOrder'] !== 'true') {
21+
header('Location: ' . Shop::Container()->getLinkService()->getStaticRoute('bestellvorgang.php') . '?monduCreateOrder=true');
22+
exit;
23+
}
24+
25+
if ($_GET['monduCreateOrder'] === 'true') {
26+
$orderService = new OrderService();
27+
$orderData = $orderService->token($_SESSION['Zahlungsart']->cModulId);
28+
header('Location: ' . $orderData['hosted_checkout_url'], true, 303);
29+
exit;
2230
}
2331
}
32+
33+
protected function isMonduPayment() {
34+
return isset($_SESSION['Zahlungsart']) && $_SESSION['Zahlungsart']->cAnbieter == 'Mondu';
35+
}
36+
37+
protected function isConfirmStep() {
38+
return isset($GLOBALS['step']) && $GLOBALS['step'] == 'Bestaetigung';
39+
}
40+
41+
protected function isMonduOrderSessionMissing() {
42+
return !isset($_SESSION['monduOrderUuid']) || empty($_SESSION['monduOrderUuid']);
43+
}
2444
}
2545

2646
$hook = new CheckoutConfirmPage();

0 commit comments

Comments
 (0)