Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check EU VAT using VIES SOAP service in C#

Tags:

c#

soap

asp.net

I have an ASP.NET website that needs to check a user-supplied VAT. The VIES Service can be used for that which exposes a SOAP API.

I need a dead-simple example on how to validate a VAT using this service. In PHP, it's these 4 lines: https://stackoverflow.com/a/14340495. For C#, I have found some articles from 2010 that do not work or are tens or even hundreds lines of "wrappers", "helper services" etc.

I don't need any of that, can someone provide PHP-like four-liner that would check VAT in C#? Thank you.

like image 735
Borek Bernard Avatar asked Oct 16 '15 10:10

Borek Bernard


People also ask

How do I check my vies?

You can verify the validity of a Vat number issued by any Member State by selecting that Member State from the drop-down menu and entering the Vat number to be validated.

What does vies stand for VAT?

VIES (VAT Information Exchange System) is an electronic mean of validating VAT-identification numbers of economic operators registered in the European Union.


1 Answers

Updated: I've published this as a NuGet library.

https://github.com/TriggerMe/CSharpVatChecker

var vatQuery = new VATQuery();
var vatResult = await vatQuery.CheckVATNumberAsync("IE", "3041081MH"); // The Squarespace VAT Number

Console.WriteLine(vatResult.Valid); // Is the VAT Number valid?
Console.WriteLine(vatResult.Name);  // Name of the organisation
like image 53
James Woodall Avatar answered Sep 18 '22 12:09

James Woodall