Verifactu with Stripe: how to connect your payments with the Verifactu API

Verifacti has no official Stripe app: you connect Stripe with the Verifactu API by listening to the payment webhook (invoice.paid) in your backend, which sends the invoice as JSON and stores the QR. No XML to generate, no hash to compute and no digital certificate: Verifacti sends the invoicing record to the AEAT as a colaborador social. In Álava, Bizkaia and Gipuzkoa, the same pattern works with the TicketBAI API.

Test environment and test NIF included
Read the documentation

Which APIs you need for Stripe

Your connector uses two pieces: the submission API that matches the NIF (Verifactu API in common territory; TicketBAI API in Álava, Bizkaia and Gipuzkoa) and the NIF management API, integrated once to register the NIF, manage the representation form and receive webhooks. Each NIF uses one API or the other depending on where it is taxed.

Test environment and test NIF included

How to connect Stripe with the API

Flow: charge in Stripe (invoice.paid webhook; for one-off Checkout payments, enable invoice_creation and the same event covers them) → your backend → Verifactu API or TicketBAI API → AEAT or foral treasury.

  1. Register the NIF with the NIF management API and sign the representation form. Each NIF has its own API key.
  2. Create the webhook endpoint for invoice.paid through the API, with api_version: '2024-06-20' (stripe.webhookEndpoints.create): Stripe builds the event with the endpoint's version and the code reads fields of that version.
  3. Verify the signature with stripe.webhooks.constructEvent.
  4. Build the invoice from the Stripe invoice (number, taxes by rate, customer NIF) and call POST /verifactu/create with the event id as Idempotency-Key.
  5. Store uuid and qr and send the customer your own PDF or email with the QR: Stripe's PDF can't carry it. Turn off Stripe's invoice emails and PDFs.

Check in Stripe's invoice settings that numbering is account-level: then the number is sequential, and the code splits the prefix into series and the sequence into number. Zero-amount invoices are not sent.

Do you build software and want to offer Verifactu to your customers? See SaaS.

Example: from the charge to the record

A Node.js backend with Express and the official Stripe library. Taxes come from total_tax_amounts (base and amount per rate); if the customer has a Spanish NIF, the invoice is a full one (F1).

server.js · Node.js
// Webhook invoice.paid de Stripe → API Verifactu (Node.js 18+, Express, stripe).
// Variables de entorno: STRIPE_SECRET_KEY, STRIPE_WEBHOOK_SECRET, VERIFACTI_API_KEY.
// El endpoint del webhook tiene que estar en la versión 2024-06-20 (créalo por API con
// api_version: '2024-06-20'): Stripe construye el evento con la versión del endpoint.
const express = require('express');
const Stripe = require('stripe');
const stripe = Stripe(process.env.STRIPE_SECRET_KEY, {
    apiVersion: '2024-06-20'
});
const app = express();
const fecha = (segundos)=>new Intl.DateTimeFormat('es-ES', {
        timeZone: 'Europe/Madrid',
        day: '2-digit',
        month: '2-digit',
        year: 'numeric'
    }).format(new Date(segundos * 1000)).replaceAll('/', '-');
const euros = (centimos)=>(centimos / 100).toFixed(2);
async function factura(invoice) {
    const lineas = [];
    for (const t of invoice.total_tax_amounts){
        const tasa = await stripe.taxRates.retrieve(t.tax_rate);
        lineas.push({
            base_imponible: euros(t.taxable_amount),
            tipo_impositivo: String(tasa.percentage),
            cuota_repercutida: euros(t.amount)
        });
    }
    const [, serie, numero] = invoice.number.match(/^(.*?)(\d+)$/);
    const nif = (invoice.customer_tax_ids || []).find((id)=>id.type === 'es_cif' || id.type === 'eu_vat' && id.value.startsWith('ES'));
    return {
        serie,
        numero,
        fecha_expedicion: fecha(invoice.status_transitions.finalized_at),
        tipo_factura: nif ? 'F1' : 'F2',
        descripcion: invoice.lines.data[0]?.description || 'Suscripción',
        ...nif && {
            nif: nif.value.replace(/^ES/, ''),
            nombre: invoice.customer_name
        },
        lineas,
        importe_total: euros(invoice.total)
    };
}
app.post('/webhooks/stripe', express.raw({
    type: 'application/json'
}), async (req, res)=>{
    let event;
    try {
        event = stripe.webhooks.constructEvent(req.body, req.get('Stripe-Signature'), process.env.STRIPE_WEBHOOK_SECRET);
    } catch  {
        return res.sendStatus(400);
    }
    if (event.type !== 'invoice.paid' || event.data.object.total === 0) return res.sendStatus(200);
    const r = await fetch('https://api.verifacti.com/verifactu/create', {
        method: 'POST',
        headers: {
            Authorization: `Bearer ${process.env.VERIFACTI_API_KEY}`,
            'Content-Type': 'application/json',
            'Idempotency-Key': event.id
        },
        body: JSON.stringify(await factura(event.data.object))
    });
    const registro = await r.json();
    if (r.status !== 200 && r.status !== 400) return res.sendStatus(500); // Stripe reintentará el evento
    if (r.status === 400) console.error('Verifacti', registro.codigo, registro.error);
    // Guarda registro.uuid y registro.url en invoice.metadata y el QR en tu base de datos
    // (la metadata de Stripe admite 500 caracteres por valor: el QR no cabe)
    res.sendStatus(200);
});
app.listen(3000);

The code groups the lines by VAT rate and uses F1 if the customer has a NIF and F2 otherwise. It sends the event id as Idempotency-Key: if Stripe resends the same event, the API returns the original response. The issue date is the date Stripe issued the invoice, so the body doesn't change even if the resend arrives another day. The response carries the uuid, the state (Pendiente: the submission to the AEAT is queued), the verification URL, the QR in Base64 and the hash: store them with the invoice.

More code in the Verifactu tutorials. For TicketBAI, the call goes to POST /ticketbai/create with the foral NIF's API key: the fields, in the TicketBAI API documentation.

Special cases in Stripe

Special cases when invoicing from Stripe
CaseWhat to doRead more
NumberingEvery invoice needs a series with sequential numbering. If invoice numbers can have gaps, give the invoice its own numberVerifactu requirements
Customer without a NIFSimplified invoice (F2), without nif or nombre. The API rejects an F2 above €3,000 (vf-verifactu-f2_limite_3000)Simplified invoice
Return or refundCorrective invoice: R5 if the original was simplified; R1–R4 if it was a full invoiceCorrective invoices
Customer asks for a full invoice laterExchange invoice (F3) replacing the simplified oneExchange invoice
Canary Islands, Ceuta and MelillaIGIC or IPSI in the lines (impuesto field), not VATIGIC · IPSI
Products without VATCheck whether they are exempt (operacion_exenta) or not subject (calificacion_operacion): they are not sent at rate 0Exempt invoice
CancellationOnly for invoices that should never have been issued: POST /verifactu/cancelCancellation
Sale to another EU countryIt depends on whether the customer is a business and on the distance-selling thresholdIntra-EU examples
Several companies or shopsOne NIF per company, each with its own API keyNIF management API

Dates

The first row only applies if you build the connector to sell it: then you sell invoicing software. For those who invoice, the Verifactu dates are published in the BOE and the postponement to October 2028 is announced with no rule published. In Álava, Bizkaia and Gipuzkoa, TicketBAI is in force.

Producers and resellers of invoicing softwareSince 29 Jul 2025
RDL 15/2025 did not change this date.
In force
Corporate Income Tax payers1 Jan 2027
Published in the BOE, future date
Everyone else, including the self-employed1 Jul 2027
Published in the BOE, future date
Postponement of the pending obligationsOct 2028
The note does not specify the scope for businesses invoicing over €8M.
Announced, no rule published
TicketBAI in Álava: foral taxpayersSince 1 Dec 2022
Phased from 1 April 2022; all other taxpayers since 1 December 2022.
In force
Batuz in Bizkaia (TicketBAI and LROE): all taxpayersSince 1 Jan 2026
Companies that are not SMEs since 1 January 2024; everyone else in windows on 1 July 2024, 1 January 2025, 1 July 2025 and 1 January 2026.
In force
TicketBAI in Gipuzkoa: foral taxpayersSince 1 Jun 2023
Phased by activity from 1 July 2022.
In force

This is not advice: each taxpayer determines what applies to them with their adviser.

More detail in Verifactu dates and TicketBAI.

Pricing

Public tariff of the Verifactu API and the TicketBAI API: you pay per NIF active in production, VAT excluded. Custom per-NIF pricing is available for volume.

From

€14.99

per month for the first NIF active in production, VAT excluded

See all pricing
  • The price per NIF goes down with every tier.
  • Free test environment and test NIF.
  • Annual plan with a 10% discount, no setup fees.
  • Up to 3,000 invoicing records per month per NIF.
  • Startup plan for companies under 12 months old, with under €100,000 in revenue and under €200,000 in funding.
  • Same price with the Verifactu API and the TicketBAI API: each NIF uses one or the other depending on where it is taxed.
  • Online signing of the representation form: €2.90 + VAT per signature.

Questions about Verifactu and Stripe

More questions about Verifactu

Is there an app from Verifacti for Stripe?

No. Verifacti is an API: Stripe connects to it with the code on this page, in your own development. There are third-party apps in the Stripe App Marketplace.

Does Stripe comply with Verifactu on its own?

Stripe takes the payment, but it does not generate invoicing records or send them to the AEAT: your invoicing system does, for example with the Verifactu API. Whoever invoices needs a system that generates the invoicing records and sends them to the AEAT. Which obligation each business has depends on its case: who Verifactu applies to.

Does it work for TicketBAI too?

Yes. If the NIF is taxed in Álava, Bizkaia or Gipuzkoa, the flow is the same with the TicketBAI API: the endpoint (/ticketbai/create), the invoice fields and the API key change.

Do I need a digital certificate?

No. Verifacti is an AEAT social collaborator and submits with its own certificate once the taxpayer signs the representation form, the same one for the AEAT and the foral treasuries. It can be signed online, without a certificate.

How much does it cost?

From €14.99 per month for the first NIF active in production, VAT excluded, with the Verifactu API or the TicketBAI API. The test environment and test NIF are free. Every plan, in pricing.

Connect Stripe in the test environment

Create your free account and try the API with a test NIF before going to production.

Test environment and test NIF includedRead the documentation