public function SerbianVat::doVerify in Commerce Core 8.2
Performs the tax number verification.
Parameters
string $tax_number: The tax number.
Return value
\Drupal\commerce_tax\Plugin\Commerce\TaxNumberType\VerificationResult The verification result.
Overrides TaxNumberTypeWithVerificationBase::doVerify
File
- modules/
tax/ tests/ modules/ commerce_tax_test/ src/ Plugin/ Commerce/ TaxNumberType/ SerbianVat.php, line 33
Class
- SerbianVat
- Provides the Serbian VAT tax number type.
Namespace
Drupal\commerce_tax_test\Plugin\Commerce\TaxNumberTypeCode
public function doVerify($tax_number) {
$timestamp = $this->time
->getRequestTime();
if ($tax_number == '190') {
// Simulate the remote service being unavailable.
return VerificationResult::unknown($timestamp, [
'error' => 'http_429',
]);
}
if ($tax_number % 2 === 0) {
// Even numbers cannot be verified.
return VerificationResult::failure($timestamp);
}
else {
return VerificationResult::success($timestamp, [
'name' => 'John Smith',
'nonce' => mt_rand(0, 1000),
]);
}
}