40 protected $_sWsdl =
'http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl';
58 $oCheckVat =
new stdClass();
81 if (!$sErrorMsg || $sErrorMsg ==
'INVALID_INPUT') {
83 $oEx =
oxNew(
'oxInputException');
84 $oEx->setMessage(
'VAT_MESSAGE_' . ($sErrorMsg ? $sErrorMsg :
'ID_NOT_VALID'));
89 $oEx =
oxNew(
'oxConnectionException');
91 $oEx->setMessage(
'VAT_MESSAGE_' . $sErrorMsg);
109 if (isset(self::$_aVatCheckCache[$sCompVatId])) {
110 if (
true === self::$_aVatCheckCache[$sCompVatId]) {
113 if (is_string(self::$_aVatCheckCache[$sCompVatId])) {
114 $this->
_parseError(self::$_aVatCheckCache[$sCompVatId]);
120 $oCheckVat =
new stdClass();
121 $oCheckVat->countryCode = substr($sCompVatId, 0, 2);
122 $oCheckVat->vatNumber = substr($sCompVatId, 2);
126 self::$_aVatCheckCache[$sCompVatId] = $sErrorMsg;
130 return self::$_aVatCheckCache[$sCompVatId] =
true;
147 $sLogMessage =
"Warning: $sErrStr in $sErrFile on line $iErrLine";
150 $oEx =
oxNew(
"oxException");
151 $sLogFileName = $oEx->getLogFileName();
167 if ($this->_blServiceIsOn === null) {
168 $this->_blServiceIsOn = class_exists(
'SoapClient') ?
true :
false;
169 if ($this->_blServiceIsOn) {
171 $this->_blServiceIsOn = $rFp !==
false;
172 if ($this->_blServiceIsOn) {
174 while (!feof($rFp)) {
175 $sWsdl .= fread($rFp, 8192);
181 $oDomDocument =
new DOMDocument();
182 $oDomDocument->loadXML($sWsdl);
185 $this->_blServiceIsOn =
false;
209 ini_set(
'default_socket_timeout', 5);
212 set_error_handler(array($this,
'catchWarning'), E_WARNING);
217 $oSoapClient =
new SoapClient($this->
getWsdlUrl(), array(
"connection_timeout" => 5));
219 $oRes = $oSoapClient->checkVat($oCheckVat);
221 }
catch (SoapFault $e) {
223 if ($this->
getError() ==
"SERVER_BUSY") {
224 usleep(self::BUSY_RETRY_WAITUSEC);
229 }
while (0 < $iTryMoreCnt--);
232 restore_error_handler();
234 return (
bool) $oRes->valid;
236 $this->
setError(
"SERVICE_UNREACHABLE");
252 if ($this->_sError) {
253 $sRegex =
'/\{ \'([A-Z_]*)\' \}/';
254 $n = preg_match($sRegex, $this->_sError, $aMatches);
255 $sError = ($aMatches[1]) ? $aMatches[1] :
'SERVICE_UNAVAILABLE';
270 $this->_sWsdl = $sWsdl;