surprisehighway / craft-avatax

Calculate and add sales tax to an order's base tax using Avalara's AvaTax service with Craft Commerce 5.
MIT License
7 stars 11 forks source link

Request to avatax.com failed #31

Closed knynkwl closed 3 years ago

knynkwl commented 3 years ago

We are running into this error. Any idea where this error is coming from or how to fix it?

[Error] Request to avatax.com failed

siffring commented 3 years ago

@knynkwl that's a general connection failure message. Are you getting that error for every request? Was it working at some point?

Does the "Test Connection" button work for you in the control panel settings?

knynkwl commented 3 years ago

Looks like validation is working. We get this error at any point trying to update a customer's address.

Screen Shot 2021-04-20 at 12 47 10 PM

knynkwl commented 3 years ago

When updating an address:

Screen Shot 2021-04-20 at 12 48 32 PM

imagehat commented 3 years ago

@knynkwl - you could try disabling address verification in the plugin settings. Avalara's address validation is super strict. Also if you turn on debugging you should see the full request and response from Avalara in the log, which might help verify if the issue is just a bad address (or one Avalara thinks is bad).

knynkwl commented 3 years ago

address verification is disabled :(

Enabling debugging setting doesn't give any more info, unfortunately.

Screen Shot 2021-04-20 at 1 34 09 PM

knynkwl commented 3 years ago

Hey so I figured it out.

I think it may be helpful to create some other errors based on the response.

When returning the response in your plugin I get two different things.

When Address Validation is enabled:

Client error: `GET https://sandbox-rest.avatax.com/api/v2/addresses/resolve?line1=*******&line2=&line3=&city=*********&country=US&textCase=Mixed` resulted in a `401 Unauthorized` response:
{"error":{"code":"SubscriptionRequired","message":"This API requires a subscription to AutoAddress.","target":"CustomerA (truncated...)

General Connection:

Client error: `POST https://sandbox-rest.avatax.com/api/v2/transactions/create` resulted in a `401 Unauthorized` response:
{"error":{"code":"SubscriptionRequired","message":"This API requires a subscription to AvaTaxPro or BasicReturns.","targ (truncated...)

It might be better to log the error response so we know the issue.

knynkwl commented 3 years ago

For example, this would be much more helpful.

Screen Shot 2021-04-20 at 2 15 19 PM

Screen Shot 2021-04-20 at 2 14 48 PM