DragonBe / vies

Component using the European Commission (EC) VAT Information Exchange System (VIES) to verify and validate VAT registration numbers in the EU, using PHP and Composer.
http://ec.europa.eu/taxation_customs/vies/faqvies.do#item16
MIT License
266 stars 59 forks source link

Validation failed for valid VAT numbers #136

Closed sunkaflek closed 2 years ago

sunkaflek commented 3 years ago

Hi, I encountered several cases, where the library returns false negatives (invalid vat while VIES web service returns valid):

FR45497709824 NL001439542B97

Am I doing anything wrong?

Thank you

Screenshot 2021-02-15 at 18 05 00 Screenshot 2021-02-15 at 18 05 34 Screenshot 2021-02-15 at 18 05 55
nils-m commented 3 years ago

It is probably the Vies::validateVatSum() method that return false negatives. Either bypass DragonBe Vies for those numbers or just comment if (!$this->validateVatSum($countryCode, $vatNumber)) {.....} statement in the vendor ... Yes it's very ugly but this error is very annoying.

krzaczek commented 2 years ago

@sunkaflek I can't reproduce this bug. What version of library are You using ?

<?php

require './vendor/autoload.php';

$vies = new \DragonBe\Vies\Vies();

$result = $vies->validateVat(
    'NL',
    '001439542B97',
    'FR',
    '45497709824'
);

Both VAT numbers pass checksum validation test and are valid in Vies.

print_r($result->toArray());

Response:

Array
(
    [countryCode] => NL
    [vatNumber] => 001439542B97
    [requestDate] => 2021-12-21
    [valid] => 1
    [name] => HAMMINGA INSTALLATIESERVICE
    [address] => 
WAGNERLAAN 00016
9603AT HOOGEZAND

    [identifier] => WAPIAAAAX3cV7iHA
    [nameMatch] => 
    [companyTypeMatch] => 
    [streetMatch] => 
    [postcodeMatch] => 
    [cityMatch] => 
)

returns true

sunkaflek commented 2 years ago

@krzaczek Ah ok, this seems to be the problem. I have now tested installing latest release using composer require dragonbe/vies (that installs 2.2.0). This version does have the bug I mentioned above.

But if I download the latest zipped code directly from github and use that way, the bug is gone. So I guess it has been fixed in some commit after 2.2.0 but has not been released as a new version yet?

In my opinion this is quite a serious bug, I'd say it's worth a release.

krzaczek commented 2 years ago

@sunkaflek Yes You are right. I will look into changes on the master branch, and will do my best to make a patch release today with the fix.

krzaczek commented 2 years ago

@sunkaflek the only change I see is a fix for 32 bit architectures and this was done in a both NL and FR validator here. What platform are You having issues on ?

https://github.com/DragonBe/vies/commit/7b10c4cffa5028c75e3404febd57b5789a1239b4

sunkaflek commented 2 years ago

@krzaczek It is 32bit PHP 7.4.4 so sounds like this could be it

krzaczek commented 2 years ago

@sunkaflek i'm upgrading the code to support PHP 8.1. When this is done there will be a new 2.3.0 release - hopefully today

krzaczek commented 2 years ago

@sunkaflek sorry for the delay. This has been released in 2.3.0