├── .gitignore ├── LICENSE ├── README.md ├── example.php └── vatValidation.class.php /.gitignore: -------------------------------------------------------------------------------- 1 | .project 2 | .settings 3 | .buildpath -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Copyright (c) 2011, Edwin Hermans 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Vat Validation # 2 | 3 | ## About ## 4 | Vat-Validation is a PHP class allowing you to 5 | 6 | - Validate a VAT number 7 | - Retrieve information like the name or the address of the company 8 | 9 | The data is extracted from a European Commission webservice 10 | 11 | __It actually only works for European countries__ 12 | 13 | ## Usage ## 14 | 15 | require_once('vatValidation.class.php'); 16 | $vatValidation = new vatValidation( array('debug' => false)); 17 | $vatValidation->check($countryCode, $vatNumber)); 18 | 19 | Your instance can now access the following methods: 20 | 21 | $vatValidation->isValid() 22 | $vatValidation->getName() 23 | $vatValidation->getDenomination() 24 | $vatValidation->getAddress() 25 | 26 | You'll find an example in the example.php file 27 | 28 | ## Requirements ## 29 | 30 | PHP with Soap enabled 31 | 32 | ## Disclaimer ## 33 | 34 | Take a look at http://ec.europa.eu/taxation_customs/vies/viesdisc.do to know when/how you're allowed to use this service and his information -------------------------------------------------------------------------------- /example.php: -------------------------------------------------------------------------------- 1 | false)); 4 | 5 | 6 | if($vatValidation->check('BE', '0828639227')) { 7 | echo '
'. htmlentities($body).''; 85 | } 86 | private function cleanUpString($string) { 87 | for($i=0;$i<100;$i++) 88 | { 89 | $newString = str_replace(" "," ",$string); 90 | if($newString === $string) { 91 | break; 92 | } else { 93 | $string = $newString; 94 | } 95 | } 96 | 97 | $newString = ""; 98 | $words = explode(" ",$string); 99 | foreach($words as $k=>$w) 100 | { 101 | $newString .= ucfirst(strtolower($w))." "; 102 | } 103 | return $newString; 104 | } 105 | } 106 | 107 | ?> 108 | --------------------------------------------------------------------------------