Skip to content

Commit

Permalink
Check Vatlayer database return for failure.
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinElst authored and peterjaap committed Dec 15, 2023
1 parent 3431dc7 commit f63fea2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Service/Validate/Vatlayer.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,18 @@ public function validateVATNumber(string $vatNumber, string $countryIso2): bool
throw new ValidationFailedException('Vatlayer could not be queried ' . $result['error']['info']);
}

if (! isset($result['valid'])) {
if ((! isset($result['valid'])) || (! isset($result['database']))) {
throw new ValidationIgnoredException('Vatlayer did not return validation');
}

if ($result['database'] === 'failure') {
throw new ValidationFailedException('Vatlayer returns: database failure (could not connect to member state)');
}

if ($result['database'] !== 'ok') {
throw new ValidationFailedException('Vatlayer database not ok');
}

return (bool)$result['valid'];
}
}

0 comments on commit f63fea2

Please sign in to comment.