Wrapper for Avalara Tax API
composer require mjmarianetti/avalara-php
Add the next line to your service providers
Mjmarianetti\Avalara\AvalaraServiceProvider::class,
Publish avalara.php config file
php artisan vendor:publish --provider="Mjmarianetti\Avalara\AvalaraServiceProvider"
use Mjmarianetti\Avalara\AvalaraClient;
$client = new AvalaraClient('API_KEY');
$params = [
'country' => 'usa',
'street' => '435 Ericksen Ave NE',
'city' => 'Bainbridge Island',
'state' => 'WA',
'postal' => '98110'
];
$response = $client->getTaxesByAddress($params);
var_dump($response);
If using Laravel, you can inject it as a dependency
public funcion index(AvalaraClient $client){
$params = [
'country' => 'usa',
'street' => '435 Ericksen Ave NE',
'city' => 'Bainbridge Island',
'state' => 'WA',
'postal' => '98110'
];
$client->getTaxesByAddress($params);
}
##Methods:
$params = [
'country' => 'usa',
'street' => '435 Ericksen Ave NE',
'city' => 'Bainbridge Island',
'state' => 'WA',
'postal' => '98110'
];
$client->getTaxesByAddress($params);
$params = [
'country' => 'usa',
'postal' => '98104'
];
$client->getTaxesByPostal($params);