Paazl / magento2-checkout-widget

6 stars 15 forks source link

No street address #36

Closed patricksindelka closed 4 years ago

patricksindelka commented 4 years ago

In version 1.1.4 the plugin can no longer send orders from other countries than the Netherlands to Paazl. This is due to a missing street address. In the log we will get the following error:

Magento2.INFO: exception: Error sending order data to Paazl: Notice: Undefined index: street in /home/pighen.designr.tech/public_html/vendor/paazl/magento2-checkout-widget/Model/Api/Builder/Order.php on line 116 [] []

I noticed that there is a bug in the function parseAddress. On rule 213 in the file Model/Api/Builder/Order.php (v 1.1.4) there is the following code:

        $address = implode(' ', $shippingAddress->getStreet());
        $pattern = '/^(?<street>[\w[:alpha:]]+[ \w[:alpha:]]*) (?<houseNumber>\d{1,5})((?<houseNumberExtension>[\-\/\s]*\w+)*)/';
        preg_match($pattern, $address, $matches);
        $parsedAddress = array_filter($matches, function ($key) {
            return !is_int($key);
        }, ARRAY_FILTER_USE_KEY);

        return $parsedAddress;

After changing this code back to a previous version everything is working fine again:

        $address = implode(' ', $shippingAddress->getStreet());
        $pattern = '#^([\w[:punct:] ]+) ([0-9]{1,5})([\w[:punct:]\-/]*)$#';
        preg_match($pattern, $address, $matches);
        $street = (isset($matches[1])) ? $matches[1] : '';
        $houseNumber = (isset($matches[2])) ? $matches[2] : '';
        $houseNumberExtension = (isset($matches[3])) ? $matches[3] : '';

        return [
            'street'               => $street,
            'houseNumber'          => $houseNumber,
            'houseNumberExtension' => $houseNumberExtension
        ];
Frank-Magmodules commented 4 years ago

Hi @patricksindelka , thank you for your message, we've fixed this in our upcoming 1.2.0 which is going to be released next week!

samgranger commented 4 years ago

@Frank-Magmodules any news on release?

Frank-Magmodules commented 4 years ago

Hi @samgranger , sorry for the delay, we are expecting the official release upcoming week. Regarding the problem with the adress-line, this was not an issue with non-Netherlands country, but with non-latin (German, Cyrillic) characters in address lines.

Frank-Magmodules commented 4 years ago

Hi @samgranger , thanks again for opening this issue. This issue has been resolved in the V 1.2.0 release. We are closing this issue now but please feel free to reopen the issue if this still occurs.