This projects is a C# wrapper library to validate VAT numbers with VIES.
Table of Contents
Use Visual Studio 2022 to build the project.
Get the NuGet packages from nuget.org or search for MichelMichels.ViesSharp
in the GUI package manager in Visual Studio.
You can also use the cli of the package manager with following command:
Install-Package MichelMichels.ViesSharp
This repository contains 2 projects:
MichelMichels.ViesSharp
- Core libraryMichelMichels.ViesSharpTests
- Testing library
There is a demo running on my website with a Blazor Web App frontend.
This code below checks the VAT number for the Belgian national broadcasting company (VRT):
IViesSharpClient client = new ViesSharpClient();
VatNumberRequest request = new()
{
CountryCode = "BE",
VatNumber = "0244142664"
};
VatNumberResponse response = await client.CheckVatNumber(request);
Response:
{
"countryCode": "BE",
"vatNumber": "0244142664",
"requestDate": "2024-04-23T08:04:10.919Z",
"valid": true,
"requestIdentifier": "",
"name": "NV OR De Vlaamse Radio- en Televisieomroeporganisatie",
"address": "Auguste Reyerslaan 52\n1030 Schaarbeek",
"traderName": "---",
"traderStreet": "---",
"traderPostalCode": "---",
"traderCity": "---",
"traderCompanyType": "---",
"traderNameMatch": "NOT_PROCESSED",
"traderStreetMatch": "NOT_PROCESSED",
"traderPostalCodeMatch": "NOT_PROCESSED",
"traderCityMatch": "NOT_PROCESSED",
"traderCompanyTypeMatch": "NOT_PROCESSED"
}
This call can be used to test the VAT service with example VatNumbers 100
and 200
.
See the ViesSharpClientTests.CheckVatTestService()
method in the test library for more information.
This call can be used to verify if the service is active and which countries are supported.
IViesSharpClient client = new ViesSharpClient();
StatusResponse response = await client.CheckStatus();
This library throws ViesSharpException
s if the HTTP status code is not 200. This ViesSharpException
has a property ErrorResponse
with a deserialized error response of the VIES service to indicate what is wrong with the call.
Visit the 'Technical information' page on the VIES site of the European Commission for more in-depth documentation.
- Written by Michel Michels.
- Thanks to the European Commission for aggregating all this information and creating a handy REST API