Sylius/PayPalPlugin

PayPal plugin KO when using locale "en"

xchopin opened this issue · 0 comments

Hi,

I have configured a shop using the locale en which didn't give me errors when I installed it, therefore it is a validate locale

then I struggled for hours to understand why the PayPal button was not showing in the shipment method section and here is the thing :

Your locale is saved in the cart (table sylius_order)
image

and the plugin PayPal uses this variable in /vendor/sylius/paypal-plugin/src/Resources/views/payFromCartPage.html.twig to build the HTTP request to PayPal (for having the javascript library).

When you have en (and I presume it does the problem for other 2 chars locales), it automatically adds a suffix _001

Check bellow

image

https://www.paypal.com/sdk/js?client-id=CLIENT_ID_HIDDEN_FOR_GITHUB&locale=en_001&currency=USD"

This request returns

throw new Error("SDK Validation error: 'Invalid query value for locale: en_001'" );

/* Original Error:

Invalid query value for locale: en_001 (debug id: 1497937e2b6bb)

*/

Hope it can help some people having this issue!