How do I validate CUI + VIES for Romanian and EU B2B in Magento?
CUI (Cod Unic de Înregistrare) is the Romanian company ID, 2-10 digits, optionally prefixed with RO for VAT-registered companies. Two separate validations matter:
- CUI lookup against ANAF, the Romanian tax authority publishes a free API (
webservicesp.anaf.ro/PlatitorTvaRest/api/v8/ws/tva) that returns company name, address, TVA registration status, and inactive-trader flag. We call this on Magento customer registration to auto-fill company name + address from CUI, and to reject inactive traders. - VIES validation, for EU intra-community B2B, the CUI prefixed with
ROmust validate via VIES (EU-wide VAT validation). Required for 0% TVA reverse-charge on cross-border B2B sales.
Magento integration steps:
- Add a
cuiattribute tocustomerentity (or B2Bcompanyif on Adobe Commerce). - On registration, call ANAF API, auto-fill name + address, set
is_tva_payerflag. - Cache ANAF response 30 days; re-validate on address change.
- For cross-border EU B2B: call VIES, apply 0% TVA reverse-charge if valid + customer outside RO.
- For RO-domestic B2B: still apply 19% TVA but issue full fiscal factură with CUI.