Problem/Motivation
During a form rebuild inside PaymentOffsiteForm.php, the $order object is initialized from the associated payment entity. However, this order is retrieved from the entity cache, and may contain a stale (outdated) version of the order. If another process has already updated and saved the order (e.g., during a parallel payment callback), attempting to save this outdated version results in an OrderVersionMismatchException.
Steps to reproduce
Try a failed payment from 2C2P and return to the form and call the buildConfigurationForm.
Proposed resolution
Use OrderStorage::loadForUpdate() when loading the order in any logic that intends to update and save the order entity. This ensures that a lock is acquired, and that we are working with a fresh copy of the entity from the database.
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork commerce_2c2p-3538634
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
mohammad-fayoumiComment #5
mhawwari commented