taxjar / taxjar-magento2-extension

Magento 2 Sales Tax Extension by TaxJar
http://www.taxjar.com/guides/integrations/magento2/
Open Software License 3.0
22 stars 30 forks source link

Improvement to Postcode Validation #322

Closed beechyrb closed 2 years ago

beechyrb commented 2 years ago

Prerequisites

Description

We have had multiple instances where customers bypassed the tax calculation at the checkout by adding a space before a postcode like this " 90230". The TaxJar API supports spaces however the _validatePostcode function in the "Model/Smartcalcs.php" file does not support the space and therefore skips tax calculations. We have had a patch on this function for a few years now to trim the postcode entered by the customer and it seems to be working fine. I would suggest this be added by default as I don't believe there are any countries that have postcodes with a space at the beginning or the end.

Steps to Reproduce

  1. Add an item to the cart and proceed to checkout, choose checkout as a guest for ease of replication.
  2. Add a taxable US address and add a space before the postcode, Magento will complain but allow you to proceed.

Expected Result

For the tax to be calculated on the order

Actual Result

Tax calculations are skipped due to failing the _validatePostcode function

Versions

sethobey-stripe commented 2 years ago

Hi @beechyrb, thanks for reporting this issue! We'll take a look.

sethobey commented 2 years ago

@beechyrb We were able to reproduce the issue and have implemented the fix you've described. It will be included in our next patch release v1.9.7. Thank you again for contributing!