You are here

private function VatNumberController::validateVatNumber in VAT Number 8

Validate the VAT number on the EU database.

1 call to VatNumberController::validateVatNumber()
VatNumberController::check in src/Controller/VatNumberController.php
Checks the VAT number format on the database.

File

src/Controller/VatNumberController.php, line 50

Class

VatNumberController
Defines a controller to validate the VAT Number.

Namespace

Drupal\vat_number\Controller

Code

private function validateVatNumber() {
  if ($this->cleint) {
    $params = [
      'countryCode' => $this->vatInfo['country_code'],
      'vatNumber' => $this->vatInfo['vatNumber'],
    ];
    try {
      $r = $this->cleint
        ->checkVat($params);
      if ($r->valid != TRUE) {
        $this->valid = FALSE;
        return FALSE;
      }
      return TRUE;
    } catch (SoapFault $e) {
      \Drupal::logger('var_number')
        ->error($e->faultstring);
    }
  }
}