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

Command icon 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

mohammad-fayoumi created an issue. See original summary.

mohammad-fayoumi’s picture

Status: Active » Needs review

mhawwari’s picture

Status: Needs review » Fixed

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.