Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

E.U. VAT Intracom Number


dennish

Recommended Posts

Hello,

 

Is anyone succesfully using the E.U. VAT Intracom Number add-on (http://addons.oscommerce.com/info/1848) on osC 2.3.3 (or any other version of osC)?

 

I get this error message when testing (adding new customer in create_account.php):

 

Warning: file_get_contents(http://ec.europa.eu/taxation_customs/vies/viesquer.do?ms=NL&iso=NL&vat=008888012B0) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 503 Service Unavailable

 

The url http://ec.europa.eu/taxation_customs/vies/viesquer.do?ms=NL&iso=NL&vat=008888012B0 opens fine in my browser, so the service itself is running normally ...

 

My validations.php file (in catalog/includes/functions) contains the following code:

 

function tep_verif_tva($num_tva){
$prefix = substr($num_tva, 0, 2);
if (array_search($prefix, tep_get_tva_intracom_array() ) === false) {
return 'false';
}
$tva = substr($num_tva, 2);
$monfd = file_get_contents('http://ec.europa.eu/taxation_customs/vies/viesquer.do?ms=' . $prefix . '&iso='.$prefix.'&vat=' . $tva, r);
if ( preg_match("/invalid VAT number/i", $monfd) ) {
 return 'false';
} elseif
( preg_match("/valid VAT number/i", $monfd) ){
return 'true';
} else {
$myVerif = 'no_verif';
}
return $myVerif;

}

 

Any help is much appreciated.

 

Kind regards,

 

Dennis

Link to comment
Share on other sites

Hi,

 

For what it is worth I never managed to get this working correctly on a 2.2 Rc2a site - so had to remove it.

Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Link to comment
Share on other sites

Hello Heather,

 

The server my osC runs on has trouble to process the file_get_contents request (which might be due to the API of the VIES service not being fully functional with IPv6. Same holds for the SOAP version).

 

My hosting provider suggested a workaround with curl (which I tested and works perfectly):

 

function tep_verif_tva($num_tva){
$prefix = substr($num_tva, 0, 2);
if (array_search($prefix, tep_get_tva_intracom_array() ) === false) {
 return 'false';
}
$tva = substr($num_tva, 2);

// $monfd = file_get_contents('http://ec.europa.eu/taxation_customs/vies/viesquer.do?ms=' . $prefix . '&iso='.$prefix.'&vat=' . $tva, r);
$url = 'http://ec.europa.eu/taxation_customs/vies/viesquer.do?ms=' . $prefix . '&iso='.$prefix.'&vat=' . $tva;
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_IPRESOLVE,CURL_IPRESOLVE_V4);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$monfd = curl_exec($ch);
// PHP 5.3+ compliance - Start
//  if ( eregi("invalid VAT number", $monfd) ) {
//   return 'false';
//  } elseif ( eregi("valid VAT number", $monfd) ){
 if ( preg_match("/invalid VAT number/i", $monfd) ) {
  return 'false';
 } elseif ( preg_match("/valid VAT number/i", $monfd) ){
// PHP 5.3+ compliance - End
  return 'true';
 } else {
  $myVerif = 'no_verif';
 }
return $myVerif;

curl_close($ch);

}

 

Hope this helps you too.

 

Kind regards,

 

Dennis

Link to comment
Share on other sites

  • 1 year later...

I would like to install this addon but I have one theoretical question

 

If somebody inserts a VAT number that is valid but not owned by the customers company, then he automattically gets tax free prices.

So how do I know he is not just camming me but really can order in behalf of this company?

Link to comment
Share on other sites

our accounting department always adds the printout that proofs the VAT number was valid at the time of purchase.

when inspected, it is up to us to proof that we could invoice tax free, so we do keep that proof with the invoice.

Personally, I think the validation is to catch typing errors upon input.

Edited by bruyndoncx

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

  • 6 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...