Skip to content

MichelMichels/ViesSharp

Repository files navigation

ViesSharp 🛂

NuGet Version .NET demo

This projects is a C# wrapper library to validate VAT numbers with VIES.

Table of Contents

Prerequisites

Building

Use Visual Studio 2022 to build the project.

Installation

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


Getting started

This repository contains 2 projects:

  • MichelMichels.ViesSharp - Core library
  • MichelMichels.ViesSharpTests - Testing library

There is a demo running on my website with a Blazor Web App frontend.

Check VAT number

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"
}

Check VAT test service

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.

Check status

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();

Exceptions

This library throws ViesSharpExceptions 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.

Documentation

Visit the 'Technical information' page on the VIES site of the European Commission for more in-depth documentation.

Credits

  • Written by Michel Michels.
  • Thanks to the European Commission for aggregating all this information and creating a handy REST API

About

C# client to validate VAT data through VIES

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages