Fixes for Zip Tax Response

This commit is contained in:
David Bomba 2023-05-15 14:38:11 +10:00
parent 63da663afa
commit 913599334b
2 changed files with 15 additions and 6 deletions

View File

@ -144,6 +144,8 @@ class Rule extends BaseRule implements RuleInterface
*/ */
public function default(): self public function default(): self
{ {
nlog("default rate");
nlog($this->tax_data);
if($this->tax_data?->stateSalesTax == 0) { if($this->tax_data?->stateSalesTax == 0) {

View File

@ -31,17 +31,17 @@ class ZipTax implements TaxProviderInterface
$response = $this->callApi(['key' => $this->api_key, 'address' => $string_address]); $response = $this->callApi(['key' => $this->api_key, 'address' => $string_address]);
if($response->successful()) if($response->successful()){
return $response->json();
return $this->parseResponse($response->json());
}
if(isset($this->address['postal_code'])) { if(isset($this->address['postal_code'])) {
$response = $this->callApi(['key' => $this->api_key, 'address' => $this->address['postal_code']]); $response = $this->callApi(['key' => $this->api_key, 'address' => $this->address['postal_code']]);
nlog($response->json());
nlog($response->body());
if($response->successful()) if($response->successful())
return $response->json(); return $this->parseResponse($response->json());
} }
@ -69,4 +69,11 @@ class ZipTax implements TaxProviderInterface
return $response; return $response;
} }
private function parseResponse($response)
{
$tax = $response['results']['0'];
return $tax;
}
} }