This guide takes you from a blank PHP project to a real VERI*FACTU registration record accepted by the AEAT pre-production endpoint. You will install the library, build aDocumentation 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.
RegistrationRecord, configure your ComputerSystem descriptor, authenticate with your certificate, and inspect the response — all in five focused steps.
Install via Composer
Verifactu-PHP requires PHP 8.2 or higher and the libxml extension (bundled with most PHP distributions). Install the package with a single Composer command:Composer will pull in all required dependencies — Guzzle for HTTP transport, UXML for XML handling, and Symfony Validator for model validation — and generate the PSR-4 autoloader under
vendor/autoload.php.Build a RegistrationRecord
A
RegistrationRecord represents a single invoice registration (alta). Populate its properties, compute the SHA-256 chain hash, and validate the model before sending it anywhere.calculateHash() computes the SHA-256 fingerprint over a canonical string that includes the issuer NIF, invoice number, issue date, invoice type, tax total, grand total, the previous record’s hash, and the generation timestamp. Set previousInvoiceId and previousHash to null only for the first record in a chain; for every subsequent record, supply the identifier and hash of the immediately preceding one.Configure ComputerSystem
ComputerSystem describes the SIF (Sistema Informático de Facturación) that is generating the records. The AEAT embeds this information in every submission, so it must be accurate and consistent across all records you send.Create AeatClient and send
AeatClient constructs the SOAP envelope, attaches your mTLS certificate, targets the correct endpoint, and dispatches the request asynchronously using Guzzle promises.send() accepts an array of RegistrationRecord and/or CancellationRecord objects. Calling ->wait() blocks until the promise resolves; in an async context you can chain ->then() handlers instead.Handle the response
The resolved promise returns an A
AeatResponse object. Check ResponseStatus::Correct to confirm the record was accepted without errors, or inspect the per-item errorDescription when the AEAT reports a problem.ResponseStatus::Correct response includes a CSV (Código Seguro de Verificación) — the unique identifier assigned by the AEAT to the submitted batch. Store this value alongside your invoice data for audit purposes.