Search: 

Machine translation:
MBBSoftware
Creating software for businesses, professionals, and the home
our sites: MBBSoftware - Custom Image Presenter - Authenticate Testimonial
How to Use the VAT Registration Number Validator Hi guest
Sign up
Login
VAT Registration Number Validator Home How to Use Download Reference Manual License Awards & Reviews  
VAT Registration Number Validator Icon
Using the software is straightforward. Copy the VAT-Validator DLL appropriate for your web server into the Bin folder of your website, or alternatively copy the "VAT-Validator.cs" file into its App_Code folder. Then you can start using the software immediately as shown in the example below.
Let the ddlECCountry and ddlResponseLanguage be two drop-down lists, populated with items to represent respective European Union Member Countries and Languages. Since in the example below we will use the values of the selected list-items directly in function calls, it is important that they are populated with valid European Union Member Country and Language Codes, which are available in the VAT Registration Number Validator Reference Manual. Alternatively these drop-lists can also be dynamically populated using:

public static string[] VATValidator.GetMemberStates(); and
public static string[] VATValidator.GetLanguages();

We will also assume that textVATNumber is a text box in which the visitor will enter their VAT number, and that the checkObtainReference is a check box which is used to indicate whether a Consultation Reference Number is required or not. We will place the overall validation result in the LabelVATValidationStatus label field, and the obtained registrant data in two strings AllItemsData and AllKnownItemsData.

Then an eCommerce website using the VAT Registration Number Validator can use similar code to obtain the details of a VAT number.
using MBBSoftware;


[some code to ensure that there is a valid selection in ddlECCountry]
[some code to ensure that there is a text (VAT number) entered in the textVATNumber]
[some code to ensure that there is a valid selection in ddlResponseLanguage]


// Dictionary which will be used to contain the VIES data for the queried VAT number.
Dictionary< VATValidator.DataItem, string > dictVATNumber = new Dictionary< VATValidator.DataItem, string >();


// Get the selected state and language in separate variables for example clarity. Note that both
// GetMemberState( param ) and GetLanguage( param ) throw exceptions when invalid arguments are supplied.
VATValidator.MemberState state    = VATValidator.GetMemberState( ddlECCountry.SelectedValue );
VATValidator.Language    language = VATValidator.GetLanguage( ddlResponseLanguage.SelectedValue );


// Variables for the results and any possible warnings that need to be sent to the webmaster.
string AllItemsData = "";
string AllKnownItemsData = "";
string WebMasterMessage = "";


try
{
   // Now create a VAT validator instance which will be used to acquire the data. Use the default 
   // constructor if you do not require a Consultation reference number. Use the parameters overload 
   // constructor to supply your own VAT number as parameterized if you require a Consultation reference number.
   VATValidator validatorVAT = checkObtainReference.Checked ? 
                             new VATValidator( VATValidator.MemberState.UnitedKingdom, "YourVATNnumber" ) : 
                             new VATValidator();


   if( validatorVAT.IsValidVAT( state, textVATNumber.Text, language, ref dictVATNumber, ref WebMasterMessage ) )
   {
      // Valid VAT Number.
      LabelVATValidationStatus.Text = dictVATNumber[VATValidator.DataItem.Status];


      // Example: build a html string for all VAT validation data items.
      foreach( VATValidator.DataItem dataFileld in VATValidator.GetAllItems() )
      {
         AllItemsData += string.Format( "{0}: {1}<br />", 
                                        VATValidator.GetItemName( dataFileld, VATValidator.Language.English ),
                                        dictVATNumber.ContainsKey( dataFileld ) ? 
                                                      dictVATNumber[dataFileld] : 
                                                      "[VAT-Validator: No Available Data]" );
      }


      // Example: build a html string only for the data items delivered through the request.
      foreach( KeyValuePair< VATValidator.DataItem, string > dataFileld in dictVATNumber )
      {
         // Ignore any empty or containing only "-" data items.
         if( !string.IsNullOrEmpty( dataFileld.Value.Trim( '-' ).Trim() ) )
         {
            AllKnownItemsData += string.Format( "{0}: {1}<br />",
                                        VATValidator.GetItemName( dataFileld.Key, VATValidator.Language.English ),
                                        dataFileld.Value );
         }
      }
   }
   else
   {
      // Invalid/Unconfirmed VAT Number. This message can be either "No, ..." for invalid VAT number or
      // ["Explanation what went wrong & why the VAT number could not be confirmed."]; use the coma as an indicator.
      LabelVATValidationStatus.Text = -1 != dictVATNumber[VATValidator.DataItem.Status].Substring(0,5).IndexOf(',') ?
                                            dictVATNumber[VATValidator.DataItem.Status] : 
                                            ("The entered VAT number could not be validated. Response: " + 
                                             dictVATNumber[VATValidator.DataItem.Status]);
   }
}
catch( Exception ex )
{
   LabelVATValidationStatus.Text = 
          "The following exception occurred while trying to obtain the requested VAT registration data: " + ex.Message;
}


if( !string.IsNullOrEmpty( WebMasterMessage ) )
{
   // There is a warning message from the VAT Registration Number Validator. Send an email to the webmaster.
   SendWarningNotification( "Warning from the VAT Registration Number Validator - [function name]", 
                           string.Format( "Warning from the VAT-Validation assembly. Message: {0}",
                                          WebMasterMessage ) );
}
The use of the VAT Validator class is simple and straightforward. First create an instance of the VAT Validator object and then execute the IsValidVAT( parameters ) method on that object. The return value of this call is either true or false depending on the circumstances. The registrant information is returned via a key-value dictionary which can be queried for any particular data item. Any administrative messages from the software to the webmaster are propagated through the WebMasterMessage ref parameter string. It is important to envelop the IsValidVAT( parameters ) function call in a try-catch block(s) as this method throws exceptions in cases when there are unrecoverable errors. Note that WebMasterMessage may contain a message to the webmaster even regardless of whether IsValidVAT( parameters ) has thrown an exception or not. The types of the thrown exceptions are documented in the VAT Registration Number Validator Reference Manual.
Reference Manual Download Now Buy Now
Community Content
(To enter your comments you must be signed in. Log in or create FREE account.)
MemberComments
Be the first to comment.
Products
Act On File
Audio Control
Custom Image Presenter
Photo Window
Vat # Validator
Custom Image Presenter
Homepage
for Galleries and Museums
for Hotels, Resorts and Cruises
for Parks of any kind
for Any Business
Learning
Encryption and Authentication
Safe Online Communication
Authenticable Website Testimonials
Learn how to store private keys
Make The Most From Your Files
Convenient Volume Control
Photo Window - an Awesome Gift
Support
My Account
FAQ - Forum
 
Community
Blog
Email this page
Newsletter
MBBSoftware
About
Contact
Buy Now
Download
Public Authentication Key
Public Encryption Key

Sitemap
Disclaimer
Privacy
Antispam
© Copyright 2017 MBBSoftware. All Rights Reserved.

Email this page
To:
use semicolon to separate emails eg: joe@abc.com; lea@abc.com
Subject:
Message:
a link to this page will be automatically added to your message
From:
Please type the anti-bot text below.
Type text:
Thank you for subscribing to the MBBSoftware newsletter.
Enter your email address:
Please type the anti-bot text below.
Type text: