diff --git a/config/packages/test/config.yaml b/config/packages/test/config.yaml index 0f4384efc0..c2d9787dff 100755 --- a/config/packages/test/config.yaml +++ b/config/packages/test/config.yaml @@ -26,6 +26,7 @@ framework: handler_id: ~ storage_id: session.storage.mock_file name: MOCKSESSID + gc_probability: null messenger: transports: coreshop_index: 'sync://' diff --git a/src/CoreShop/Bundle/FrontendBundle/Controller/CheckoutController.php b/src/CoreShop/Bundle/FrontendBundle/Controller/CheckoutController.php index 40ae9ec3c6..dbe01b40ed 100644 --- a/src/CoreShop/Bundle/FrontendBundle/Controller/CheckoutController.php +++ b/src/CoreShop/Bundle/FrontendBundle/Controller/CheckoutController.php @@ -211,6 +211,22 @@ public function doCheckoutAction(Request $request): Response $workflow->apply($order, OrderSaleTransitions::TRANSITION_ORDER); + $event = new CheckoutEvent($this->getCart(), ['order' => $order]); + + $this->get('event_dispatcher')->dispatch($event, CheckoutEvents::CHECKOUT_PAYMENT_PRE); + + if ($event->isStopped()) { + $this->addEventFlash($event->getMessageType(), $event->getMessage(), $event->getMessageParameters()); + + if ($event->hasResponse()) { + return $event->getResponse(); + } + } + + if ($event->hasResponse()) { + return $event->getResponse(); + } + $response = $this->redirectToRoute('coreshop_payment', ['order' => $order->getId()]); if (0 === $order->getTotal()) { diff --git a/src/CoreShop/Component/Order/CheckoutEvents.php b/src/CoreShop/Component/Order/CheckoutEvents.php index 15a0cf76b4..22c87a6617 100644 --- a/src/CoreShop/Component/Order/CheckoutEvents.php +++ b/src/CoreShop/Component/Order/CheckoutEvents.php @@ -27,4 +27,6 @@ class CheckoutEvents public const CHECKOUT_DO_PRE = 'coreshop.checkout.do.pre'; public const CHECKOUT_DO_POST = 'coreshop.checkout.do.post'; + + public const CHECKOUT_PAYMENT_PRE = 'coreshop.checkout.payment.pre'; }