Automattic / wp-calypso

The JavaScript and API powered WordPress.com
https://developer.wordpress.com
GNU General Public License v2.0
12.4k stars 1.98k forks source link

VAT Details: try sanitization for the VAT ID field #91759

Open liviopv opened 3 months ago

liviopv commented 3 months ago

What

VAT numbers vary from country to country, and some might include dashes like Spain (X-0000000) or spaces, but our system only accepts letter/number input

We should build in some logic that sanitizes the input data and cleans up any invalid characters automatically

Why

If a user can't add VAT on their own because of validation, they will likely contact support about it. If we can avoid that, It's better if we can avoid that for something so simple.

Example: 8173714-zd-a8c

How

Review all EU formats and possible input variations, and add rules to sanitize the data based on that.

github-actions[bot] commented 3 months ago

Support References

This comment is automatically generated. Please do not edit it.

mrfoxtalbot commented 2 months ago

Is this something that @Automattic/martech could take care of? Thank you!

niranjan-uma-shankar commented 2 months ago

From the ticket, it looks like the issue was encountered on /me/purchases page. Maybe this is for @Automattic/payments?

martian77 commented 2 months ago

We do validate tax numbers, we just don't autoremove invalid characters for people. And with the example of Spain above, it appears that dashes aren't actually included in the definition of the VAT number. It's listed here as ES + 9 digits (first and last can be letters), without dashes.

Also, we don't only deal with EU business tax numbers. Dashes are valid in e.g. South Korea and Indonesia.

I guess we could try to automatically strip out characters based on the official format for that country, but it might be better to not second guess these numbers (given that supplying someone else's number is likely to be seen as tax fraud) and instead let them know what format we're expecting.

mrfoxtalbot commented 2 months ago

Thank you for taking a look @martian77.

What is the text in the error messages we are showing at the moment? Perhaps we could alleviate this just by being more explicit in the error message we show to users?

jjchrisdiehl commented 2 months ago

I suppose we could consider adding placeholder text or a line describing the format we expect 🤔

martian77 commented 2 months ago

I suppose we could consider adding placeholder text or a line describing the format we expect

I think we did this for postcodes, right? It would make sense here too.