This is a PHP sample demonstrating the AvaTax REST API methods: tax/get POST, tax/get GET, tax/cancel POST, and address/validate GET.
For more information on the use of these methods and the AvaTax product, please visit our developer site or homepage
Authentication requires an valid Account Number and License Key, which should be entered in the test file (e.g. GetTaxTest.php) you would like to run.
If you do not have an AvaTax account, a free trial account can be acquired through our developer site
Some Windows users have had trouble with cURL automatically using our SSL certificate. The sample code offers two workarounds (both in /AvaTaxClasses/classes/TaxServiceRest.php.class). If this is something that presents a challenge for your system, uncomment ONE of the following two options in that file:
//Some Windows users have had trouble with our SSL Certificates. Uncomment the following line to NOT use SSL.
// *This is not recommended, see below for better alternative*
//curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
//Other Windows users may prefer to download the certificate from our site (detail here: http://developer.avalara.com/api-docs/designing-your-integration/errors-and-outages/ssl-certificates) and manually set the cert path.
// To set the path manually, uncomment the following two lines and ensure you are telling curl where it can find the root certificate. If you choose to manually set the path, make sure you have reenabled cURL by commenting out the line above
// that tells curl to NOT use SSL.
//$ca = "C:/curl/curl-ca-bundle.crt";
//curl_setopt($curl, CURLOPT_CAINFO, $ca);
If you would like to use these core classes as part of a project and manage your depencies through composer, the Avatax classes can be added to your existing project by adding
"repositories": [
{
"type": "vcs",
"url": "https://github.com/avadev/AvaTax-Calc-REST-PHP"
}
],
"require": {
"avalara/avatax-rest-api": "*"
}
to your composer.json file and run php composer.phar update
from your command line.
Sample Files | |
---|---|
CancelTaxTest.php | Demonstrates the CancelTax method used to void a document. |
EstimateTaxTest.php | Demonstrates the EstimateTax method used for product- and line- indifferent tax estimates. |
GetTaxTest.php | Demonstrates the GetTax method used for product- and line- specific calculation. |
PingTest.php | Uses a hardcoded EstimateTax call to test connectivity and credential information. |
ValidateAddressTest.php | Demonstrates the ValidateAddress method to normalize an address. | Other Files |
AvaTaxClasses/ | Contains the core classes that make the service calls. |
.gitattributes | - |
.gitignore | - |
LICENSE.md | - |
README.md | - |