Coder Social home page Coder Social logo

validate-vat's Introduction

Validate European VAT number

Build Status Downloads

Note: if you are using typescript, please try out https://github.com/viruschidai/validate-vat-ts

A very lightweight, tiny lib (no external dependencies) allows you to verify the validity of a VAT number issued by any European Union Member State. This lib is basically calling web service provided by VIES (at http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl) for VAT number validation.

What is a VAT number?

A value added tax identification number or VAT identification number (VATIN) is an identifier used in many countries, including the countries of the European Union, for value added tax purposes.

Get started

npm install validate-vat

In your code

var validate = require('validate-vat');
validate(countryCode, vatNumber, callback)

Example

var validate = require('validate-vat');
validate( 'xx',  'xxxxxxx',  function(err, validationInfo) {
    console.log(validationInfo);
});
Returns

when valid

{
  countryCode: 'xx',
  vatNumber: 'xxxxxxxxx',
  requestDate: '2013-11-22+01:00',
  valid: true,
  name: 'company name',
  address: 'company address'
}

when invalid

{
  countryCode: 'xx',
  vatNumber: 'xxxxxxxxxx',
  requestDate: '2013-11-22+01:00',
  valid: false,
  name: '---',
  address: '---'
}

possible error messages

  'The provided CountryCode is invalid or the VAT number is empty'
  'The VIES VAT service is unavailable, please try again later'
  'The VAT database of the requested member country is unavailable, please try again later'
  'The request to VAT database of the requested member country has timed out, please try again later'
  'The service cannot process your request, please try again later'
  'Unknown error'

For more details usage, please check test

Change Log

0.9.0

  • Contains change related to the latest change in VIES service, see PR

0.7.0

  • Remove UK & Add Northern Ireland

0.6.0

  • Use https VIEW endpoint

0.5.0

  • Use IPv4 explicitly #13

0.4.0

  • Added a timeout option in #9
  • Upgraded versions of dev dependencies to latest versions

0.3.1

Wrap field parse in a try catch block when it can not parse a soap message. The soap message will be attached to the error object for furthur investigation.

0.3.0 - 05/Dec/2013

Instead of var validate = require('validate-vat').validate , you should call `var validate = require('validate-vat)' This will break your code, so update all the usages if you want to use this version

License

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

validate-vat's People

Contributors

ahmedissa avatar alanhett avatar arthurmialon avatar bultas avatar dependabot[bot] avatar kerbrown avatar pieterjandesmedt avatar red15 avatar remy avatar renovate-bot avatar suprememoocow avatar thebillg avatar viruschidai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

validate-vat's Issues

Can i use async/await instead of cabllback?

Hello,

In your example:
var validate = require('validate-vat'); validate( 'xx', 'xxxxxxx', function(err, validationInfo) { console.log(validationInfo); });
You use the callback. but can i use the validate with async/await feature? Thank you

How to process other countries

The VIES check is only usable for EU countries, which makes complete sense.
I was wondering what would be the best way to process other countrycodes.

For instance, CHE100416306IVA is not valid according to the VIES check, but it might very well be valid. (Switzerland is in europe, but not in the EU)

Should i check the countrycodes beforehand? or is this something we should incorperate into this module?

consult number

Hi,

for legal purposes this check is awesome as its one of the vew that included the businessname.
People think that thats not needed but it actually is.

When u do the request u should also post your own Tax id to get a consulation code, a identifier that proves that u checked the data.

Can that be implemented?

Validate call fails with "Error reading XMLStreamReader"

When I try to validate a VAT number, the validation fails with a generic "failed to fetch" error. Looking at the network request in the browser, the response from the service is:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>Error reading XMLStreamReader.</faultstring></soap:Fault></soap:Body></soap:Envelope>

Error 500--Internal Server Error

Since friday morning the vat validation service seems to have been throwing internal server errors. You can validate through the official website, so wondering if it's just me having issues or if there's been changes to their API or such?

index.js

var validate = require('validate-vat');
validate('SE', '556810898801', console.log); // Volvo Cars AB

package.json

{
  "name": "vat",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "dev": "node index.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "validate-vat": "^0.8.0"
  }
}

soapResponse

'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Draft//EN">\n' +
    '<HTML>\n' +
    '<HEAD>\n' +
    '<TITLE>Error 500--Internal Server Error</TITLE>\n' +
    '</HEAD>\n' +
    '<BODY bgcolor="white">\n' +
    '<FONT FACE=Helvetica><BR CLEAR=all>\n' +
    '<TABLE border=0 cellspacing=5><TR><TD><BR CLEAR=all>\n' +
    '<FONT FACE="Helvetica" COLOR="black" SIZE="3"><H2>Error 500--Internal Server Error</H2>\n' +
    '</FONT></TD></TR>\n' +
    '</TABLE>\n' +
    '<TABLE border=0 width=100% cellpadding=10><TR><TD VALIGN=top WIDTH=100% BGCOLOR=white><FONT FACE="Courier New"><FONT FACE="Helvetica" SIZE="3"><H3>From RFC 2068 <i>Hypertext Transfer Protocol -- HTTP/1.1</i>:</H3>\n' +
    '</FONT><FONT FACE="Helvetica" SIZE="3"><H4>10.5.1 500 Internal Server Error</H4>\n' +
    '</FONT><P><FONT FACE="Courier New">The server encountered an unexpected condition which prevented it from fulfilling the request.</FONT></P>\n' +
    '</FONT></TD></TR>\n' +
    '</TABLE>\n' +
    '\n' +
    '</BODY>\n' +
    '</HTML>\n'

easy enhancement

Hi Mr. Cup,
Amazing work... we've been using it for a long time as it works like a champ...
Could you add a new field in the object response that catches the more info about an invalid VAT number? I mean apart of the non existence, it also could be invalid because it not been activated for transactions within the EU .... That will help a lot

Thank you so much in advance...

Error in install

Hello,

The install is not working!
npm install --save https://github.com/benbucksch/validate-vat
npm ERR! code ENOENT
npm ERR! syscall spawn git
npm ERR! path git
npm ERR! errno -2
npm ERR! enoent Error while executing:
npm ERR! enoent undefined ls-remote -h -t https://github.com/benbucksch/validate-vat.git
npm ERR! enoent
npm ERR! enoent
npm ERR! enoent spawn git ENOENT
npm ERR! enoent This is related to npm not being able to find a file.

I tried this for testing:
curl https://github.com/benbucksch/validate-vat.git

<title>301 Moved Permanently</title>

301 Moved Permanently


nginx

Any help?

Compiled code error?

hi,
I think that code compiled from coffee has error.
When I have tried to get vat info, I always get an error. Web service is not called.

After some debuging I have noticed that this line of code looks strange...see "void 0"?
if (__indexOf.call(EU_COUNTRIES_CODES, countryCode) < 0 || !(vatNumber != null ? vatNumber.length : void 0))

...so I have to change it manually
if (__indexOf.call(EU_COUNTRIES_CODES, countryCode) < 0 || (vatNumber != null ? vatNumber.length> 0 : false))

Module is loaded from https://registry.npmjs.org/validate-vat/-/validate-vat-0.3.1.tgz

kr,
tom

Get "requestIdentifier" in the response?

Great package!

Would it be possible to have the "requestIdentifier" (Consultation Number) in the response when checking a VAT no? See attached example from the VIES web interface.

For Danish tax-audits this is required to store as a proof of a validated VAT no.

vies-validation-webinterface

Can't resolve 'https' in '..\node_modules\validate-vat\lib'

Hi! I import, in my angular project, the library 'validate-vat': "^0.8.0" and I use it in my .ts file as following:

let validate = require('validate-vat');

but the compilator generate an error:

Error: ./node_modules/validate-vat/lib/index.js
Module not found: Error: Can't resolve 'https' in 'C:\Users\developer\Desktop\progetti\bus-firenze-gui\node_modules\validate-vat\lib'

Could you help me? Is This library compatible with Angular 11?

Error: "Failed to parseField countryCode"

I am receiving a strange error today (which yesterday was not present):
It says: "Failed to parseField countryCode."
I am not sure what happened and I don't understand what happened since yesterday.

image

CORS header 'Access-Control-Allow-Origin' missing

Is It usable with ReactJS?

I'm trying to validate a VAT Number with the following code, but I get the 'Access-Control-Allow-Origin' error.
Is there a way to solve it in the frontend, or Am I constrained to do the call in the backend?

import validate from 'validate-vat';

validate('IT',  'XXXXXXXXXXX',  function(err, validationInfo) {
    console.log("err", err);
    console.log("validationInfo", validationInfo);
});

Error:
image

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.