PHP developer in Seville

WordPress for businesses in Seville, delivered remotely by one developer.

PHP developer

My place in the WordPress community

  • I have had a wordpress.org account since 2006.
  • I contributed to WordPress core for versions 7.0 and 7.1.
  • I maintain 30 plugins on wordpress.org.
  • I organise and speak at WordCamps.
  • I have attended every WordCamp Europe from 2017 to 2026.
  • Local WordPress meetup: WordPress Sevilla

My WordPress.org profile

An invoicing module written in PHP for the Spanish market writes a record with a hash that links it to the previous one for every invoice, prints a tax QR code, and in VERI*FACTU mode sends the record to the tax agency (AEAT). I am Mariusz Szatkowski, a developer in Gdynia who builds custom PHP applications remotely and in writing, with the screens designed by me or built from your design. This page is for a Seville company or software house that has to implement the hash, the QR code and the submission. It stays with the technical rules; who is in scope and what the regulation is for is covered on my Malaga page about the same regulation. Tax advice is outside what I do.

Calle Fray Ceferino Gonzalez between the cathedral and the Archivo de Indias, Seville

Photo: CEphoto, Uwe Aranas, CC BY-SA 3.0, Wikimedia Commons.

#Which documents define the technical rules?

  1. Real Decreto 1007/2023 of 5 December, the regulation on invoicing software. Article 8 requires integrity, conservation, accessibility, legibility, traceability and inalterability of the records. Article 12 covers the hash and electronic signature, and article 13 the producer’s declaración responsable.
  2. Orden HAC/1177/2024 of 17 October, published in the BOE on 28 October 2024 and in force since 29 October 2024. It sets the technical, functional and content specifications, and its annex holds the record layouts.
  3. AEAT’s technical information pages: record designs, WSDL, schemas, a document of validations and errors, the hash algorithm, the signature specification, the QR characteristics and an external test portal.

Several articles of the order leave the details to publication on AEAT’s electronic office, so in practice the PDFs on those pages decide how the code looks.

#How is the record hash built?

Article 13 of the order lists the fields, and AEAT’s hash specification (version 0.1.2 of 27 August 2024) turns them into an exact string. For an invoice record (registro de alta) the fields come in this order, matching the XML record design:

  1. IDEmisorFactura
  2. NumSerieFactura
  3. FechaExpedicionFactura
  4. TipoFactura
  5. CuotaTotal
  6. ImporteTotal
  7. Huella (the hash of the previous record)
  8. FechaHoraHusoGenRegistro

A cancellation record (registro de anulación) uses five fields: IDEmisorFacturaAnulada, NumSerieFacturaAnulada, FechaExpedicionFacturaAnulada, the previous Huella and FechaHoraHusoGenRegistro. Event records have their own nine-field set.

AEAT’s rules for the string:

  • each pair is written as name=value, and pairs are joined with &
  • the field name is the constant name from the XML design
  • the value is the same as in the XML, with leading and trailing spaces removed
  • for amounts, AEAT accepts one or two decimals alike, so 123.1 and 123.10 are both valid
  • a field that is absent or empty still appears as its name and =, with nothing after it
  • the string is encoded as UTF-8 bytes before hashing

The only algorithm the order’s list L12 allows today is SHA-256. The output is hexadecimal, in capital letters, 64 characters long, and goes into the record’s own Huella field. The first record of a system is no exception: it gets a hash too, its PrimerRegistro field is set to S, and the previous-record block is left out.

#PHP code that matches AEAT’s test values

AEAT’s document gives three worked examples with expected outputs. The function below reproduces the first two exactly when run on PHP 8.4.

<?php
function huellaAlta(array $r, string $previousHash): string
{
    $fields = [
        'IDEmisorFactura'          => $r['nif'],
        'NumSerieFactura'          => $r['numSerie'],
        'FechaExpedicionFactura'   => $r['fecha'],
        'TipoFactura'              => $r['tipo'],
        'CuotaTotal'               => $r['cuota'],
        'ImporteTotal'             => $r['importe'],
        'Huella'                   => $previousHash,
        'FechaHoraHusoGenRegistro' => $r['generado'],
    ];
    $parts = [];
    foreach ($fields as $name => $value) {
        $parts[] = $name . '=' . trim((string) $value);
    }
    return strtoupper(hash('sha256', implode('&', $parts)));
}

$first = huellaAlta([
    'nif' => '89890001K', 'numSerie' => '12345678/G33', 'fecha' => '01-01-2024',
    'tipo' => 'F1', 'cuota' => '12.35', 'importe' => '123.45',
    'generado' => '2024-01-01T19:20:30+01:00',
], '');
// 3C464DAF61ACB827C65FDA19F352A4E3BDC2C640E9E9FC4CC058073F38F12F60

$second = huellaAlta([
    'nif' => '89890001K', 'numSerie' => '12345679/G34', 'fecha' => '01-01-2024',
    'tipo' => 'F1', 'cuota' => '12.35', 'importe' => '123.45',
    'generado' => '2024-01-01T19:20:35+01:00',
], $first);
// F7B94CFD8924EDFF273501B01EE5153E4CE8F259766F88CF6ACB8935802A2B97

The values are not URL-encoded: the slash in 12345678/G33 stays a slash in the hash input. PHP’s hash() returns lowercase hex, and AEAT wants uppercase. And the amount must be the same string that goes into the XML, so the code that formats ImporteTotal for the XML should be the one that feeds the hash.

The order adds the link between records in article 7: each record carries the issuer’s tax number, the series and number, and the issue date of the record immediately before it, plus the first 64 characters of its hash. “Immediately before” is by date of generation, so two requests that create invoices at the same time must not read the same previous record. A database transaction that locks the last record per issuer, or a single queue worker per issuer, keeps the chain linear.

AEAT’s specification says that when a hash sent by a VERI*FACTU system does not match AEAT’s own calculation, the record is marked “Aceptado con errores”. A bug in the string builder therefore does not show up as a rejected submission. It needs its own test, and AEAT’s three examples make a good fixture for a PHPUnit test.

#What goes into the QR code?

Article 20 of the order requires a QR code on the printed invoice and on the image of a digital one. Under article 21 the code measures from 30x30 to 40x40 millimetres, follows ISO/IEC 18004 and uses error correction level M. For structured electronic invoices exchanged between systems, article 20.2 asks for the URL as a separate field instead of the image.

The content is a URL with four parameters: the issuer’s tax number, the series and number, the issue date and the total amount. AEAT’s QR document (version 0.5.0 of 10 December 2025) gives four base URLs:

SystemEnvironmentPath
Verifiable (VERI*FACTU)test portalhttps://prewww2.aeat.es/wlpl/TIKE-CONT/ValidarQR
Verifiable (VERI*FACTU)productionhttps://www2.agenciatributaria.gob.es/wlpl/TIKE-CONT/ValidarQR
Not verifiabletest portalhttps://prewww2.aeat.es/wlpl/TIKE-CONT/ValidarQRNoVerifactu
Not verifiableproductionhttps://www2.agenciatributaria.gob.es/wlpl/TIKE-CONT/ValidarQRNoVerifactu

The parameters are nif, numserie, fecha (DD-MM-YYYY) and importe. Unlike the hash input, they must be URL-encoded in UTF-8. AEAT’s own example has a series number containing an ampersand, which must arrive as %26. In PHP, http_build_query() does this. Its default is RFC 1738 encoding, which turns spaces into plus signs; php.net documents PHP_QUERY_RFC3986 for percent-encoded spaces, which is the safer choice for a value that may contain a space.

<?php
$query = http_build_query([
    'nif'      => '89890001K',
    'numserie' => '12345678&G33',
    'fecha'    => '01-01-2024',
    'importe'  => '241.4',
], '', '&', PHP_QUERY_RFC3986);

$url = 'https://prewww2.aeat.es/wlpl/TIKE-CONT/ValidarQR?' . $query;
// ...ValidarQR?nif=89890001K&numserie=12345678%26G33&fecha=01-01-2024&importe=241.4

That output matches the encoded example in AEAT’s document character for character.

#Where does the QR code sit on the invoice?

The order leaves placement to AEAT, and the QR document fills it in:

  • the code goes at the start of the invoice, before the content the invoicing system generates
  • on a multi-page invoice it appears once, on the first page
  • in portrait layout, near the top margin, preferably centred, otherwise top left; in landscape, on the left, preferably near the top left corner
  • at least 2 millimetres of blank space on all four sides, 6 millimetres recommended
  • the text “QR tributario:” always precedes it, placed above the code
  • for verifiable invoices, the phrase “Factura verificable en la sede electrónica de la AEAT” or “VERI*FACTU” goes directly below the code
  • both texts use a legible font at least as large as the rest of the invoice data
  • if the invoice holds other QR codes, the tax one comes first and stands out

For a PHP invoice template the tax QR code belongs in the header area at the top of page one. A PDF library that renders HTML templates needs the code as an image at a fixed physical size, so the template should set it in millimetres rather than pixels.

#How does submission to AEAT work?

Article 16 of the order covers systems that send records. The messages are XML with the structure in section 4 of the annex. The flow control works like this:

  1. The system sends a first batch of records.
  2. AEAT’s response carries, among other data, an updated wait time “t”.
  3. The next batch goes when “t” seconds have passed since the previous one, or when the system holds as many records as one submission allows, whichever comes first.
  4. Each response can update “t” again.

The initial value of “t” is 60 seconds, and the annex allows up to 1,000 records per submission. An accepted response does not mean every record is valid; AEAT can still validate later, and a rejected submission comes back with an error code. If a technical problem blocks sending, the records go as soon as possible, in the order they were generated, with the affected messages flagged in a field for that purpose.

In PHP this fits a queue worker. The invoice is issued and its record stored in the same transaction; a worker sends pending records in generation order, stores AEAT’s “t” and the response, and never drops a record because a call failed. Systems that do not send records to AEAT sign them instead: article 14 requires a XAdES Enveloped signature under ETSI EN 319 132, made with a qualified certificate from a provider on the EU Trusted List.

#When do the rules apply?

The dates have changed several times, so here is the chain as the BOE text stands on 4 December 2026.

  • The consolidated text of Real Decreto 1007/2023, last amended by Real Decreto-ley 43/2026 of 24 November, says taxpayers must have their systems adapted when the period in letter b) of section 1 of the fourth final provision of Real Decreto 238/2026 runs out.
  • Real Decreto 238/2026 of 25 March, on mandatory electronic invoicing between businesses, sets that period at 24 months from the entry into force of the ministerial order on the public e-invoicing solution.
  • That order is Orden HAC/1028/2026 of 2 October, published on 5 October 2026 and in force since 6 October 2026.

AEAT’s information note, updated on 25 November 2026, gives the result as a date: taxpayers must have their systems adapted before 6 October 2028. For producers and sellers of invoicing software the consolidated text keeps a separate rule: products fully adapted within nine months of the entry into force of Orden HAC/1177/2024, which entered into force on 29 October 2024. Nine months from that date fell in 2025. The same provision makes one exception: systems covered by multi-year maintenance contracts signed before that deadline follow the taxpayers’ date. A Seville software house that sells a PHP invoicing product should read its own position against this paragraph, not against the 2028 date alone.

#Checklist for a PHP invoicing module

  • Build the hash string from the XML values, not from separate database columns that may format amounts differently.
  • Uppercase the SHA-256 output and keep all 64 characters in the record.
  • Add AEAT’s three worked examples as unit test fixtures.
  • Serialise record creation per issuer so each record links to the real previous one.
  • URL-encode QR parameters with PHP_QUERY_RFC3986, and never URL-encode the hash input.
  • Put the QR code at the top of page one with “QR tributario:” above it and the 2 millimetre margin.
  • Send records from a queue worker that respects AEAT’s wait time and the 1,000-record limit.
  • Run the whole flow against AEAT’s external test portal before switching to production URLs.

#How does a project run?

  1. You send the repository or module description, the framework, how invoices are rendered today and your deadline. A written reply follows within 24 hours, counting working days.
  2. I write down the scope: record tables, hash builder, QR output, submission worker, with my assumptions.
  3. Development runs on a staging copy and against AEAT’s test portal.
  4. After your written acceptance the module is released.

The declaración responsable under article 13 of the regulation stays with the producer of the software. More on my PHP work is on the PHP developer page.

#Send me your invoicing module

If your Seville company builds or runs invoicing in PHP, send me the repository or a short description, the framework, the PDF or template library and your deadline through the contact page. The first estimate, in writing, comes at no cost. Questions of tax treatment stay with your adviser.

Need this service: PHP developer in Seville?

Describe your project by e-mail. I reply within 24 hours.

Describe your project

Latest PHP developer articles

Dec 2, 2026

Laravel Rust: what does it mean for PHP apps?

On 1 December 2026 Taylor Otwell shipped the Laravel Rust beta, and Laravel Go followed a day later. What the framework contains, what the 18x benchmark really measures, what happens to Laravel PHP and WordPress, and when a rewrite makes sense.

Explore other WordPress services and knowledge base