Skip to content

Commit

Permalink
Merge pull request #2177 from dpfaffenbauer/pre_payment_checkout
Browse files Browse the repository at this point in the history
[Checkout] add pre-payment event
  • Loading branch information
dpfaffenbauer authored Jan 16, 2023
2 parents 216db9b + cd11ef7 commit 85f9565
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/packages/test/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ framework:
handler_id: ~
storage_id: session.storage.mock_file
name: MOCKSESSID
gc_probability: null
messenger:
transports:
coreshop_index: 'sync://'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
2 changes: 2 additions & 0 deletions src/CoreShop/Component/Order/CheckoutEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

0 comments on commit 85f9565

Please sign in to comment.