Documentation Index
Fetch the complete documentation index at: https://mintlify.com/josemmo/Verifactu-PHP/llms.txt
Use this file to discover all available pages before exploring further.
VERI*FACTU regulations require every issued invoice to include a QR code that points to the AEAT’s invoice verification portal. QrGenerator produces the correctly formatted verification URL; you are then responsible for rendering that URL as a QR image using a separate library and printing it on the invoice document.
Basic usage — from a RegistrationRecord
The most convenient approach is to derive the URL directly from a fully built RegistrationRecord. fromRegistrationRecord() reads the issuer ID, invoice number, issue date, and total amount automatically.
<?php
use DateTimeImmutable;
use josemmo\Verifactu\Models\Records\InvoiceIdentifier;
use josemmo\Verifactu\Models\Records\RegistrationRecord;
use josemmo\Verifactu\Services\QrGenerator;
// Assume $record is a fully built RegistrationRecord
$record = new RegistrationRecord();
$record->invoiceId = new InvoiceIdentifier(
'A86018322',
'FACT001',
new DateTimeImmutable('2025-10-01'),
);
$record->totalAmount = '100.23';
// ... (set remaining fields, hash, etc.)
$generator = new QrGenerator();
$generator->setProduction(false); // use pre-production during development
$url = $generator->fromRegistrationRecord($record);
echo "QR URL: $url\n";
// https://prewww2.aeat.es/wlpl/TIKE-CONT/ValidarQR?nif=A86018322&numserie=FACT001&fecha=01-10-2025&importe=100.23
From an InvoiceIdentifier
If you have an InvoiceIdentifier and the invoice amount available separately, use fromInvoiceId():
use josemmo\Verifactu\Models\Records\InvoiceIdentifier;
use josemmo\Verifactu\Services\QrGenerator;
use DateTimeImmutable;
$invoiceId = new InvoiceIdentifier(
'A00000000',
'FACT-2026-001',
new DateTimeImmutable('2026-03-15'),
);
$generator = new QrGenerator();
$url = $generator->fromInvoiceId($invoiceId, '1210.00');
echo $url . "\n";
From raw parameters
For maximum flexibility, from() accepts the four individual components directly:
use josemmo\Verifactu\Services\QrGenerator;
use DateTimeImmutable;
$generator = new QrGenerator();
$url = $generator->from(
'A00000000', // issuerId
'FACT-2026-001', // invoiceNumber
new DateTimeImmutable('2026-03-15'), // issueDate
'1210.00', // total amount
);
echo $url . "\n";
Production vs pre-production
By default QrGenerator targets the production AEAT portal. Call setProduction(false) to switch to the pre-production environment during development and testing.
$generator = new QrGenerator();
// Production (default) — www2.agenciatributaria.gob.es
$generator->setProduction(true);
// Pre-production — prewww2.aeat.es
$generator->setProduction(false);
| Mode | Base URL |
|---|
| Production | https://www2.agenciatributaria.gob.es |
| Pre-production | https://prewww2.aeat.es |
Online vs offline mode
VERI*FACTU distinguishes between two operating modes that affect the verification path used in the QR URL.
// Online / VERI*FACTU mode (default) — uses /ValidarQR
$generator->setOnlineMode(true);
// Offline / Non-VERI*FACTU mode — uses /ValidarQRNoVerifactu
$generator->setOnlineMode(false);
setOnlineMode() | Path | Use case |
|---|
true (default) | /wlpl/TIKE-CONT/ValidarQR | VERI*FACTU mode (records submitted to AEAT in real time) |
false | /wlpl/TIKE-CONT/ValidarQRNoVerifactu | Non-VERI*FACTU mode (records submitted only on AEAT request) |
Generated URL structure
All three generation methods produce a URL with the following structure and query parameters:
https://www2.agenciatributaria.gob.es/wlpl/TIKE-CONT/ValidarQR
?nif=A00000000
&numserie=FACT-2026-001
&fecha=15-03-2026
&importe=1210.00
| Parameter | Source | Format |
|---|
nif | InvoiceIdentifier::$issuerId | 9-character NIF |
numserie | InvoiceIdentifier::$invoiceNumber | Invoice series + number |
fecha | InvoiceIdentifier::$issueDate | dd-mm-yyyy |
importe | RegistrationRecord::$totalAmount | Decimal with 2 decimal places |
Rendering the QR image
Verifactu-PHP only produces the verification URL. To render a scannable QR image, use a dedicated PHP QR library and embed the result in your invoice PDF or HTML. For example, using endroid/qr-code:
composer require endroid/qr-code
use Endroid\QrCode\QrCode;
use Endroid\QrCode\Writer\PngWriter;
use josemmo\Verifactu\Services\QrGenerator;
$generator = new QrGenerator();
$url = $generator->fromRegistrationRecord($record);
$qrCode = QrCode::create($url);
$writer = new PngWriter();
$result = $writer->write($qrCode);
// Save to file or embed in a PDF
file_put_contents('invoice-qr.png', $result->getString());