getValue(); if (empty($value)) { return true; } $formattedValue = preg_replace('/[ \-,.]/', '', $value); $countryCode = substr($formattedValue, 0, 2); // get country code - first two letters of VAT ID $vatNumber = substr($formattedValue, 2); if (!class_exists('SoapClient')) { throw new \Exception('The Soap library has to be installed and enabled.'); } try { $client = new \SoapClient(self::WEBSERVICE_URL, array('trace' => true)); } catch (\Exception $e) { throw new \Exception('Web Service Error: ' . $e->getMessage()); } try { $rs = $client->checkVat(array('countryCode' => $countryCode, 'vatNumber' => $vatNumber)); if ($rs->valid) { return true; } } catch (\Exception $e) { } $this->setMessage( str_replace('%value%', $value, $this->getMessage())); return false; } }