PHPackages                             taxjar/taxjar-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. taxjar/taxjar-php

ActiveLibrary[API Development](/categories/api)

taxjar/taxjar-php
=================

Sales Tax API Client for PHP 8.0+

v2.0.1(1y ago)716.1M—4.4%24[1 issues](https://github.com/taxjar/taxjar-php/issues)[1 PRs](https://github.com/taxjar/taxjar-php/pulls)2MITPHPPHP ^8.0

Since Jul 14Pushed 1y ago13 watchersCompare

[ Source](https://github.com/taxjar/taxjar-php)[ Packagist](https://packagist.org/packages/taxjar/taxjar-php)[ Docs](https://www.taxjar.com/)[ RSS](/packages/taxjar-taxjar-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (27)Used By (2)

TaxJar Sales Tax API for PHP [![Packagist](https://camo.githubusercontent.com/ce96102cd37965d6280c812702c6fa2158078ae2dd367e2bbdcf5c2ff68148dc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7461786a61722f7461786a61722d7068702e737667)](https://packagist.org/packages/taxjar/taxjar-php) [![Build Status](https://camo.githubusercontent.com/8560592e9ffebb73587db8f30e7d420e97d7f509d82879f4cf4e9b9e722eba7e/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7461786a61722f7461786a61722d7068702e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/taxjar/taxjar-php)
==============================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#taxjar-sales-tax-api-for-php--)

Official PHP client for Sales Tax API v2. For the REST documentation, please visit [https://developers.taxjar.com/api](https://developers.taxjar.com/api/reference/?php).

---

[Requirements](#requirements)
[Installation](#installation)
[Authentication](#authentication)
[Usage](#usage)
[Custom Options](#custom-options)
[Sandbox Environment](#sandbox-environment)
[Error Handling](#error-handling)
[Testing](#testing)

---

Requirements
------------

[](#requirements)

- PHP 8.0 and later.
- [Guzzle](https://github.com/guzzle/guzzle) (included via Composer).

Installation
------------

[](#installation)

Use Composer and add `taxjar-php` as a dependency:

```
composer require taxjar/taxjar-php

```

```
{
  "require": {
    "taxjar/taxjar-php": "^2.0"
  }
}
```

If you get an error with `composer require`, update your `composer.json` directly and run `composer update`.

Authentication
--------------

[](#authentication)

```
require __DIR__ . '/vendor/autoload.php';
$client = TaxJar\Client::withApiKey($_ENV['TAXJAR_API_KEY']);
```

You're now ready to use TaxJar! [Check out our quickstart guide](https://developers.taxjar.com/api/guides/php/#php-quickstart) to get up and running quickly.

Usage
-----

[](#usage)

[`categories` - List all tax categories](#list-all-tax-categories-api-docs)
[`taxForOrder` - Calculate sales tax for an order](#calculate-sales-tax-for-an-order-api-docs)
[`listOrders` - List order transactions](#list-order-transactions-api-docs)
[`showOrder` - Show order transaction](#show-order-transaction-api-docs)
[`createOrder` - Create order transaction](#create-order-transaction-api-docs)
[`updateOrder` - Update order transaction](#update-order-transaction-api-docs)
[`deleteOrder` - Delete order transaction](#delete-order-transaction-api-docs)
[`listRefunds` - List refund transactions](#list-refund-transactions-api-docs)
[`showRefund` - Show refund transaction](#show-refund-transaction-api-docs)
[`createRefund` - Create refund transaction](#create-refund-transaction-api-docs)
[`updateRefund` - Update refund transaction](#update-refund-transaction-api-docs)
[`deleteRefund` - Delete refund transaction](#delete-refund-transaction-api-docs)
[`listCustomers` - List customers](#list-customers-api-docs)
[`showCustomer` - Show customer](#show-customer-api-docs)
[`createCustomer` - Create customer](#create-customer-api-docs)
[`updateCustomer` - Update customer](#update-customer-api-docs)
[`deleteCustomer` - Delete customer](#delete-customer-api-docs)
[`ratesForLocation` - List tax rates for a location (by zip/postal code)](#list-tax-rates-for-a-location-by-zippostal-code-api-docs)
[`nexusRegions` - List nexus regions](#list-nexus-regions-api-docs)
[`validateAddress` - Validate an address](#validate-an-address-api-docs)
[`validate` - Validate a VAT number](#validate-a-vat-number-api-docs)
[`summaryRates` - Summarize tax rates for all regions](#summarize-tax-rates-for-all-regions-api-docs)

---

### List all tax categories *([API docs](https://developers.taxjar.com/api/reference/?php#get-list-tax-categories))*

[](#list-all-tax-categories-api-docs)

> The TaxJar API provides product-level tax rules for a subset of product categories. These categories are to be used for products that are either exempt from sales tax in some jurisdictions or are taxed at reduced rates. You need not pass in a product tax code for sales tax calculations on product that is fully taxable. Simply leave that parameter out.

```
$categories = $client->categories();
```

### Calculate sales tax for an order *([API docs](https://developers.taxjar.com/api/reference/?php#post-calculate-sales-tax-for-an-order))*

[](#calculate-sales-tax-for-an-order-api-docs)

> Shows the sales tax that should be collected for a given order.

```
$order_taxes = $client->taxForOrder([
  'from_country' => 'US',
  'from_zip' => '07001',
  'from_state' => 'NJ',
  'from_city' => 'Avenel',
  'from_street' => '305 W Village Dr',
  'to_country' => 'US',
  'to_zip' => '07446',
  'to_state' => 'NJ',
  'to_city' => 'Ramsey',
  'to_street' => '63 W Main St',
  'amount' => 16.50,
  'shipping' => 1.5,
  'line_items' => [
    [
      'id' => '1',
      'quantity' => 1,
      'product_tax_code' => '31000',
      'unit_price' => 15.0,
      'discount' => 0
    ]
  ]
]);

echo $order_taxes->amount_to_collect;
// 1.26
```

### List order transactions *([API docs](https://developers.taxjar.com/api/reference/?php#get-list-order-transactions))*

[](#list-order-transactions-api-docs)

> Lists existing order transactions created through the API.

```
$orders = $client->listOrders([
  'from_transaction_date' => '2015/05/01',
  'to_transaction_date' => '2015/05/31'
]);
```

### Show order transaction *([API docs](https://developers.taxjar.com/api/reference/?php#get-show-an-order-transaction))*

[](#show-order-transaction-api-docs)

> Shows an existing order transaction created through the API.

```
$order = $client->showOrder('123');
```

### Create order transaction *([API docs](https://developers.taxjar.com/api/reference/?php#post-create-an-order-transaction))*

[](#create-order-transaction-api-docs)

> Creates a new order transaction.

```
$order = $client->createOrder([
  'transaction_id' => '123',
  'transaction_date' => '2015/05/14',
  'from_country' => 'US',
  'from_zip' => '92093',
  'from_state' => 'CA',
  'from_city' => 'La Jolla',
  'from_street' => '9500 Gilman Drive',
  'to_country' => 'US',
  'to_zip' => '90002',
  'to_state' => 'CA',
  'to_city' => 'Los Angeles',
  'to_street' => '123 Palm Grove Ln',
  'amount' => 17.45,
  'shipping' => 1.5,
  'sales_tax' => 0.95,
  'line_items' => [
    [
      'id' => '1',
      'quantity' => 1,
      'product_identifier' => '12-34243-9',
      'description' => 'Fuzzy Widget',
      'unit_price' => 15.0,
      'discount': 0,
      'sales_tax' => 0.95
    ]
  ]
]);
```

### Update order transaction *([API docs](https://developers.taxjar.com/api/reference/?php#put-update-an-order-transaction))*

[](#update-order-transaction-api-docs)

> Updates an existing order transaction created through the API.

```
$order = $client->updateOrder([
  'transaction_id' => '123',
  'amount' => 17.95,
  'shipping' => 2.0,
  'line_items' => [
    [
      'quantity' => 1,
      'product_identifier' => '12-34243-0',
      'description' => 'Heavy Widget',
      'unit_price' => 15.0,
      'discount' => 0.0,
      'sales_tax' => 0.95
    ]
  ]
]);
```

### Delete order transaction *([API docs](https://developers.taxjar.com/api/reference/?php#delete-delete-an-order-transaction))*

[](#delete-order-transaction-api-docs)

> Deletes an existing order transaction created through the API.

```
$client->deleteOrder('123');
```

### List refund transactions *([API docs](https://developers.taxjar.com/api/reference/?php#get-list-refund-transactions))*

[](#list-refund-transactions-api-docs)

> Lists existing refund transactions created through the API.

```
$refunds = $client->listRefunds([
  'from_transaction_date' => '2015/05/01',
  'to_transaction_date' => '2015/05/31'
]);
```

### Show refund transaction *([API docs](https://developers.taxjar.com/api/reference/?php#get-show-a-refund-transaction))*

[](#show-refund-transaction-api-docs)

> Shows an existing refund transaction created through the API.

```
$refund = $client->showRefund('123-refund');
```

### Create refund transaction *([API docs](https://developers.taxjar.com/api/reference/?php#post-create-a-refund-transaction))*

[](#create-refund-transaction-api-docs)

> Creates a new refund transaction.

```
$refund = $client->createRefund([
  'transaction_id' => '123-refund',
  'transaction_reference_id' => '123',
  'transaction_date' => '2015/05/14',
  'from_country' => 'US',
  'from_zip' => '92093',
  'from_state' => 'CA',
  'from_city' => 'La Jolla',
  'from_street' => '9500 Gilman Drive',
  'to_country' => 'US',
  'to_zip' => '90002',
  'to_state' => 'CA',
  'to_city' => 'Los Angeles',
  'to_street' => '123 Palm Grove Ln',
  'amount' => -17.45,
  'shipping' => -1.5,
  'sales_tax' => -0.95,
  'line_items' => [
    [
      'id' => '1',
      'quantity' => 1,
      'product_identifier' => '12-34243-9',
      'description' => 'Fuzzy Widget',
      'unit_price' => -15.0,
      'discount' => -0,
      'sales_tax' => -0.95
    ]
  ]
]);
```

### Update refund transaction *([API docs](https://developers.taxjar.com/api/reference/?php#put-update-a-refund-transaction))*

[](#update-refund-transaction-api-docs)

> Updates an existing refund transaction created through the API.

```
$refund = $client->updateRefund([
  'transaction_id' => '123-refund',
  'transaction_reference_id' => '123',
  'amount' => -17.95,
  'shipping' => -2.0,
  'line_items' => [
    [
      'id' => '1',
      'quantity' => 1,
      'product_identifier' => '12-34243-0',
      'description' => 'Heavy Widget',
      'unit_price' => -15.0,
      'discount' => -0,
      'sales_tax' => -0.95
    ]
  ]
]);
```

### Delete refund transaction *([API docs](https://developers.taxjar.com/api/reference/?php#delete-delete-a-refund-transaction))*

[](#delete-refund-transaction-api-docs)

> Deletes an existing refund transaction created through the API.

```
$client->deleteRefund('123-refund');
```

### List customers *([API docs](https://developers.taxjar.com/api/reference/?php#get-list-customers))*

[](#list-customers-api-docs)

> Lists existing customers created through the API.

```
$customers = $client->listCustomers();
```

### Show customer *([API docs](https://developers.taxjar.com/api/reference/?php#get-show-a-customer))*

[](#show-customer-api-docs)

> Shows an existing customer created through the API.

```
$customer = $client->showCustomer('123');
```

### Create customer *([API docs](https://developers.taxjar.com/api/reference/?php#post-create-a-customer))*

[](#create-customer-api-docs)

> Creates a new customer.

```
$customer = $client->createCustomer([
  'customer_id' => '123',
  'exemption_type' => 'wholesale',
  'name' => 'Dunder Mifflin Paper Company',
  'exempt_regions' => [
    [
      'country' => 'US',
      'state' => 'FL'
    ],
    [
      'country' => 'US',
      'state' => 'PA'
    ]
  ],
  'country' => 'US',
  'state' => 'PA',
  'zip' => '18504',
  'city' => 'Scranton',
  'street' => '1725 Slough Avenue'
]);
```

### Update customer *([API docs](https://developers.taxjar.com/api/reference/?php#put-update-a-customer))*

[](#update-customer-api-docs)

> Updates an existing customer created through the API.

```
$customer = $client->updateCustomer([
  'customer_id' => '123',
  'exemption_type' => 'wholesale',
  'name' => 'Sterling Cooper',
  'exempt_regions' => [
    [
      'country' => 'US',
      'state' => 'NY'
    ]
  ],
  'country' => 'US',
  'state' => 'NY',
  'zip' => '10010',
  'city' => 'New York',
  'street' => '405 Madison Ave'
]);
```

### Delete customer *([API docs](https://developers.taxjar.com/api/reference/?php#delete-delete-a-customer))*

[](#delete-customer-api-docs)

> Deletes an existing customer created through the API.

```
$client->deleteCustomer('123');
```

### List tax rates for a location (by zip/postal code) *([API docs](https://developers.taxjar.com/api/reference/?php#get-show-tax-rates-for-a-location))*

[](#list-tax-rates-for-a-location-by-zippostal-code-api-docs)

> Shows the sales tax rates for a given location.
>
> **Please note this method only returns the full combined rate for a given location.** It does not support nexus determination, sourcing based on a ship from and ship to address, shipping taxability, product exemptions, customer exemptions, or sales tax holidays. We recommend using [`taxForOrder` to accurately calculate sales tax for an order](#calculate-sales-tax-for-an-order-api-docs).

```
$rates = $client->ratesForLocation(90002, [
  'city' => 'LOS ANGELES',
  'country' => 'US'
]);

echo $rates->combined_rate;
// 0.09
```

### List nexus regions *([API docs](https://developers.taxjar.com/api/reference/?php#get-list-nexus-regions))*

[](#list-nexus-regions-api-docs)

> Lists existing nexus locations for a TaxJar account.

```
$nexus_regions = $client->nexusRegions();
```

### Validate an address *([API docs](https://developers.taxjar.com/api/reference/?php#post-validate-an-address))*

[](#validate-an-address-api-docs)

> Validates a customer address and returns back a collection of address matches. **Address validation requires a [TaxJar Plus](https://www.taxjar.com/plus/) subscription.**

```
$addresses = $client->validateAddress([
  'country' => 'US',
  'state' => 'AZ',
  'zip' => '85297',
  'city' => 'Gilbert',
  'street' => '3301 South Greenfield Rd'
]);
```

### Validate a VAT number *([API docs](https://developers.taxjar.com/api/reference/?php#get-validate-a-vat-number))*

[](#validate-a-vat-number-api-docs)

> Validates an existing VAT identification number against [VIES](http://ec.europa.eu/taxation_customs/vies/).

```
$validation = $client->validate([
  'vat' => 'FR40303265045'
]);
```

### Summarize tax rates for all regions *([API docs](https://developers.taxjar.com/api/reference/?php#get-summarize-tax-rates-for-all-regions))*

[](#summarize-tax-rates-for-all-regions-api-docs)

> Retrieve minimum and average sales tax rates by region as a backup.
>
> This method is useful for periodically pulling down rates to use if the TaxJar API is unavailable. However, it does not support nexus determination, sourcing based on a ship from and ship to address, shipping taxability, product exemptions, customer exemptions, or sales tax holidays. We recommend using [`taxForOrder` to accurately calculate sales tax for an order](#calculate-sales-tax-for-an-order-api-docs).

```
$summarized_rates = $client->summaryRates();
```

Sandbox Environment
-------------------

[](#sandbox-environment)

You can easily configure the client to use the [TaxJar Sandbox](https://developers.taxjar.com/api/reference/?php#sandbox-environment):

```
require __DIR__ . '/vendor/autoload.php';
$client = TaxJar\Client::withApiKey($_ENV['TAXJAR_SANDBOX_API_KEY']);
$client->setApiConfig('api_url', TaxJar\Client::SANDBOX_API_URL);
```

For testing specific [error response codes](https://developers.taxjar.com/api/reference/?php#errors), pass the custom `X-TJ-Expected-Response` header:

```
$client->setApiConfig('headers', [
  'X-TJ-Expected-Response' => 422
]);
```

Custom Options
--------------

[](#custom-options)

### Timeout

[](#timeout)

> This package utilizes Guzzle which defaults to a request timeout value of 0s, allowing requests to remain pending for an indefinite period of time.
>
> You can modify this behavior by configuring the client with a `timeout` value in seconds.

```
$client->setApiConfig('timeout', 30);
```

### API Version

[](#api-version)

> By default, TaxJar's API will respond to requests with the [latest API version](https://developers.taxjar.com/api/reference/#changelog) when a version header is not present on the request.
>
> To request a specific API version, include the `x-api-version` header with the desired version string.

```
$client->setApiConfig('headers', [
  'x-api-version' => '2020-08-07'
]);
```

Error Handling
--------------

[](#error-handling)

When invalid data is sent to TaxJar or we encounter an error, we’ll throw a `TaxJar\Exception` with the HTTP status code and error message. To catch these exceptions, refer to the example below:

```
require __DIR__ . '/vendor/autoload.php';
$client = TaxJar\Client::withApiKey($_ENV['TAXJAR_API_KEY']);

try {
  // Invalid request
  $order = $client->createOrder([
    'transaction_date' => '2015/05/14',
    'from_country' => 'US',
    'from_zip' => '07001',
    'from_state' => 'NJ',
    'from_city' => 'Avenel',
    'from_street' => '305 W Village Dr',
    'to_country' => 'US',
    'to_zip' => '90002',
    'to_state' => 'CA',
    'to_city' => 'Ramsey',
    'to_street' => '63 W Main St',
    'amount' => 16.5,
    'shipping' => 1.5,
    'sales_tax' => 0.95,
    'line_items' => [
      [
        'id' => '1',
        'quantity' => 1,
        'product_tax_code' => '31000',
        'unit_price' => 15,
        'discount' => 0,
        'sales_tax' => 0.95
      ]
    ]
  ]);
} catch (TaxJar\Exception $e) {
  // 406 Not Acceptable – transaction_id is missing
  echo $e->getMessage();

  // 406
  echo $e->getStatusCode();
}
```

For a full list of error codes, [click here](https://developers.taxjar.com/api/reference/?php#errors).

Testing
-------

[](#testing)

Make sure PHPUnit is installed via `composer install` and run the following:

```
php vendor/bin/phpunit test/specs/.

```

To enable debug mode, set the following config parameter after authenticating:

```
$client->setApiConfig('debug', true);
```

###  Health Score

58

—

FairBetter than 98% of packages

Maintenance49

Moderate activity, may be stable

Popularity59

Moderate usage in the ecosystem

Community30

Small or concentrated contributor base

Maturity78

Established project with proven stability

 Bus Factor1

Top contributor holds 60.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~143 days

Recently: every ~450 days

Total

26

Last Release

375d ago

Major Versions

v1.10.4 → v2.0.02022-10-03

PHP version history (3 changes)v1.0.0PHP &gt;=5.3.3

v1.2.3PHP &gt;=5.5.0

v2.0.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/84dc6cd9a6d174bd985b181655bf8946589ee88d5075d1b4a6c0414813018341?d=identicon)[fastdivision](/maintainers/fastdivision)

![](https://www.gravatar.com/avatar/042b832bb1a3ea4bd27f01e2b99ba6d9b5d7b7486edd878ccadeb705261b435c?d=identicon)[TaxJar](/maintainers/TaxJar)

---

Top Contributors

[![fastdivision](https://avatars.githubusercontent.com/u/1137184?v=4)](https://github.com/fastdivision "fastdivision (87 commits)")[![ScottRudiger](https://avatars.githubusercontent.com/u/26824724?v=4)](https://github.com/ScottRudiger "ScottRudiger (27 commits)")[![sethobey](https://avatars.githubusercontent.com/u/47947793?v=4)](https://github.com/sethobey "sethobey (11 commits)")[![makstech](https://avatars.githubusercontent.com/u/25028046?v=4)](https://github.com/makstech "makstech (4 commits)")[![sethobey-stripe](https://avatars.githubusercontent.com/u/93532842?v=4)](https://github.com/sethobey-stripe "sethobey-stripe (4 commits)")[![bobbarn](https://avatars.githubusercontent.com/u/1882691?v=4)](https://github.com/bobbarn "bobbarn (2 commits)")[![kylechallis](https://avatars.githubusercontent.com/u/2374759?v=4)](https://github.com/kylechallis "kylechallis (2 commits)")[![andyg5000](https://avatars.githubusercontent.com/u/1800052?v=4)](https://github.com/andyg5000 "andyg5000 (2 commits)")[![saville-stripe](https://avatars.githubusercontent.com/u/88848893?v=4)](https://github.com/saville-stripe "saville-stripe (2 commits)")[![VladimirRebilly](https://avatars.githubusercontent.com/u/144002104?v=4)](https://github.com/VladimirRebilly "VladimirRebilly (1 commits)")[![rrehbein](https://avatars.githubusercontent.com/u/140358?v=4)](https://github.com/rrehbein "rrehbein (1 commits)")[![acdameli](https://avatars.githubusercontent.com/u/634040?v=4)](https://github.com/acdameli "acdameli (1 commits)")

---

Tags

ecommercephpsales-taxsales-tax-apitaxtax-ratetaxjarapitaxjarsales tax

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/taxjar-taxjar-php/health.svg)

```
[![Health](https://phpackages.com/badges/taxjar-taxjar-php/health.svg)](https://phpackages.com/packages/taxjar-taxjar-php)
```

###  Alternatives

[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)[mailchimp/transactional

458.9M16](/packages/mailchimp-transactional)[get-stream/stream-chat

A PHP client for Stream Chat (https://getstream.io/chat/)

301.8M2](/packages/get-stream-stream-chat)[convertkit/convertkitapi

Kit PHP SDK for the Kit API

2167.1k1](/packages/convertkit-convertkitapi)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
