https://github.com/digitalfondue/vatchecker
java library for calling the eu vat checker web service
https://github.com/digitalfondue/vatchecker
eu eu-vat-validator java tin tin-soap-service vat-number vies vies-soap-service
Last synced: 5 months ago
JSON representation
java library for calling the eu vat checker web service
- Host: GitHub
- URL: https://github.com/digitalfondue/vatchecker
- Owner: digitalfondue
- License: apache-2.0
- Created: 2018-05-28T19:58:05.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2024-06-16T15:32:54.000Z (almost 2 years ago)
- Last Synced: 2024-06-16T17:40:08.164Z (almost 2 years ago)
- Topics: eu, eu-vat-validator, java, tin, tin-soap-service, vat-number, vies, vies-soap-service
- Language: Java
- Homepage:
- Size: 116 KB
- Stars: 19
- Watchers: 6
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# vatchecker: a java library for fetching information from the VIES and TIN webservice
[](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22vatchecker%22)
[](https://github.com/digitalfondue/vatchecker/actions?query=workflow%3A%22Java+CI+with+Maven%22)
A small java client with 0 dependencies for calling:
- the European "VAT Information Exchange System" (VIES) webservice for validating the VAT numbers. See http://ec.europa.eu/taxation_customs/vies/ .
- the European "TIN" webservice. See https://ec.europa.eu/taxation_customs/tin/ .
## License
vatchecker is licensed under the Apache License Version 2.0.
## Download
maven:
```xml
ch.digitalfondue.vatchecker
vatchecker
1.6.0
```
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:
```java
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:
```java
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:
- https://github.com/digitalfondue/vatchecker/blob/master/src/test/java/ch/digitalfondue/vatchecker/EUVatCheckerTest.java
You can use your own data fetcher if customization is needed, see:
- https://github.com/digitalfondue/vatchecker/blob/master/src/main/java/ch/digitalfondue/vatchecker/EUVatChecker.java#L183
- https://github.com/digitalfondue/vatchecker/blob/master/src/main/java/ch/digitalfondue/vatchecker/EUVatChecker.java#L67
### TIN
As a static method:
```java
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:
- https://github.com/digitalfondue/vatchecker/blob/master/src/test/java/ch/digitalfondue/vatchecker/EUTinCheckerTest.java