Fixing Mollie Failed Payment Redirects in Hyvä Checkout
Mollie for Magento 2 has an admin setting: redirect the user when a transaction fails. You can configure it to send customers back to the cart, the shipping step, or the payment step.
It doesn’t work correctly with Hyvä Checkout.
Why
The base mollie/magento2 module constructs redirect URLs using hash-based routing:
- Shipping:
/checkout/ - Payment:
/checkout/#payment
This works for Magento’s standard Luma checkout, which uses #shipping and #payment hash fragments for navigation.
Hyvä Checkout uses URL-based step navigation:
- Shipping:
/checkout/index/index/step/shipping/ - Payment:
/checkout/index/index/step/payment/
The hash fragment is ignored entirely. Customers returning from a failed Mollie payment always land on the first checkout step, regardless of what the admin setting says. If they were at the payment step, they now have to navigate back through shipping — or they just leave.
The fix
My PR adds an after plugin on MolliePaymentServiceOrderRedirectOnError::getUrl() in the frontend scope. It detects the hash-based URLs and replaces them with the correct Hyvä Checkout step URLs:
| Config value | Before | After |
|---|---|---|
| Redirect to shipping | /checkout/ |
/checkout/index/index/step/shipping/ |
| Redirect to payment | /checkout/#payment |
/checkout/index/index/step/payment/ |
| Redirect to cart | /checkout/cart |
/checkout/cart (unchanged) |
Because the plugin lives in the Hyvä compatibility module, it only activates when Hyvä Checkout is installed. Standard Magento checkout is completely unaffected.
Why this matters
Failed payments are a normal part of e-commerce — card declines, 3DS timeouts, bank rejections. What matters is how smoothly the customer can recover. If they have to re-enter shipping details because they were dropped on the wrong step, a meaningful percentage won’t bother, and that’s especially true on higher-value orders where the checkout experience gets more scrutiny.
Current status
The PR is open and awaiting review from the Mollie team. PR #81 on the official repo. If you’re running Hyvä Checkout with Mollie and hitting this issue, you can apply the fix from the PR branch now without waiting for the merge.
Contributing fixes upstream is worthwhile for everyone running the same stack. If you’re running into Magento or Hyvä issues, let me know — I may have a fix or can build one.