No payment method provided
-
Hello everyone,
I have a problem with my Woocommerce webshop. On the checkout page I only have 1 payment method enabled (Mollie iDEAL). When a new user is on the checkout page, it needs to fill in all their information. Because there is only one payment method, the user doesn’t need to select the payment method, because it is already selected. But when the user wants to proceed, it gets the following error message: ‘no payment method selected’ (in Dutch: geen betaalmethode geselecteerd).
When the user refreshes the page, their information is already filled in. And now they can proceed with the payment.
I dug a little bit into the code, and I noticed that in the DOM the iDEAL option is
checked, but in the POST request I don’t see thepayment_method.
I made a (very) dirty work-a-round for my issue. I will post that at the bottom.My environment:
- WordPress (Version 6.8.3)
- Mollie Payments for WooCommerce (Version 8.0.6)
- WooCommerce (Version 10.3.3)
My work-a-round
My work-a-round to make this work, is to add a custom HTML block to the checkout page and add the following javascript to the page. This sets first the current payment to the (not enabled) “Direct bank transfer” and then reset it back to the mollie iDEAL payment method.Technical: I think the issue is in the
paymentMethodId, because theactivePaymentMethodis set correctly (tested withwp.data.select('wc/store/payment').getActivePaymentMethod()). But the value ofpaymentMethodIdis not updated. https://github.com/woocommerce/woocommerce/blob/4d2bb38575840530b70ef339ceb4997a6494db43/plugins/woocommerce/client/blocks/assets/js/base/context/providers/cart-checkout/checkout-processor.ts#L125<script type="text/javascript">
jQuery(function($) {
function setPaymentMethod(method) {
return new Promise((resolve) => {
const unsubscribe = wp.data.subscribe(() => {
const current = wp.data.select('wc/store/payment').getActivePaymentMethod();
if (current === method) {
unsubscribe();
resolve();
}
});
wp.data.dispatch('wc/store/payment').__internalSetActivePaymentMethod(method);
});
}
(async () => {
await setPaymentMethod('bacs');
await setPaymentMethod('mollie_wc_gateway_ideal'); // final state
console.log("Mollie FIX");
})();
});
</script>Today I tested it with the latest version 8.1.0 of the plugin, now I get a 400 bad request.
:8080/index.php?rest_route=/wc/store/v1/checkout&_locale=site:1 Failed to load resource: the server responded with a status of 400 (Bad Request)The error message is now
Something went wrong. Please contact us to get assistance.The refresh method when a user already has filled in their “Billing address” doesn’t work any more.
Btw, the work-a-round still works
The topic ‘No payment method provided’ is closed to new replies.