Take the community feedback survey now.

Asynchronous Payment Flow Best Practices

Vote:
 

Sorry for the long post, but got a "fun" problem to solve:

Our client uses CMS 12 / Commerce Connect 14 + Adyen payments (via the drop-in component).

As it stands:

  • user adds products to their cart, checks out either as authenticated user or guest, enters shipping details, etc.
  • at the payment step we setup the Adyen drop-in and await onPaymentCompleted.
  • if successful, onPaymentCompleted makes a call to convert the cart to a purchase order (status = InProgress)
  • in the background, Adyen sends a webhook to confirm the authorisation, which if successful, we use to send the order onto downstream systems.

The original problem:

  • Some payment methods are weird: for example, onlinebanking_pl intermittently dumps users who have successfully paid on an external "pending" page, and the user never returns to the site (and therefore onPaymentCompleted is not called).
    • When it does "work", it occasionally waits 10+ minutes before redirecting the user back.
  • Adyen Support said this is expected behaviour and the definitive event that places an order should be the webhook.

Work done so far:

  • Refactored the webhook so that rather than waiting for the cart to become an order, it now places the order.
  • Refactored the checkout process so that it just calls Adyen then assuming no immediate rejection, redirects to the confirmation screen in a "pending" state.
  • This works pretty well.

The problem I need to solve is:

  • In the time between the user clicking pay and the webhook arriving, the cart is still a cart and can therefore be modified - for obvious reasons, this is bad™
  • I could:
    • Implement some status or flag on the cart that prevents modification in this state, but:
      • in the event of failure, or the user just abandoning the checkout, the cart needs to be unlocked somehow.
      • would potentially need UI changes/error handing everywhere to indicate this is the case.
    • Or, convert the cart to an order prior to payment (in a Awaiting Payment state), but:
      • in the event of failure, or the user just abandoning the checkout, the cart is gone and there's no way to get it back.

Been researching this and everything seems to be geared towards a "synchronous" payment flow where you know the payment succeeded before placing the order.


Has anyone dealt with anything like the above?

#340018
Aug 21, 2025 16:11
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.