LokiCheckout_EuVat
This Magento 2 module is an add-on package to the LokiCheckout that validates VAT IDs in both billing and shipping address via the online VIES service.
Note that this does not require any other third party module.
Installation
Install this package via composer:
composer require loki-checkout/magento2-eu-vat
Next, enable this module:
bin/magento module:enable LokiCheckout_EuVat
Usage
Note that this is not based upon the Geissweb module.
Make sure customer/address/taxvat_show is enabled
VAT numbers are validated in the following order:
- Offline check of the country prefix and the number format of that country (for instance
NL123456789B01); - Online check via VIES (Magento core);
- Online check via vatlayer.com, when VIES is unavailable and a Vatlayer API key is configured;
- Optional offline fallback, when both VIES and vatlayer.com are unavailable and the number matches the country format;
Input is normalized first: spaces, dots and dashes are removed and letters are converted to uppercase.
Configuration
Under Stores > Configuration > Loki Checkout > EU VAT:
- Vatlayer API Key: Optional API key for vatlayer.com;
- Vatlayer API Timeout: Timeout in seconds for requests to vatlayer.com (default
5); - Cache Lifetime: Lifetime in seconds of cached validation results (default
86400, use0to disable). Requires the cache typeloki_checkout_eu_vatto be enabled; - Offline Fallback: Accept numbers with a valid format when all online services are unavailable (default
No); - Prefill Company: Fill in an empty company field with the company name returned by vatlayer.com (default
No, requires a Vatlayer API key);
CLI
Test the validation chain from the command line:
bin/magento loki-checkout:eu-vat:validate NL NL123456789B01
Credits
The country formats, the caching and the offline fallback are inspired by Dutchento/m2-vatfallback (MIT license).
Current status
Support
For getting support, create an Issue under the following project URL:
https://gitlab.yireo.com/loki-checkout/LokiCheckout_EuVat.git
Configuration Options
The following options of this module can be configured via the Store Configuration:
loki_checkout/eu_vat/vatlayer_api_key
loki_checkout/eu_vat/vatlayer_timeout
loki_checkout/eu_vat/cache_lifetime
loki_checkout/eu_vat/offline_fallback
loki_checkout/eu_vat/prefill_company
Loki Components
The following LokiComponents are created or references in this module:
loki-checkout.billing.address.country_id
loki-checkout.billing.address.vat_id
loki-checkout.shipping.address.country_id
loki-checkout.shipping.address.vat_id
Module Dependencies
The following dependencies are declared in the module its `etc/module.xml` file:
LokiCheckout_Core
Loki_Base
Loki_Components
Loki_CssUtils
Loki_FieldComponents
Magento_AdminNotification
Magento_Backend
Magento_Catalog
Magento_CatalogInventory
Magento_Checkout
Magento_CheckoutAgreements
Magento_Cms
Magento_Config
Magento_Csp
Magento_Customer
Magento_Directory
Magento_Eav
Magento_Indexer
Magento_MediaGalleryUiApi
Magento_Newsletter
Magento_Payment
Magento_Quote
Magento_Rule
Magento_Sales
Magento_SalesRule
Magento_SalesSequence
Magento_Shipping
Magento_Store
Magento_Tax
Magento_Theme
Magento_Ui
Magento_User
Magento_Variable
Magento_Vault
Magento_Widget
Yireo_CspUtilities
Composer details
LokiCheckout_EuVatloki-checkout/magento2-eu-vat
ext-pcre: *
loki-checkout/magento2-core: ^2.0
loki/magento2-components: ^2.0
loki/magento2-css-utils: ^1.0
magento/framework: ^103.0
magento/module-backend: ^102.0
magento/module-config: ^101.2
magento/module-customer: ^103.0
magento/module-store: ^101.1
php: >=8.2 <8.6
psr/log: ^3.0
symfony/console: ^5.0 | ^6.0 | ^7.0
Releases
| 2.0.24 | 11 November 2026 |
| 2.0.23 | 11 November 2026 |
| 2.0.22 | 11 November 2026 |
| 2.0.21 | 11 November 2026 |
| 2.0.20 | 11 November 2026 |
| 2.0.19 | 11 November 2026 |
| 2.0.18 | 11 November 2026 |
| 2.0.17 | 11 November 2026 |
| 2.0.16 | 11 November 2026 |
| 2.0.15 | 11 November 2026 |
| 2.0.14 | 11 November 2026 |
| 2.0.13 | 11 November 2026 |
| 2.0.12 | 11 November 2026 |
| 2.0.11 | 11 November 2026 |
| 2.0.10 | 11 November 2026 |
| 2.0.9 | 11 November 2026 |
| 2.0.8 | 11 November 2026 |
| 2.0.7 | 11 November 2026 |
| 2.0.6 | 11 November 2026 |
| 2.0.5 | 11 November 2026 |
Changelog
[2.0.24] - 08 November 2026
Fixed
- Send ISO country code and 2-letter VAT prefix to VIES for AT, ES and GR
- Add
trim()its second argument for PHP 8.6 compatibility
Added
- Prefill empty company field via vatlayer.com lookup
- Add CLI command loki-checkout:eu-vat:validate
- Add offline fallback and harden vatlayer.com client with timeout and database check
- Cache VAT validation results in dedicated cache type
- Validate VAT number format per EU country and normalize input
[2.0.23] - 28 August 2026
Fixed
- Add language files
- Fix child calls to
afterin new style
[2.0.22] - 17 July 2026
Fixed
- Only fallback when message is not "Please enter a valid VAT number"
- Allow for fallback to vatlayer.com when VIES fails
[2.0.21] - 01 July 2026
Fixed
- Prevent JS error when value is not there yet
[2.0.20] - 19 June 2026
Fixed
- Add positive feedback when VAT ID is correct
[2.0.19] - 12 June 2026
Fixed
- Autoprefix the mapped country ID to the VAT ID
[2.0.18] - 24 February 2026
Fixed
- Add
en_USlanguage file
[2.0.17] - 11 December 2025
Fixed
- Rename deprecated AddressState::save/load to set/get
[2.0.16] - 12 November 2025
Fixed
- Only intercept errors if validation failed
- Update composer keywords
[2.0.15] - 22 October 2025
Fixed
- Do not escape
$css()withescapeHtmlAttr()butescapeHtml()
[2.0.14] - 30 September 2025
Fixed
- Improve styling under Luma
[2.0.13] - 24 September 2025
Fixed
- Change containers into blocks to allow for caching
- Rename loki-components to loki.script.component
[2.0.12] - 04 September 2025
Fixed
- Rename FieldTemplateLocator to FieldTypeManager
- Undo minification
[2.0.11] - 02 September 2025
Fixed
- Update CI files
[2.0.10] - 02 September 2025
Fixed
- Update CI files
[2.0.9] - 02 September 2025
Fixed
- Reset
- Document latest version of template
- Prepare release
[2.0.8] - 02 September 2025
Fixed
- Add CI files
- Replace yireo/opensearch with yireo/opensearch-dummy in Gitlab CI
[2.0.7] - 26 August 2025
Fixed
- 2067d98 Add GitLab CI files
[2.0.6] - 21 August 2025
Fixed
- Add dependency with loki/magento2-css-utils
- Fix duplicate import
- Replace LokiComponentsUtilBlockCssClass with LokiCssUtilsUtilCssClass
- Declare used PHP namespaces
- Document latest version of template
- Add missing strict_types declaration
[2.0.5] - 18 August 2025
Fixed
- Allow for PHP 8.1 compatibility
- Lower requirements to PHP 8.1
[2.0.4] - 13 August 2025
Fixed
- Add data-valid attribute to fields
[2.0.3] - 07 August 2025
Fixed
- Lower PHP requirement to PHP 8.2+
[2.0.2] - 01 August 2025
Fixed
- Add missing
$csswrapper
[2.0.1] - 30 July 2025
Fixed
- Allow entering NLNL000000 as VAT ID anyway
[2.0.0] - 22 July 2025
Fixed
- Rename PHP namespace from
Yireo_Loki*toLoki* - Rename composer package from
yireo/magento2-loki*toloki/magento2* - Bump loki/magento2-components to major 2.0
- Bump loki/magento2-field-components to major 2.0
- Bump
LokiCheckout_Coreto 2.0.0 - Major rewrite of namespaces
[1.0.0] - 26 May 2025
Fixed
- Generate new MODULE.json with simple test count
- Allow PHP 8.4 in CI
- Update composer and module deps
[0.0.7] - 25 April 2025
Fixed
- Allow for LokiCheckout 1.0
[0.0.6] - 25 April 2025
Fixed
- Remove x-model because of CSP compliance
- Allow upgrade to LokiComponents 1.0
- Rewrite FieldTemplateLocator usage to be independent of context
[0.0.5] - 08 April 2025
Fixed
- Housekeeping changes
[0.0.4] - 11 March 2025
Fixed
- Accessibiity fixes
- Fix styling of country box when there is an error
- Add module dependencies
- Huge refactoring to move logic into new LokiFieldComponents
- Improve handling of AJAX errors
[0.0.3] - 22 February 2025
Fixed
- Fix typo
- Change deps
[0.0.2] - 20 February 2025
Fixed
- Handling of timeout to EU VIES service
- Prevent empty VAT ID from being saved
- Handle SOAP errors during EU VAT validation properly
Added
- Create abstraction of EU VAT validation for Geissweb purpose
- Save VAT ID of quote to customer as well
[0.0.1] - 21 January 2025
- Add proper deps
- Initial release