avadev / AvaTax-Calc-REST-PHP

PHP sample for the AvaTax Calc REST API
Apache License 2.0
9 stars 28 forks source link

32 error handling #33

Closed skylord123 closed 8 years ago

skylord123 commented 8 years ago

Fixes #31 Closes #17 Closes #32

Needed these fixes. We are implementing Avalara on our website and if the request to the Avalara API fails we need to get an exception thrown instead of a fatal/warning occurring (for example #31 happened because of this). This allows us to program for these situations and handle accordingly (for example, if there is an error connecting then log it to the system log and notify a developer).

I also included a bunch of PHPDoc and other fixes to code I saw issues with. I also made it so all cURL requests go through one function to clean up the Rest classes.

Also both AddressServiceRest and TaxServiceRest both now accept two extra (non required) parameters for SSL. This way the user doesn't have to change the actual source files to use these fixes (bad practice if you are using composer)

None of these changes should break anyone's code already out there. I made sure to leave it compatible with PHP >= 5.3. The major addition is using Exceptions more when a request to the API is being made for better debugging and error handling.

skylord123 commented 8 years ago

I've been using this code in production on our website without any issues. We use avatax for calculating tax and verifying addresses when users checkout. Been using for last couple weeks without any issues.