Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order checkout complete fail il phone number is incorrect #250

Closed
rv-garnier opened this issue May 13, 2024 · 2 comments · Fixed by #254
Closed

Order checkout complete fail il phone number is incorrect #250

rv-garnier opened this issue May 13, 2024 · 2 comments · Fixed by #254

Comments

@rv-garnier
Copy link

rv-garnier commented May 13, 2024

Hello,

If I have a malformed phone number for the delivery or billing address, and I don't have validation via the Symfony form, I get an error at the complete checkout step, when i payment is captured.

request.CRITICAL: Uncaught PHP Exception libphonenumber\NumberParseException: "The string supplied did not seem to be a phone number." at PhoneNumberUtil.php line 1673 {"exception":"[object] (libphonenumber\NumberParseException(code: 1): The string supplied did not seem to be a phone number. at /apps/sylius/vendor/giggsey/libphonenumber-for-php/src/PhoneNumberUtil.php:1673)"}

In my example, phone number was a simple hyphen.

Solution must be to catch NumberParseException in PayPlug\SyliusPayPlugPlugin\Creator\PayPlugPaymentDataCreator, formatNumber function :

public function formatNumber(string $phoneNumber, ?string $isoCode): array
{
    try {
        $phoneNumberUtil = PhoneNumberUtil::getInstance();
        $parsed = $phoneNumberUtil->parse($phoneNumber, $isoCode);

        if (!$phoneNumberUtil->isValidNumber($parsed)) {
            return [
                'phone' => null,
                'is_mobile' => null,
            ];
        }

        $formatted = $phoneNumberUtil->format($parsed, PhoneNumberFormat::E164);

        return [
            'phone' => $formatted,
            'is_mobile' => PhoneNumberType::MOBILE === $phoneNumberUtil->getNumberType($parsed),
        ];
    }
    catch (NumberParseException $e) {
        return [
            'phone' => null,
            'is_mobile' => null,
        ];
    }
}
@dmurillo-payplug
Copy link
Contributor

Hello,

Thank you for bringing this issue to our attention.

We will review this issue and investigate the proposed solution to ensure it resolves the problem effectively without introducing any new issues. Our team will need some time to thoroughly test and verify the fix.

We will update you as soon as we have more information or a resolution.

@dmurillo-payplug
Copy link
Contributor

Hello, this issue has been solved in the version 1.9.3.

Thanks for taking the time to report it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants