CheckoutFlowBase::onStepChange should not blindly place the order

Created on 7 January 2025, 3 months ago

I've noticed CheckoutFlowBase::onStepChange immediately places the order
$order->getState()->applyTransitionById('place');
as long as the requested step is complete without doing any verification whatsoever

I've also noticed that OrderPaidSubscriber::onPaid is also able to place the order
$order->getState()->applyTransitionById('place');
but this time is only does it if the event ORDER_PAID (commerce_order.order.paid) is dispatched by OrderStorage::doOrderPreSave after it made sure the order had been fully paid.

I believe CheckoutFlowBase::onStepChange should not blindly place the order anymore. We should let OrderStorage::doOrderPreSave and OrderPaidSubscriber::onPaid do it once the order has been fully paid.

This also means that the checkout complete step should be able to handle the case where the complete step has been asked for but for some reason the order is not completed yet.

Here is an example of a situation where the order would not be completed yet once reaching the complete step: as explained here 🐛 Make sure the price of a locked order is never updated especially when a promotion expires. Active , as of right now, it is possible for the order total to be updated while the customer is validating an offsite payment, although the order is locked. Leading to an order total not being the paid amount. So in this case OrderStorage::doOrderPreSave would not dispatch the ORDER_PAID and the order would not have been placed yet.

📌 Task
Status

Active

Version

2.40

Component

Checkout

Created by

🇫🇷France nicolas bouteille

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @nicolas bouteille
  • 🇮🇱Israel jsacksick

    Hm... Not really sure what you're suggesting here... The reason we have different events for "order paid in full", checkout completion / place is to let you react differently to those.

    If you want to fulfill an order until it has been paid, you should do so and not fulfill the order if the order is just placed. Also, the order should not be placed because the "complete" step is requested. This isn't really how it works?

  • 🇫🇷France nicolas bouteille

    Thank you for your feedback, unfortunately I am not able to fully understand your answer and your position so I am not able to further respond :/

  • 🇮🇱Israel jsacksick

    Since there is no patch to review and not exactly a clear ask here, closing this as "won't fix".

Production build 0.71.5 2024