DEV Community

Daniel Igel
Daniel Igel

Posted on

How to add EU VAT number validation to your Stripe checkout in under 30 minutes

EU B2B SaaS with Stripe has a common requirement: validate the customer's VAT number before finalizing the checkout so you can apply the correct tax rate — or zero-rate cross-border sales. Stripe itself does not verify against VIES; that check is your responsibility.

GET /api/v1/validate?vat=DE123456789 hits the EU's official VIES database, caches results for 1 hour, and returns valid, name, and address for the business — everything you need to decide the tax treatment:

curl --request GET \
  --url 'https://eu-vat-number-validator-api.p.rapidapi.com/api/v1/validate?vat=DE123456789' \
  --header 'x-rapidapi-key: YOUR_RAPIDAPI_KEY' \
  --header 'x-rapidapi-host: eu-vat-number-validator-api.p.rapidapi.com'
Enter fullscreen mode Exit fullscreen mode

Wire it into a preflight before your PaymentIntent:

const res = await fetch(
  'https://eu-vat-number-validator-api.p.rapidapi.com/api/v1/validate?vat='
    + encodeURIComponent(vatInput),
  {
    headers: {
      'x-rapidapi-key': process.env.RAPIDAPI_KEY,
      'x-rapidapi-host': 'eu-vat-number-validator-api.p.rapidapi.com',
    },
  }
);
const { valid, name, address } = await res.json();
if (!valid) return res.status(422).json({ error: 'Invalid VAT number' });
// Apply zero-rate and pre-fill billing details from `name` / `address`
Enter fullscreen mode Exit fullscreen mode

POST /api/v1/validate/batch accepts up to 10 numbers in one request — handy for onboarding flows where customers import CRM exports with existing VAT data. Covers all 27 EU member states plus Northern Ireland (XI country code).

Free tier on RapidAPI: https://rapidapi.com/danieligel/api/eu-vat-number-validator-api

Are you handling EU VAT zero-rating automatically today, or still doing it manually after checkout?

Top comments (0)