Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid address error results in uncaught exception #29

Closed
sparkalow opened this issue Feb 18, 2021 · 2 comments · Fixed by #32
Closed

Invalid address error results in uncaught exception #29

sparkalow opened this issue Feb 18, 2021 · 2 comments · Fixed by #32
Labels
enhancement New feature or request

Comments

@sparkalow
Copy link

sparkalow commented Feb 18, 2021

When updating an order/cart with a bad address, an uncaught exception is thrown. This results in an error causing Craft to render it's environment specific error page. I noticed this after having a local test user with a crappy address, then installing/configuring the plugin and logging in with that user. It also happens when setting a bad address normally during checkout (tested with default commerce templates).

This seems like a mature plugin and I find it hard to believe that a bad address could have this effect. I'm hoping there is a documentation I missed or I'm doing something dumb to cause this.

Details

Bad cart addresses (with wrong U.S. zip/state) results in this api response(taken from Avatax log):

"Client error: `POST https:\/\/sandbox-rest.avatax.com\/api\/v2\/transactions\/create` resulted in a `400 Bad Request`

 response:\n{\"error\":{\"code\":\"GetTaxError\",\"message\":\"Tax calculation cannot be determined. Zip is not valid for the state.\",\"target (truncated...)\n"

Causes uncaught exception here /src/services/SalesTaxService.php at line 714 effectively killing the page.

System report:
PHP version 7.4.15
Craft Pro 3.6.4.1
Craft Commerce 3.2.14.1
Avatax | 2.1.3

@imagehat
Copy link
Collaborator

@sparkalow - You can disable address validation in the plugin settings by turning off "Enable Address Validation".

Most stores using this plugin either don't use Avalara's address validation service, use it via the json endpoint with javascript (which works even if the address validation setting is off), or have some other address validation service in place.

Avalara is very strict and will not return any sales tax for a bad address. But I agree the exception is pretty heavy-handed. What would make more sense for you? Something like adding the errors to the Cart errors instead?

@sparkalow
Copy link
Author

@imagehat I knew it was something I overlooked (typical).

I was going to suggest, capturing and logging the exception and leaving it up to plugin users to deal with zero tax calculations in their own way.

For my case, it makes sense to allow an order to be made with no taxes and then manually sort it out later. I don't know offhand if a Cart error would still allow an order to be completed.

@siffring siffring added the enhancement New feature or request label Apr 20, 2021
@imagehat imagehat mentioned this issue May 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants