Magento Forum

Page 3 of 3
Added EU VAT ID validation service integration
 
tbousiou
Jr. Member
 
Total Posts:  4
Joined:  2012-05-12
 

I use Mageneto CE 1.7.0.2 and i noticed that i can not validate VAT numbers from my store country (Greece). I tested VAT numbers from other EU countries and it was ok.

I spent a few hours and i think i found the solution. The VIES system uses country code EL for Greece (HELLAS is the country name we use inside our country) and magento uses the standard country code GR for greece.

i changed function checkVatNumber in app/code/core/mage/customer/helper/data.php (the if statement before try)

public function checkVatNumber($countryCode$vatNumber$requesterCountryCode ''$requesterVatNumber '')
    
{
        
// Default response
        
$gatewayResponse = new Varien_Object(array(
            
'is_valid' => false,
            
'request_date' => '',
            
'request_identifier' => '',
            
'request_success' => false
        
));

        if (!
extension_loaded('soap')) {
            Mage
::logException(Mage::exception('Mage_Core',
                
Mage::helper('core')->__('PHP SOAP extension is required.')));
            return 
$gatewayResponse;
        
}

        
if (!$this->canCheckVatNumber($countryCode$vatNumber$requesterCountryCode$requesterVatNumber)) {
            
return $gatewayResponse;
        
}
       
        
//greek "hack" for VIES SYSTEM
        
if ($countryCode ==='GR'{$countryCode ='EL';}

        
try {

and it worked, it validates my country VAT numbers. i thought of changing it to the database but i dont know the implications. should i report this as a bug?

 
Magento Community Magento Community
Magento Community
Magento Community
 
breda
Jr. Member
 
Total Posts:  4
Joined:  2012-02-03
 

Has anyone got this problem with the VAT checker?
I followed the instructions for 1.7 on the Magento Guide, and I have the validation working on the Admin Area in Configuration- General - Company VAT No. that seems to work. But my problem is it does not give me a vaidate button or seem to validate automatically on the Customer Check out Screens, I’ve tried it with Shipping address, Billing address, create a new customer in the admin area, none of them have a vaidate button and if I just add in a number it just accepts it.

Should there be a Validate button on the customer Shipping page beside the VAT No. box?
thanks,
B

 
Magento Community Magento Community
Magento Community
Magento Community
 
roman204
Jr. Member
 
Avatar
Total Posts:  4
Joined:  2011-01-28
Linz/Austria
 

it could be a problem with the redirect which was made when the old service url is called… but thats only a guess

you could try my extension here
it overrides the Mage_Customer_Helper_Data, sets the new validation-service-url and checks if the first two signs are a country code or not…
if you use it, deactivate every other class which overrides the Mage_Customer_Helper_Data .

 
Magento Community Magento Community
Magento Community
Magento Community
 
dparker
Jr. Member
 
Total Posts:  3
Joined:  2012-07-20
 

I’ve managed to fix my particular problem of our own VAT number not validating to start with by changing the VIES WSDL URL in the data.php file.

app/code/core/mage/customer/helper/data.php

Roughly line 74

/**
* WSDL of VAT validation service
*
*/
const VAT_VALIDATION_WSDL_URL = ‘http://ec.europa.eu/taxation_customs/vies/services/checkVatService.wsdl’;

change the URL to http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl as per the information provided by VIES on this site http://ec.europa.eu/taxation_customs/vies/faq.html Q16

 
Magento Community Magento Community
Magento Community
Magento Community
 
kvangest
Jr. Member
 
Total Posts:  12
Joined:  2013-02-11
 

I managed to fix this problem by adding an entry in the /etc/hosts file on the server that is making the request.

The problem was that on my server IPv6 was enabled and ec.europa.eu accepts IPv6 requests but responds to them using IPv6

And that causes the SOAP request to fail.

Adding the following the line in /etc/hosts/ worked for me

147.67.136.103 ec.europa.eu

This forces the usage of IPv4

 
Magento Community Magento Community
Magento Community
Magento Community
 
tphoare
Jr. Member
 
Total Posts:  2
Joined:  2012-05-15
 

I seem to have got this working now after quite a bit of fiddling.  The only thing I am not now clear about is this - There seems to be no indication on the front end of whether VAT validation has been successful or not.

I have tested this in every possible way but if an invalid VAT number is entered there is no indication to the customer apart from the fact that VAT is added.  Equally the same transaction repeated but with the correct VAT number entered completes correctly with no VAT added but equally no indication that the validation has taken place and succeeded.

Is this correct or should there be some success or failure message box or a message that the EU site is not working (which is quite often the case)

 
Magento Community Magento Community
Magento Community
Magento Community
 
AlojamientoTecnico
Jr. Member
 
Total Posts:  1
Joined:  2010-10-12
 

Hi,

VAT verificación fails when you use ipv6, if your reject it, Magento will try over ipv4 and it will work:

# dig +short aaaa ec.europa.eu
2001:bc8:3408:200::2
2001:bc8:3408:100::2
#

ip6tables -I OUTPUT -m tcp -p tcp -d 2001:bc8:3408:100::2 -j REJECT
ip6tables -I OUTPUT -m tcp -p tcp -d 2001:bc8:3408:200::2 -j REJECT

Should be elegant, create a script to upgrade this rules, maybe some day the ups are changed by owner.

You can also use IPv6 proxy to IPv4.

 
Magento Community Magento Community
Magento Community
Magento Community
 
oMikR0n
Jr. Member
 
Total Posts:  4
Joined:  2013-12-03
 

Thank you all for your help! Really appreciated!

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 3 of 3