cancel
Showing results for 
Search instead for 
Did you mean: 

EU VAT number validation improvement suggestions

EU VAT number validation improvement suggestions

Feature request from hostep, posted on GitHub May 09, 2015

Hi

This is mostly based on Magento 1 experience, but it looks like not much has changed in Magento 2 currently (testing 0.74.0-beta8). I'm not a VAT expert, I'm simply getting this from feedback we get from store owners who complain about how bad this is currently implemented in Magento 1. So with Magento 2, it would be a good idea to try to get this right from the start.

Here are some suggestions, please review them, maybe there are better solutions then the ones I'm suggesting ...

  1. If you go through the checkout, you should get instant feedback when you enter a VAT number if it is valid or not, and not after you go through the whole purchase process and it is too late. With the instant feedback you can correct your VAT number before purchasing if you made a typo.

  2. We have experienced a lot of issues with the VAT API service which is currently used in Magento (= VIES VAT number validation), it happens very regularly that the API service is down or times out. So you should think about some kind of way to handle this. Maybe there are alternative API services? Maybe you can do a first preliminary check using regular expressions before going to the API service to lower the load on the service? Maybe add a switch in the backend where store owners can choose what happens when the API service is down: allow the customer to proceed, or let them try again until the API service is back up?

  3. Right now you aren't allowed to enter your country prefix in front of the VAT number, since it uses the country from your address. I believe you should clearly state this in a line of text or in a tooltip or something like that, so the customers know what to enter. Also: it makes a lot more sense to put the VAT number field after the country selector field, because it depends on that value (the same thing applies to the state/region field, but that's another issue).

If others have some opinions about these issues or have other suggestions, please leave a comment, so we can try to improve how Magento 2 handles the EU VAT number validation.

Credit where credit's due: most of these suggestions come from a commercial extension we used a few times in the past: https://www.geissweb.de/eu-vat-enhanced-magento-extension.html, but since the current implementation in Magento is pretty broken, we shouldn't depend on an extension to fix these bugs in Magento I believe?

9 Comments
apiuser
New Member
Status changed to: Investigating
 
apiuser
New Member

Comment from choukalos, posted on GitHub May 11, 2015

Created JIRA issue MAGETWO-37219 and put into Backlog to improve VAT ID validation

apiuser
New Member

Comment from peterjaap, posted on GitHub May 14, 2015

@sandermangel and me did some work on extending the M1 VAT validation logic with some extra services and a regex fallback; https://github.com/sandermangel/rkvatfallback

apiuser
New Member

Comment from hostep, posted on GitHub May 14, 2015

@peterjaap: cool! I quickly ran through your code to see how it works. But I would put the regex checking before going to the validation service. So if the regex checks fail, you can immediately determine that the number is incorrect without having to wait for the API services. If the regex check says the number is correct, only then go to the API service. And if the API service is down, then let the store owner decide what to do with it through a configuration switch, either approve it (since it was already approved by the regex, but this is no guarantee, it can still be incorrect), or don't allow the customer to proceed and let him try again until the API service is back online.

About the regexes, I still don't know if it is a good idea, I don't know if the format of the VAT numbers change a lot over the years as extra VAT numbers are needed per country (for example it changed for Irish numbers in 2013: http://www.vatlive.com/european-news/ireland-vat-number-format-from-january-2013/). And also if extra countries get added to the EU, we should be aware that we will need to add an extra regex each time. If we do go for the regex checks, we should pay very good attention to see if they are correct. I just compared some of your regexes with some we used in the past, and they are slightly different for some countries, so I'm not sure if yours or ours are actually 100% foolproof. Over here is an explanation about the format per country (not sure if it is up to date though): http://ec.europa.eu/taxation_customs/vies/faq.html#item_11

About the http://isvat.appspot.com/ service, isn't that an extra service in front of VIES, with the difference that it returns json data? So if VIES is down, that service will probably also be down? Unless it does some kind of caching, but still then it would be an amazing coincidence if they have cached that particular VAT number...

These are just some ideas, I'm sure the Magento devs can come up with a more robust plan for this Smiley Happy

apiuser
New Member

Comment from peterjaap, posted on GitHub May 14, 2015

Thanks @hostep for your input.

I agree moving the regex to before the services is a good idea. Keeping the regexes up to date would be community effort I guess, unless Magento is willing to take up the glove.

Would you be in a position to share your regexes so we can improve the ones that are in rkvatfallback now?

About the Appspot one, you are right. I never noticed they got their data from VIES. I just asked @aral on Twitter whether he caches the data, just to be sure.

apiuser
New Member

Comment from versdivers, posted on GitHub Apr 06, 2016

Does someone know if this is already created also for magento 2?

roman204
Moderator

I wrote a plugin which exqactly does that.

Find it here: https://github.com/CopeX/CopeX_VatFix

baldwin_pieter
Core Contributor

Hi @roman204, great job!

 

Quickly looking through your code, it seems like it only fixes issue #3 mentioned above, correct?

#1 has the highest priority in my opinion, so it would be great if you could add that sort of functionality to your plugin (no pressure, take your time Smiley Happy).

 

Thanks!

VersDivers
New Contributor

Just saying that every other e-commerce system has this already. Maybe time to look into it?