Opencart Paypal failures/INVALID with foreign characters

We’ve had occasional oddities with Paypal (Standard) payments showing as ‘Pending Paypal’ on Opencart, with the Error Log showing an “INVALID” response from the Paypal IPN transaction. However, when we check on Paypal, the transaction has completed without a problem.

Opencart error log

The (seemingly) common factor with the payments that show like this is that originated in a foreign currency, so I’d assumed that was the problem, but in fact some orders from (the same) currencies went through OK. On Saturday I spotted that those that failed all included a ‘non-standard’ character in the customer’s names: é, ø etc. And this suggested an issue with character sets.

So, after a bit of digging, I discovered that Paypal, as a default, sends all IPN responses encoded as win-1252, whereas my website is in utf-8. You can change this, although it isn’t easy to find, via My Profile > My Selling Preferences > Paypal Button Language Encoding (link right at the bottom) and then the ‘More options’ button. Set the encoding used on your website to utf-8 (or whatever you use, obviously…).

Paypal screenshot showing encoding settings

Testing this after making the change means no more failures with non-standard characters.

Tags: ,

Useful? Interesting? Leave me a comment

I've yet to find a way of allowing code snippets to be pasted into Wordpress comments - so if you're trying to do this you'd be better off using the contact form.