Skip to content

M2 – VAT validation sometimes “fails”, valid EU VAT numbers still charged VAT

I am running a Magento 2.4.7-p3 webshop (Netherlands based).
VAT validation is configured to use the default Magento VIES integration. Most (9/10) of the time it works correctly:

  • A customer enters a valid EU VAT number.
  • Magento validates it with VIES.
  • Customer is automatically moved into the correct tax-free customer group.
  • The order is created without VAT (as expected).

So far, so good.

But in about 1 out of 10 cases something strange happens:

  • The VAT number is valid (we checked afterwards directly in VIES).
  • The Magento frontend shows no errors during checkout.
  • Yet the order is placed with 21% VAT added.
  • The customer is assigned to my “VAT-free”
    group. Not to my “VAT failed” fallback group that I created.

This means Magento “thinks” everything is fine during checkout, but still applies VAT.

Sanity checks I already did:

  • Store origin is set to NL.
  • Tax calculation is based on shipping address.
  • Customer groups and tax rules are set up correctly (with a 0% intra-EU rule for validated customers).
  • “Validate VAT Number” is enabled, but I already tested with “Validate on Each Transaction” on/off.
  • Input is normalized on the frontend (no spaces, always uppercase, BE leading zeros handled, etc.).
  • Company field is required when a VAT number is entered.

Still, I get these edge cases. It even happens with new customers without an account, so it’s not an “old account data” issue.

I am honestly out of ideas. The logs sometimes show an earlier “VAT number cannot be validated” error, but the timestamp doesn’t match the actual order time — maybe the customer waited in checkout for a while. But even then, if validation failed, I would expect them to end up in my fallback “VAT failed” group, not in the default VAT 21% group. Also, it could be just some other random order/customer that actually made a typo I guess.

Question:
How can I debug and trace these inconsistent VAT cases further?
Where in Magento’s VAT validation / quote → order flow could a valid VAT number slip through and still get charged VAT?
And how can I reliably link my VIES validation log entries to the final order so I know what really happened?