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

Avalara tax plugin. Error when address value was incomplete #7584

Open
RomanovM opened this issue Feb 17, 2025 · 0 comments
Open

Avalara tax plugin. Error when address value was incomplete #7584

RomanovM opened this issue Feb 17, 2025 · 0 comments

Comments

@RomanovM
Copy link
Contributor

If the customer doesn't provide the full address then the Avalara API returns the error message.

Tax.Avalara error. InvalidAddress - The address value was incomplete.
Details: The address value ShipTo was incomplete. You must provide either a valid postal code, line1 + city + region, or line1 + postal code.

Could you add this checking in the method?
I added checking "line1 + postal code + city".
The Postal code is mandatory, when I provided the city without line 1 then I got error message.

    public async Task<TaxRateResult> GetTaxRateAsync(TaxRateRequest taxRateRequest)
    {
        if (taxRateRequest.Address == null)
            return new TaxRateResult { Errors = new List<string> { "Address is not set" } };

        //You must provide either a valid postal code, line1 + city + region, or line1 + postal code.
        if (string.IsNullOrWhiteSpace(taxRateRequest.Address.ZipPostalCode)
           || string.IsNullOrWhiteSpace(taxRateRequest.Address.City)
           || string.IsNullOrWhiteSpace(taxRateRequest.Address.Address1)
           )
           return new TaxRateResult { Errors = new List<string> { "Address is not set" } };

        //get tax rate
        var taxRate = await _avalaraTaxManager.GetTaxRateAsync(taxRateRequest);
        if (!taxRate.HasValue)
            return new TaxRateResult { Errors = new List<string> { "No response from the service" } };

        return new TaxRateResult { TaxRate = taxRate.Value };
    }

Source: https://www.nopcommerce.com/boards/topic/101847/avalara-tax-provider

@RomanovM RomanovM self-assigned this Feb 17, 2025
@RomanovM RomanovM added this to the Version 4.90 milestone Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant