Whitelist vat
Verify business buyers in Medusa v2: Polish NIP against the VAT white list (Biała lista) and GUS REGON, EU VAT numbers in VIES, with company data for checkout, a verification history as proof, and an admin panel.
VAT white list for Medusa
Verify business buyers in your Medusa store: Polish NIP on the Ministry of Finance white list (Biała lista VAT) and in the GUS REGON register, EU VAT numbers in VIES.
Installation · Configuration · What it does · Storefront · Admin · Testing
Requirements
- Medusa 2.22 or newer, Node.js 20.19+ or 22.12+
- Nothing else to start: the white list and VIES need no keys.
- Optional: a GUS REGON API key (free, from api.stat.gov.pl), one per store.
Installation
The package has no runtime dependencies of its own. It uses the Medusa packages your app already has (, , the admin SDK, UI and icons, , and ) as peer dependencies.
Register it and run the migrations:
npx medusa db:migrateThat is a working setup: every option has a default.
Configuration
| Option | Default | |
|---|---|---|
| How long an answer is reused before the registers are asked again. | ||
| Per request to a register. A slow register counts as unavailable. | ||
| Country for numbers typed without a prefix when the billing country is unknown. | ||
| Ministry of Finance white list. | ||
| uses the ministry's test environment. | ||
| Requests per day the plugin allows itself (the ministry permits about 100). | ||
| EU VAT number validation. | ||
| Your EU VAT number, for consultation numbers. | ||
| GUS answers from sample businesses, without a key (see Demo mode). | ||
| Turns the GUS REGON register on. | ||
| with GUS's public test key (see Testing). | ||
| Metadata keys that may hold the tax ID, in order. | ||
| Verify the buyer's tax ID when an order is placed. | ||
| Refuse to complete carts whose tax ID has one of . | ||
| Any of , , , . cannot be rejected. | ||
| The storefront lookup route. | ||
| Lookups one visitor may make per minute. |
Invalid options never stop Medusa. The plugin stays disabled and logs one line, ; its admin page shows the same reason.
Environment variables
| Variable | |
|---|---|
| GUS REGON API key, when you use the GUS register. |
The name is yours to choose; the plugin only reads options. See .
Where the tax ID lives
Medusa has no tax ID field, so the plugin reads it from metadata under the keys in . It looks, in this order, at the billing address, the shipping address, the cart or order itself, and the customer. Your storefront decides where to put it, for example:
Numbers may be typed with or without spaces, dashes and the country prefix. Without a prefix the billing country decides; Poland when it is unknown or outside the EU.
What it does
- Checks the number locally first. Format and check digit (NIP, EU VAT formats per country). Typos never reach a register.
- Polish NIP: asks the white list for the VAT status (active, exempt, not registered), the company's name, address, REGON, KRS and registered bank accounts. With a GUS key it also asks the REGON register, which knows businesses that are not VAT payers and whether a business has closed.
- EU VAT numbers: asks VIES and stores the consultation number.
- Keeps the proof. Every answer of every register is a row in the history with the register's own request ID and the time, linked to the order and customer. Orders placed with a tax ID are verified automatically, so each B2B order has the answers from the day of the sale.
- Reuses answers. A number verified in the last 24 hours (configurable) is not asked about again; an order still gets its own history rows pointing at the reused answer.
- Never mistakes an outage for a verdict. See below.
- Bank account check in the admin: is this account registered for this NIP on the white list today?
Verdicts
| Status | Meaning |
|---|---|
| Active VAT payer on the white list. | |
| On the white list as exempt from VAT. | |
| EU VAT number confirmed by VIES. | |
| A real business that is not a registered VAT payer. | |
| GUS reports the business has ended its activity. | |
| Wrong format or check digit, or VIES does not confirm the number. | |
| The registers answered and none knows the number. | |
| No register could be asked. Says nothing about the number. |
is true for , and .
When a register is down
Registers go offline, time out, and the white list has a daily limit. All of that yields with , never :
- a register that cannot be asked is recorded as in the history, with the reason;
- an outage never overwrites what a register said before: the earlier answer stays and is marked stale;
- cannot be put in , so a store can never turn buyers away because a government service is having a bad day;
- if the checkout check itself fails for any reason, the cart goes through.
The white list's daily limit
The ministry allows about 100 requests a day and may block further access until midnight. The plugin counts its own requests and stops at (95), reporting the white list as unavailable for the rest of the Polish calendar day. Answers are cached for 24 hours and the storefront route is rate limited per visitor, so the quota goes to real buyers. A store with many B2B orders a day should add a GUS key: GUS has no such limit and still confirms that the business exists, although only the white list gives the VAT status.
What it does not do
- The rate limit () counts requests per visitor by , in the memory of each server process. Behind a proxy or load balancer, set Express in your app, or every visitor shares the proxy's address. With several server instances, each counts on its own, so the effective limit is the setting times the number of instances. The daily white list quota () is counted in the database, so all instances share it.
- It does not change tax rates. A valid EU VAT number is recorded; applying 0% reverse charge is a decision for the store or its accounting.
- It does not block checkout unless you turn on.
- It does not use the ministry's daily flat file for bulk bank account checks.
- It does not re-verify stored businesses on a schedule (that would spend the daily limit); stale answers are marked and refreshed on demand and with each new order.
- It ships no storefront component, only the API below.
Storefront
checks a number and returns the verdict with the company's data for the invoice form:
The route needs the publishable API key like every store route, answers HTTP 429 after lookups per visitor a minute, and never returns bank accounts or register IDs.
Rejecting carts
With , completing a cart () whose tax ID has one of fails with an error naming the number. Carts without a tax ID are not affected. The check is a middleware on that route, so the validate hook stays free for your own code.
Admin
Extensions → VAT white list
- Panel: counts at a glance and today's white list usage; the businesses verified so far with status, address, REGON/KRS and number of bank accounts, filtered by active, exempt and EU, needs attention, or stale; search by number, name or address; "check again" per business; a link to the customer; and the full verification history with the registers' request IDs.
- Lookup: verify any NIP or EU VAT number and see what each register said, the company's data and its white list bank accounts; check whether a bank account belongs to a NIP.
- Settings: the registers in use, and the options from (read-only) with the plugin version. The GUS key is never shown, not even in part.
- Guide: the registers, verdicts, orders, checkout and limits in plain words.
Order and customer pages get a panel with the record's tax ID, the verdict, the business's data, the answers recorded for that record and a "Verify again" button.
The admin is in English and Polish.
Workflows and events
takes and verifies the tax ID found on the order.
is emitted after the registers were asked (not for cached answers) with . Subscribe to it to flag orders for review or to tell your accounting system.
API
Admin routes, all under and behind admin authentication:
| Route | |
|---|---|
| Registers in use, today's white list usage, counts, options. | |
| Verified businesses; , , , . | |
| Ask the registers about a stored business again. | |
| Manual lookup: . | |
| : is the account registered for the NIP today? | |
| History; filter by , , , . | |
| , | Tax ID, verdict and history of a record. |
| , | Verify a record's tax ID now. |
Demo mode
shows what GUS adds without a key: GUS answers at once from made-up businesses (their names start with ), and no request goes to GUS. The same NIP always gets the same business, with a valid REGON. Two NIPs have fixed answers so every state can be shown:
| NIP | GUS answer |
|---|---|
| (business closed) | |
The white list and VIES are still asked for real (they need no key), so a real NIP shows its real white list data next to the sample GUS data. The admin page shows a "Demo mode" bar. The history keeps demo answers with request IDs starting with . Don't use demo mode in production: the GUS data is not real.
Testing
- White list: points at the ministry's test environment (), which has its own data and limits.
- GUS: uses GUS's public test key against its test database (old, anonymised data). Production keys are requested at api.stat.gov.pl.
- VIES has no sandbox for real numbers; look up your own VAT number from Extensions → VAT white list → Lookup.
- Use the Lookup tab for all of the above: it shows what each register answered, including the reason when one is unavailable.
Troubleshooting
- Everything is "Could not verify": open the Lookup tab and read the reason per register. Typical causes are the white list's daily limit and a member state's system being offline in VIES.
- "The daily limit of 95 white list requests is used up": it resets at midnight Polish time. Add a GUS key, or raise .
- GUS says the key was not accepted: check and that matches the key (test keys only work in ).
- The order panel says "No tax ID on this record": your storefront stores it under a key that is not in .
- A foreign number is read as Polish: type it with its country prefix, or make sure the billing address has the country.
Development
See docs/development.md and the repository's CONTRIBUTING.md.
License
MIT © 2026 Bitshaft. This plugin is not affiliated with or endorsed by the Polish Ministry of Finance, Statistics Poland (GUS) or the European Commission. See TRADEMARKS.md.

