digitalfondue / vatchecker

java library for calling the eu vat checker web service
Apache License 2.0
20 stars 3 forks source link
eu eu-vat-validator java tin tin-soap-service vat-number vies vies-soap-service

vatchecker: a java library for fetching information from the VIES and TIN webservice

Maven Central Build Status

A small java client with 0 dependencies for calling:

License

vatchecker is licensed under the Apache License Version 2.0.

Download

maven:

<dependency>
    <groupId>ch.digitalfondue.vatchecker</groupId>
    <artifactId>vatchecker</artifactId>
    <version>1.6.0</version>
</dependency>

gradle:

compile 'ch.digitalfondue.vatchecker:vatchecker:1.6.0'

Use

If you use it as a module, remember to add requires ch.digitalfondue.vatchecker; in your module-info.

VIES

As a static method:

EUVatCheckResponse resp = EUVatChecker.doCheck("IT", "00950501007");
Assert.assertEquals(true, resp.isValid());
Assert.assertEquals("BANCA D'ITALIA", resp.getName());
Assert.assertEquals("VIA NAZIONALE 91 \n00184 ROMA RM\n", resp.getAddress());

You can create an instance if you prefer:

EUVatChecker euVatChecker = new EUVatChecker();
EUVatCheckResponse resp = euVatChecker.check("IT", "00950501007");
Assert.assertEquals(true, resp.isValid());
Assert.assertEquals("BANCA D'ITALIA", resp.getName());
Assert.assertEquals("VIA NAZIONALE 91 \n00184 ROMA RM\n", resp.getAddress());

For error handling, see the tests, you may distinguish "invalid" and "error" which can have a Fault object:

You can use your own data fetcher if customization is needed, see:

TIN

As a static method:

EUTinCheckResponse resp = EUTinChecker.doCheck("BE", "00012511119");
Assert.assertEquals(true, resp.isValidStructure());
Assert.assertEquals(true, resp.isValidSyntax());

Like the VIES counterpart, you can see the tests for all the possibile outputs: