viruschidai / validate-vat-ts

A library for validating VAT number
32 stars 13 forks source link

Vies Response Error #27

Open Thazar opened 2 years ago

Thazar commented 2 years ago

Hey, after validateVat, the response from the vies is: 'ViesClientError: Failed to parse vat validation info from VIES response'. Any sugestions?

stupkad commented 2 years ago

Hi there,

I experienced the same issue, I am using my own code based on this library, but not exactly this library. To fix this issue, I did the following two things:

  1. The regex used in hasFault does not work, as there is some whitespace including linefeeds.

    const hasFault = (soapMessage: string): boolean => {
    return soapMessage.match(/<soap:Fault>(.|\s)*<\/soap:Fault>/g) !== null;
    };
  2. There is an issue with the request headers, I changed them as follows. Problem is the SOAPAction from the request headers, which has to be removed at all.

const headers = {
    "Content-Type": "application/xml",
    "User-Agent": "node-soap",
    "Accept": "text/html,application/xhtml+xml,application/xml,text/xml;q=0.9,*/*;q=0.8",
    "Accept-Encoding": "none",
    "Accept-Charset": "utf-8",
    "Connection": "close",
    "Host": "ec.europa.eu"
};

Cheers, Dietmar

florianmrz commented 2 years ago

This was already fixed in the "non-TS" version of this package: https://github.com/viruschidai/validate-vat

You can use it as a workaround until it was fixed here as well.

thebillg commented 2 years ago

It was fixed in this commit https://github.com/viruschidai/validate-vat-ts/commit/ee582740d8f9904ce93ca1d74ba775fe3bf48f36#diff-a2a171449d862fe29692ce031981047d7ab755ae7f84c707aef80701b3ea0c80

jpagex commented 2 years ago

Any plan on releasing the fix?

AllanJard commented 2 years ago

Looks like it was in 1.2.1. Its working for me :). I'd say this can be closed.

jpagex commented 2 years ago

Looks like it was in 1.2.1. Its working for me :). I'd say this can be closed.

I did not see any tag/release on this repo, so I assumed it was not yet released. It seems to be deployed on npm though with the correct commit hash.

Thanks!