routeMatch may lack commerce_order in inline form

Created on 8 January 2026, 14 days ago

Problem/Motivation

`PaymentGatewayForm::dispatchFailedPaymentEvent()` assumes the current route always contains the `commerce_order` parameter. This isn’t always true, given that the form is inline, causing failed payment events to miss the order context and not to be dispatched.

Affected code:
- `modules/contrib/commerce/modules/payment/src/Plugin/Commerce/InlineForm/PaymentGatewayForm.php` reads `$this->routeMatch->getParameter('commerce_order')` as the sole source.

Steps to reproduce

1. Invoke the inline form inside a flow without `commerce_order` in the route.
2. Trigger a gateway failure.
3. Observe missing order context in the dispatched `FailedPaymentEvent`.

Proposed resolution

- Resolve the order via robust fallbacks:
1. Check `FormStateInterface::getBuildInfo()['callback_object']` and call `getOrder()` if available.

πŸ› Bug report
Status

Needs review

Version

3.2

Component

Payment

Created by

πŸ‡―πŸ‡΄Jordan Ahmad Khader

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024