Elixir package to validate European VAT numbers with the VIES service.
Add viex
to your list of dependencies in mix.exs
:
def deps do
[{:viex, "~> 0.1.0"}]
end
From the service WSDL we know these possible error reasons
Fault String | Meaning | Suggested recovery |
---|---|---|
GLOBAL_MAX_CONCURRENT_REQ | Your Request for VAT validation has not been processed; the maximum number of concurrent requests has been reached. Please re-submit your request later or contact [email protected] for further information": Your request cannot be processed due to high traffic on the web application. | Try again later |
MS_MAX_CONCURRENT_REQ | Your Request for VAT validation has not been processed; the maximum number of concurrent requests for this Member State has been reached. Please re-submit your request later or contact [email protected] for further information": Your request cannot be processed due to high traffic towards the Member State you are trying to reach. | Try again later |
SERVICE_UNAVAILABLE | An error was encountered either at the network level or the Web application level | Try again later |
MS_UNAVAILABLE | The application at the Member State is not replying or not available. Please refer to the Technical Information page to check the status of the requested Member State. | Try again later |
TIMEOUT | The application did not receive a reply within the allocated time period | Try again later |
Use Viex.lookup/1
to look up a European VAT number. Returns a Viex.Response
struct containing the company name, address, and a valid
key that is either
true
or false
.
iex(1)> Viex.lookup("NL854265259B01")
%Viex.Response{address: "PRINS BERNHARDPLEIN 00200\n1097JB AMSTERDAM", company: "GITHUB B.V.",
valid: true}
Use Viex.valid?/1
to check the validity of a European VAT number. Returns a
boolean.
iex(1)> Viex.valid?("NL854265259B01")
true