Skip to content

Commit

Permalink
Remove UK VAT checks
Browse files Browse the repository at this point in the history
  • Loading branch information
driesvints committed Feb 28, 2025
1 parent 6671959 commit 5fff70f
Showing 1 changed file with 1 addition and 33 deletions.
34 changes: 1 addition & 33 deletions src/VatCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -594,11 +594,6 @@ class VatCalculator
*/
protected $businessCountryCode = '';

/**
* @var string
*/
protected $ukValidationEndpoint = 'https://api.service.hmrc.gov.uk';

/**
* @param \Illuminate\Contracts\Config\Repository|array
*/
Expand Down Expand Up @@ -901,22 +896,7 @@ public function getVATDetails($vatNumber)
$vatNumber = substr($vatNumber, 2);

if (strtoupper($countryCode) === 'GB') {
$apiHeaders = get_headers("$this->ukValidationEndpoint/organisations/vat/check-vat-number/lookup/$vatNumber");
$apiHeaders = explode(' ', $apiHeaders[0]);
$apiStatusCode = (int) $apiHeaders[1];

if ($apiStatusCode === 400 || $apiStatusCode === 404) {
return false;
}

if ($apiStatusCode === 200) {
$apiResponse = file_get_contents("$this->ukValidationEndpoint/organisations/vat/check-vat-number/lookup/$vatNumber");
$apiResponse = json_decode($apiResponse, true);

return $apiResponse['target'];
}

throw new VATCheckUnavailableException("The UK VAT check service is currently unavailable (status code $apiStatusCode). Please try again later.");
throw new VATCheckUnavailableException("UK VAT checks are no longer available. Please see .");
} else {
$this->initSoapClient();
$client = $this->soapClient;
Expand Down Expand Up @@ -978,16 +958,4 @@ public function setSoapClient($soapClient)
{
$this->soapClient = $soapClient;
}

/**
* @return $this
*
* @internal This method is not covered by our BC policy.
*/
public function testing()
{
$this->ukValidationEndpoint = 'https://test-api.service.hmrc.gov.uk';

return $this;
}
}

0 comments on commit 5fff70f

Please sign in to comment.