TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Eseperio/verifactu-php/llms.txt
Use this file to discover all available pages before exploring further.
Verifactu class is the primary entry point for all interactions with Spain’s AEAT VERI*FACTU system. Every method is static — no instantiation is required. Call Verifactu::config() once during application bootstrap, then use the operation methods wherever you need them.
Constants
Environment constants
| Constant | Value | Description |
|---|---|---|
Verifactu::ENVIRONMENT_PRODUCTION | 'production' | Live AEAT production environment |
Verifactu::ENVIRONMENT_SANDBOX | 'sandbox' | Homologation / test environment (pre-production) |
Certificate type constants
| Constant | Value | Description |
|---|---|---|
Verifactu::TYPE_CERTIFICATE | 'certificate' | Standard personal or company certificate |
Verifactu::TYPE_SEAL | 'seal' | Electronic seal certificate (sello electrónico) |
SOAP endpoint URL constants
| Constant | Value |
|---|---|
Verifactu::URL_PRODUCTION | https://www1.agenciatributaria.gob.es/wlpl/TIKE-CONT/ws/SistemaFacturacion/VerifactuSOAP |
Verifactu::URL_PRODUCTION_SEAL | https://www10.agenciatributaria.gob.es/wlpl/TIKE-CONT/ws/SistemaFacturacion/VerifactuSOAP |
Verifactu::URL_TEST | https://prewww1.aeat.es/wlpl/TIKE-CONT/ws/SistemaFacturacion/VerifactuSOAP |
Verifactu::URL_TEST_SEAL | https://prewww10.aeat.es/wlpl/TIKE-CONT/ws/SistemaFacturacion/VerifactuSOAP |
QR verification URL constants
| Constant | Value |
|---|---|
Verifactu::QR_VERIFICATION_URL_PRODUCTION | https://www2.agenciatributaria.gob.es/wlpl/TIKE-CONT/ValidarQR |
Verifactu::QR_VERIFICATION_URL_TEST | https://prewww2.aeat.es/wlpl/TIKE-CONT/ValidarQR |
config() based on the environment and certificate type you provide — you never need to reference the URL constants directly in normal usage.
Methods
config()
Initialises the library with your certificate and target environment. Must be called once before any other method. Call it during application bootstrap (e.g. in a service provider or bootstrap file).
Absolute filesystem path to the PKCS#12 (
.p12 / .pfx) certificate file issued by a recognised Spanish certification authority (e.g. FNMT).Password that protects the certificate file.
Type of certificate. Use
Verifactu::TYPE_CERTIFICATE for a personal/company certificate or Verifactu::TYPE_SEAL for an electronic seal. The value determines which AEAT SOAP endpoint is selected.Target environment. Use
Verifactu::ENVIRONMENT_SANDBOX for development and testing against the AEAT homologation platform, or Verifactu::ENVIRONMENT_PRODUCTION for live submissions. Defaults to ENVIRONMENT_PRODUCTION.\InvalidArgumentException if an unrecognised value is passed to $environment.
registerInvoice()
Submits a new invoice record (Alta / RegistroAlta) to AEAT via SOAP.
A fully populated and valid
InvoiceSubmission instance. Call $invoice->validate() before submitting to catch any model-level errors early.An
InvoiceResponse object containing the AEAT response. Check submissionStatus against InvoiceResponse::STATUS_OK ('Correcto') to determine success. The csv property holds the AEAT-generated Secure Verification Code when accepted.\DOMException— if the internal XML document cannot be constructed.\SoapFault— if the SOAP call to AEAT fails (network error, invalid credentials, endpoint unavailable, etc.).
cancelInvoice()
Sends a cancellation record (Anulación / RegistroAnulacion) to AEAT to void a previously registered invoice.
A fully populated
InvoiceCancellation instance. The invoiceId, chaining, systemInfo, recordTimestamp, and issuerName fields are required.An
InvoiceResponse object. A successful cancellation sets submissionStatus to 'Correcto'.\SoapFault on SOAP-level transport or authentication failures.
queryInvoices()
Queries previously submitted invoice records from AEAT. Supports filtering by year, period, series number, date, counterparty, and pagination.
A populated
InvoiceQuery instance. year and period are required; all other filters are optional.A
QueryResponse object. The foundRecords array holds the matched invoice records. paginationKey is set when there are more pages of results.\SoapFault on communication errors.
generateInvoiceQr()
Generates a QR code for a submitted invoice. The QR encodes a URL pointing to the AEAT verification portal with the invoice’s identifying parameters appended as query string arguments. The return value is the raw QR image data (binary PNG by default) — it is not base64-encoded automatically. Encode it yourself if you need to embed it in HTML or store it as text.
Any
InvoiceRecord subclass instance — typically an InvoiceSubmission. The record must have invoiceId, hash, and totalAmount populated (i.e. it should have been submitted or at least have its hash computed).Raw QR image data (binary PNG when using the default GD renderer). The value is not base64-encoded — call
base64_encode() yourself if you need a data-URI or text-safe representation.