A web designer client had a problem with one of their client’s WooCommerce stores whereby all transactions recorded successfully in the store but their payment gateway (PayPal) was billing non-GBP transactions with the correct amount but in the wrong currency.
- A UK based customer would buy an item listed in GBP, the transaction would be recorded in WooCommerce in GBP and PayPal would checkout in GBP.
- A US based customer however would buy an item listed in USD, the transaction would be recorded in WooCommerce in USD but PayPal would checkout the correct value of the transaction but in GBP instead of USD.
Asked to investigate we first checked the database to verify the order details and that was entirely as expected with the
_order_currency attribute in the
postmeta table being correctly set to the currency the order was conducted in.
PayPal themselves had sent through confirmation that they were receiving “GBP” as the
CURRENCYCODE for all transactions, even where we had the currency recorded in the database as USD.
We could only see two options:
- That PayPal were ignoring the currency attribute of the transaction (and applying the base currency of the PayPal account instead)
- Something was going wrong in the payment gateway plugin on the site.
It was easier to verify the payment plugin first. The site was using WooCommerce PayPal Pro (v4.2.0) from the folks at WooThemes so we took a look through the plugin PHP code looking for any issues.
We found a number of references to the
CURRENCYCODE variable PayPal used to process the payment. What immediately stood out was that the
CURRENCYCODE reference in the
do_payment function (in
wp-content/plugins/woocommerce-gateway-paypal-pro/includes/class-wc-gateway-paypal-pro.php) was set as follows (line 723):
'CURRENCYCODE' => get_option('woocommerce_currency' ),
Errr, hold on, that sets the currency for the PayPal transaction to be the base currency for the site. But what about if the transaction is in a non-base currency?
We commented that line out and added line 724:
'CURRENCYCODE' => $order->get_order_currency(),
Which set the PayPal transaction currency to the currency selected for the order.
And it worked – all transactions now checkout in the correct currency and are billed by PayPal in the correct currency.
It appears that the plugin is wrongly configured – significantly so for a $79+ piece of software. What makes it particularly painful is that the database transaction is recorded absolutely correctly – but will not necessarily accurately reflect the actual currency that is sent to the payment processor.
Note also that the same problem appears to exist in the PayFlow functions within the same plugin (file
class-wc-gateway-paypal-pro-payflow.php at line 420).
We passed our finding back to our developer client who has passed them back to WooThemes. We will update this post as and when we get any feedback from them. In the interim please be very careful when using this plugin with non-base currency transactions.
The plugin has been updated and, from what we can see, the latest version now handles the multi-currency situation we described – seemingly by applying the same modification to the checkout code that we deployed.