- Issue created by @wengerk
- 🇨🇭Switzerland wengerk Lausanne
+++ b/src/Plugin/Commerce/PaymentGateway/PostFinanceCheckout.php @@ -822,6 +825,14 @@ class PostFinanceCheckout extends OffsitePaymentGatewayBase implements PostFinan + // Prevents \Drupal\commerce_payment\EventSubscriber\OrderPaidSubscriber::onPaid + // to place the order on cancellation. + if ($state === 'canceled') { + $order = $order_storage->loadForUpdate($payment->getOrderId()); + $order->state->value = 'canceled'; + $order->save(); + } +
I was unable to find a more effective way to prevent the order from being placed automatically.
In our project, when the payment status was changed to 'canceled,' the system placed the order instead of canceling it, triggering the 'placed' transition and sending out order-related emails and other actions.
Is there a better approach to handle order cancellations without triggering the order placement process?