Worldpay / Worldpay-Magento2-CG

Worldpay Magento 2 Plugin for Worldpay Corporate Gateway
Other
17 stars 35 forks source link

Klarna locale issue - BAD_VALUE: Bad value: locale (#deed595e-4c59-439e-b81b-xxxxxx) #113

Closed obsergiu closed 1 year ago

obsergiu commented 1 year ago

Klarna fails on our multi-store platform.

The error we get back is:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE paymentService PUBLIC "-//WorldPay//DTD WorldPay PaymentService v1//EN" "http://dtd.worldpay.com/paymentService_v1.dtd">
<paymentService version="1.4" merchantCode="MERCHANTCODE">
    <reply>
        <orderStatus orderCode="22000022222-2222222222">
            <error code="7"><![CDATA[BAD_VALUE: Bad value: locale (#deed595e-4c59-439e-b81b-xxxxxx)]]></error>
        </orderStatus>
    </reply>
</paymentService>

This issue is because the module is sending the locale in a format that does not comply with WorldPay's specifications. Specifically, the module is using the Magento default format, which separates the language and region subtags with an underscore, as in "en_GB":

<KLARNA_PAYLATER-SSL shopperCountryCode="GB" locale="en_GB">

However, the WorldPay documentation specifies that the format should be RFC 1766 compliant, which uses a hyphen to separate the language and region subtags, as in "en-GB".

According to Worldpay documentation:

Solution: This can be fixed easily by adding the code:

$include['locale'] = str_replace('_','-',$locale);

instead of:

$include['locale'] = $locale;

in the file:

vendor/sapient/module-worldpay/Model/XmlBuilder/RedirectKlarnaOrder.php

It would be nice to have this fix in the next release as it will save us the headaches of worrying about maintaining the patch and potentially encountering issues in the future.

elavarasann commented 1 year ago

Hi, Thanks for the update, we will check in our side and come back to you.

elavarasann commented 1 year ago

We have fixed this issue in our latest release - 2.4.6-rc0523. Please have a look.

https://github.com/Worldpay/Worldpay-Magento2-CG/releases/tag/2.4.6-rc0523