Problem/Motivation
On Drupal Commerce 3.3.0+, the on-site gateway can no longer collect a card during checkout. The card form never renders, no payment method is created, and submitting the order fails on the payment step with:
commerce_payment: Unable process payment with eway_gate_onsite
No exception is logged, which makes it look like a misconfiguration rather than a code issue.
Commerce 3.3.0 reworked the payment form (see the Commerce 3.3.0 release notes). The PaymentInformation checkout pane now renders the add-card form only when the gateway has a form registered for the checkout-add-payment-method operation:
// commerce_payment/src/Plugin/Commerce/CheckoutPane/PaymentInformation.php if ($payment_gateway_plugin instanceof SupportsCreatingPaymentMethodsInterface && $payment_gateway_plugin->hasFormClass('checkout-add-payment-method')) { $pane_form = $this->buildPaymentMethodForm($pane_form, $form_state, $default_option); }
Core provides backward compatibility in PaymentGatewayBase::create(), which copies a gateway's existing add-payment-method form to checkout-add-payment-method:
// commerce_payment/src/Plugin/Commerce/PaymentGateway/PaymentGatewayBase.php if (isset($instance->pluginDefinition['forms']['add-payment-method']) && !isset($instance->pluginDefinition['forms']['checkout-add-payment-method'])) { $instance->pluginDefinition['forms']['checkout-add-payment-method'] = $instance->pluginDefinition['forms']['add-payment-method']; }
Onsite::create() overrides the parent and builds the instance with new static(...) without ever calling parent::create(), so this shim never runs. As a result hasFormClass('checkout-add-payment-method') returns FALSE and the pane renders nothing.
Steps to reproduce
- Drupal 10.3+ / Commerce 3.3.0+, eway_commerce2 3.0.0, gateway in on-site mode.
- Add a product to the cart and proceed to checkout.
- Observe that no credit-card fields appear in the Payment information pane.
- Place the order → checkout fails; watchdog logs
Unable process payment with eway_gate_onsite.
Confirmed via:
$plugin->hasFormClass('add-payment-method'); // TRUE $plugin->hasFormClass('checkout-add-payment-method'); // FALSE ← should be TRUE
Proposed resolution
Declare the checkout-add-payment-method form explicitly on the gateway plugin annotation (simplest, independent of create()):
* forms = { * "add-payment-method" = "Drupal\eway_gate\PluginForm\Onsite\PaymentMethodAddForm", + * "checkout-add-payment-method" = "Drupal\eway_gate\PluginForm\Onsite\PaymentMethodAddForm", * "edit-payment-method" = "Drupal\commerce_payment\PluginForm\PaymentMethodEditForm", * },
Alternatively (better long-term), refactor Onsite::create() to call parent::create() and then inject the transaction manager, so it inherits the core BC shim and any future create() behavior instead of re-implementing it.
Remaining tasks
- Decide between the annotation fix and the
create()refactor. - Same review for any other gateway form operations the overridden
create()may shadow. - Reviewed-and-tested.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | eway_commerce2-onsite-create-bypasses-checkout-add-payment-method-bc-shim-3595095-2.patch | 616 bytes | janvonmulert |
Comments
Comment #2
janvonmulert commented