avadev / AvaTax-REST-V2-PHP-SDK

Sales Tax API SDK for PHP and AvaTax REST
https://developer.avalara.com/sdk/
Apache License 2.0
48 stars 95 forks source link

AvaTaxClient methods no longer returning API JSON error message for HTTP 4** etc responses. #205

Closed nickfowlie closed 1 year ago

nickfowlie commented 1 year ago

Using Composer I recently updated the SDK source, this took me from RestClient 22.10.0 to 23.5.0. Unfortunately my code no longer works as it did previously because the AvaTaxClient method -

refundTransaction($companyCode, $transactionCode, $include=null, $documentType=null, $useTaxDateOverride=null, $model=null)

I have Not changed the default of the AvaTaxClient to return the response rather than throw an exception.

I had previously added logging code by extending the AvaTaxClient class and adding a middleware History handler ( Middleware::history) to guzzel's handler Stack ( $handlerStack->push($history) ).

Using this history handler to retrieve the API response I can obtain the following structure from guzzel's response stream -

{ "error": { "code": "EntityNotFoundError", "message": "Document not found.", "target": "HttpRequest", "details": [ { "code": "EntityNotFoundError", "number": 4, "message": "Document not found.", "description": "The Document with ID 'b295bd0a-f8c1-428f-90cd-example304baa' was not found.", "faultCode": "Client", "helpLink": "https://developer.avalara.com/avatax/errors/EntityNotFoundError", "severity": "Error" } ] } }

Which is exactly what the previous version ( 22.10. 0) of the SDK, was returning from the refundTransaction() method. This may well be the case for other AvaTaxClient methods as they appear to go through the same restCall() Method, though I have not yet tested the ones I use.

svc-developer commented 1 year ago

Thank you for reporting this issue. We have released a new version 23.6.2 which should rectify the problem.

https://github.com/avadev/AvaTax-REST-V2-PHP-SDK/releases/tag/23.6.2

let us know if you have any other issues thank you! cc: @nickfowlie