vateu

EU VAT Number validation via European Union VIES API including company information

Usage no npm install needed!

<script type="module">
  import vateu from 'https://cdn.skypack.dev/vateu';
</script>

README

VATEU - European VAT Number Validation

vateu status Badge vateu license Badge vateu license Badge vateu twitter Badge

What is VATEU ?

VATEU is a lightweight quick and easy to use NPM package written in node.js A simple request with country code & VAT number ( timeout & debug optional ) will allow you to verify the validity of a VAT number issued by any European Union Member State via the VIES System. The returned response will show whether the VAT number is valid or not and any extra company information where available.

What is VIES ?

VIES (VAT Information Exchange System) is an electronic means of validating VAT-identification ( VATIN ) numbers of economic operators registered in the European Union for cross border transactions on goods or service.

Get started

npm install --save vateu

Valid CountryCodes

AT BE BG HR CY CZ DK EE FI FR DE EL HU IE IT LV LT LU MT NL PL PT RO SK SI ES SE XI

Callback example

var vateu = require('vateu');

var vateuOptions = {
    "countryCode": "xx", // ie FR
    "vatNumber": 'xxxxxx', // vat Number without country code
    "timeout": 10000 // optional - default 30000 ( 30 seconds )
}

vateu(vateuOptions, function (error, vateuInfo) {
    if (error) console.log('vateu callback test - error ', res.error)
    
    console.log('vateu callback test ', vateuInfo)
});

async/await example

var vateu = require('vateu');

awaitTest()
async function awaitTest() {
    var vateuOptions = {
        "countryCode": "xx", // ie FR
        "vatNumber": 'xxxxxx', // vat Number without country code
        "timeout": 10000 // optional - default 30000 ( 30 seconds )
    }

    var res = await vateu(vateuOptions)
    if (res.error) console.log('vateu sync test - error ', res.error)

    console.log('vateu sync test Result ', res.vateuInfo)
}
Valid Response
{
  valid: true,
  countryCode: 'xx',
  vatNumber: 'xxxxxxx',
  requestDate: '2021-12-08+01:00',
  name: 'Company Name', // if available
  address: 'Company Address' // if available
}
Invalid Response
{
  valid: false,
  countryCode: 'xx',
  vatNumber: 'xxxxxxxxxx',
  requestDate: '2021-12-08+01:00',
  name: false,
  address: false,
  error : 'Error message'
}
Error Messages
  'vateu Badly formed request - Check vatNumber & countryCode'
  'vateu Badly formed request - vatNumber is empty'
  'vateu Badly formed request - countryCode is empty'
  'vateu Badly formed request - Not EU Country'
  'vateu vies call error'
  'vateu Timeout'
Debug

Add the Debug key to your options
This will give more details of the call including errors

debugTest()
async function debugTest() {
  var vateuOptions = {
        "countryCode": "xx", // ie FR
        "vatNumber": 'xxxxxx', // vat Number without country code
        "timeout": 60000, // optional - default 30000 ( 30 seconds )
        "debug": true // optional - default false
      }
  var res = await vateu(vateuOptions)
  if (res.error) console.log('vateu debug test - error ', res.error)
  console.log('vateu debug test Result ', res.vateuInfo)
}

Common Issues

Receive Error when testing a valid VAT Number

This could be an internet connection issue or dns lookup
Check that you can ping 'ec.europa.eu' from your server
Add the following entry to your host file:-
147.67.34.30 ec.europa.eu

Change Log

1.2.7

Add Debug option

1.2.6

Add common issues section

1.2.5

Make for public use on GITHUB

License

The MIT License (MIT)

Copyright (c) 2021 bitinix@gmail.com

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.