Recientemente me he encontrado con muchos ecommerce que tienen este problema a la hora de validad los VAT Number de los clientes Europeos.
El modulo responsable es «vatnumber».
Básicamente a la hora de intentar validar el VAT Number el webservice no da una respuesta correcta. Es como si el webservice al que llama dicho modulo ya no funcionase.
He hecho una modificación al modulo de VAT Number modificando la función WebServiceCheck:
public static function WebServiceCheck($vat_number) { if (empty($vat_number)) return array(); $vat_number = str_replace(' ', '', $vat_number); $prefix = Tools::substr($vat_number, 0, 2); if (array_search($prefix, self::getPrefixIntracomVAT()) === false) return array(Tools::displayError('Invalid VAT number')); $vat = Tools::substr($vat_number, 2); $url = 'http://ec.europa.eu/taxation_customs/vies/services/checkVatService'; $contenido = array("method" => "POST", "content" => '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns1="urn:ec.europa.eu:taxud:vies:services:checkVat:types" xmlns:impl="urn:ec.europa.eu:taxud:vies:services:checkVat"> <soap:Header> </soap:Header> <soap:Body> <tns1:checkVat xmlns:tns1="urn:ec.europa.eu:taxud:vies:services:checkVat:types" xmlns="urn:ec.europa.eu:taxud:vies:services:checkVat:types"> <tns1:countryCode>'.$prefix.'</tns1:countryCode> <tns1:vatNumber>'.$vat.'</tns1:vatNumber> </tns1:checkVat> </soap:Body> </soap:Envelope>'); $params = stream_context_set_default(array("http" => $contenido)); @ini_set('default_socket_timeout', 5); $page_res = Tools::file_get_contents_xml($url, false, $params); if ($page_res) { if (preg_match('/<valid>false/i', $page_res)) { @ini_restore('default_socket_timeout'); return array(Tools::displayError('VAT number not found')); } else if (preg_match('/<valid>true/i', $page_res)) { @ini_restore('default_socket_timeout'); return array(); } else ++$i; } @ini_restore('default_socket_timeout'); return array(Tools::displayError('VAT number validation service unavailable')); }
Y añadiendo esta función a la clase Tools:
public static function file_get_contents_xml($url, $use_include_path = false, $stream_context = null, $curl_timeout = 5) { $curl = curl_init(); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($curl, CURLOPT_TIMEOUT, $curl_timeout); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); if ($stream_context != null) { $opts = stream_context_get_options($stream_context); if (isset($opts['http']['method']) && Tools::strtolower($opts['http']['method']) == 'post') { curl_setopt($curl, CURLOPT_POST, true); if (isset($opts['http']['content'])) { curl_setopt($curl, CURLOPT_POSTFIELDS, $opts['http']['content']); } } } $content = curl_exec($curl); curl_close($curl); return $content; }
Esta solución lo que hará es llamar de otro modo al webservice y recogiendo la respuesta de una forma correcta.
Modifica tu tienda en un solo sitio Si por algún motivo, no utilizas multitienda y dispones de dos tiendas exactamente…
En el proceso de compra no se muestran las opciones de pago Si te has encontrado con este problema, después…
/migrations#rm -rf ./* #php bin/console doctrine:migrations:generate #php bin/console doctrine:migrations:migrate #php bin/console doctrine:migrations:current #php bin/console doctrine:migrations:diff #php bin/console c:c #php bin/console…
Pasos para inicializar un proyecto Symfony 5 y un panel de control de entidades Inicializando Symfony: Si no tenemos el comando…
MODULOS DE ODOO NECESARIOS PARA UN ECOMMERCE Enlaces de OCA de interes: En el siguiente enlace existen un montón de…
Migración de un prestashop 1.7 de un dominio a otro. Copiamos la BBDD del antiguo hosting al nuevo. Copiamos los…