Пример #1
0
        /// <summary>
        /// Verifies a VAT number using the EU Comission service. Note, this call is not error free
        /// and can throw errors, so it's important to use try catch. You can see current health of
        /// the service at http://ec.europa.eu/taxation_customs/vies/monitoring.html.
        /// </summary>
        /// <param name="VATId">The VAT id, eg SE559116174901.</param>
        public static VATResponse IsValidVAT(string VATId)
        {
            // all requests sent to http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl
            // tech docs at http://ec.europa.eu/taxation_customs/vies/help.html

            if (VATId == null || VATId.Length < 3)
            {
                Debug.WriteLine("VATId cannot be null or less 3 chars in length.");
                return(new VATResponse {
                    IsValid = false
                });
            }

            var param = new VATCheck.checkVatRequest(VATId.Substring(0, 2), VATId.Substring(2));

            var service = new VATCheck.checkVatPortTypeClient();

            var result = Task.Run(async() => await service.checkVatAsync(param)).Result;

            return(new VATResponse
            {
                IsValid = result.valid,
                CompanyName = result.name != "---" ? result.name : null,
                Address = result.address != "---" ? result.address : null
            });
        }
Пример #2
0
 public System.Threading.Tasks.Task <VATCheck.checkVatResponse> checkVatAsync(VATCheck.checkVatRequest request)
 {
     return(base.Channel.checkVatAsync(request));
 }