Summary of the issue

The Aelia Currency Switcher allows to enable specific payment methods for each of the enabled currencies. That can be configured at WooCommerce > Currency Switcher > Payment Gateways (see below):

This feature works fine with all payment gateways we tested so far, but the PeachPay plugin is not affected by it.


The PeachPay plugin uses its own custom logic to offer its payment options to the customers. Its logic doesn't take into account the fact that the payment method might have been made unavailable in specific cases, e.g. for some currencies, for some countries, or using some other criteria. Due to that, the following happens:

  1. The PeachPay payment option is always visible, no matter what currency is active. This is incorrect.
  2. The PeachPay payment process fails when it's performed in a currency different from the ones for which that service is enabled. For example, if PeachPay is enabled only for EUR, and the customer tries to use it to place an order in USD, PeachPay throws an error. This happens because the filtering of the available payment methods does apply during the payment process. WooCommerce sees that PeachPay is not available for USD (even though it appeared on the page itself), and throws an error, as it should.


Solution

We reported the issue to the authors of the PeachPay plugin on the 24 September 2021 and explained how the issue could be fixed. While they work on a solution, the following filter can be a suitable workaround:

add_action('wp_enqueue_scripts', function() {
  // Fetch the list of available payment gateways
  $available_payment_gateways = WC()->payment_gateways()->get_available_payment_gateways();
  // Don't load the PeachPay scripts when PeachPay is not enabled. This fixes the incorrect
  // behaviour, preventing PP from crashing mid-payment
  if(!isset($available_payment_gateways['peachpay'])) {
    remove_action('wp_enqueue_scripts', 'peachpay_load_button_scripts');
  }
}, 1);

When the authors of PeachPay will implent the fix, we will update this article to indicate that the workaround will not longer be needed.