DEV Community

Structure Hub
Structure Hub

Posted on

French e-invoicing for online shops: what Factur-X changes for your code

If you build or maintain an online shop that sells to French businesses, invoicing is about to change. From September 2026, every company in France must be able to receive electronic invoices. Large and mid-size companies must also issue them from that date, and small businesses follow in September 2027.

We had to deal with this for our own back office, Structure Hub, and for the shops that use it. Here is what we learned, with the parts that actually touch the code.

A PDF is no longer an invoice

Today most shops send a PDF by email and call it a day. Under the reform, a B2B invoice has to be structured data, sent through an approved platform (in French, a "plateforme agréée"). The tax authority receives the data from that platform.

Three formats are accepted: UBL, UN/CEFACT CII, and Factur-X. For a shop that already generates PDFs, Factur-X is the easiest path, because it is still a PDF.

What Factur-X is, technically

A Factur-X file is a PDF/A-3 with an XML file embedded inside it:

  • the visible part is your usual invoice, readable by a human;
  • the embedded file is called factur-x.xml and contains the same invoice in CII syntax;
  • the PDF's XMP metadata declares the Factur-X profile used.

There are several profiles, from MINIMUM to EXTENDED. MINIMUM and BASIC WL don't carry the invoice lines, so they are not enough on their own. For the French reform, EN 16931 (also called COMFORT) is the safe choice.

The two parts must say the same thing. If the PDF shows a total of 120 € and the XML says 100 €, the platform and the tax authority only read the XML, and you have a problem.

Checking a file in a few lines

You can open any Factur-X invoice and read its XML with pikepdf:

import pikepdf

with pikepdf.open("invoice.pdf") as pdf:
    files = pdf.attachments
    print(list(files.keys()))  # should include 'factur-x.xml'
    xml = files["factur-x.xml"].get_file().read_bytes()
    print(xml[:300].decode("utf-8"))
Enter fullscreen mode Exit fullscreen mode

If factur-x.xml is missing, the file is just a PDF. If it is there, validate it against the official schemas published with the Factur-X specification, then check the PDF/A-3 part with a tool like veraPDF. We run both checks in our test suite every time the invoice code changes.

The new mandatory fields

The reform adds four pieces of information to every B2B invoice. Shops often don't collect them at checkout today:

  1. The customer's SIREN number (the 9-digit French company ID). Add an optional field at checkout for business customers.
  2. The delivery address, if it differs from the billing address. Most shops already have it, but it has to make it into the invoice data.
  3. The type of operation: goods, services, or both. For a shop selling physical products, this is usually "goods", but a shop that also sells installation or subscriptions has to tell them apart.
  4. The VAT payment option, when the seller pays VAT on debits rather than on receipts. This one is a setting of the seller, not of the order.

Plan these as database fields now. Adding them after go-live is a lot more painful.

B2C sales: e-reporting, not e-invoicing

This part surprised us. Sales to private customers are not e-invoices. Instead, the seller reports transaction data (amounts, VAT, dates) to the tax authority through the same approved platform. That's called e-reporting.

So a typical shop ends up with two flows:

  • B2B orders → a Factur-X invoice, sent through the platform;
  • B2C orders → regular receipt or invoice for the customer, plus a periodic e-report of the totals.

Your order model needs to know which is which. A simple flag set at checkout ("I'm buying for a company" plus the SIREN) is enough for most shops.

Credit notes and refunds

A refund on a B2B order is a credit note, and it follows the same rules: Factur-X, same fields, sent through the platform, with a reference to the original invoice. If your shop issues partial refunds from the payment provider's dashboard, you need a way to create the matching credit note in your system. Otherwise the books and the reported data drift apart.

What we would do again

  • Generate the XML first, from the order data, then render the PDF from the same data. Never the other way round.
  • Store the final Factur-X file, byte for byte. In France you have to keep invoices for 10 years.
  • Keep the platform connection behind one small module. Approved platforms each have their own API, and a shop may want to change platform later.

Where Structure Hub fits

We built Structure Hub as a back office that plugs into an existing shop. Invoices and credit notes come out in Factur-X EN 16931 and can be sent through an approved platform. There's a free plan if you want to see how the invoices are built.

Questions about the reform or the format? Ask in the comments, we read them.

— The Structure Hub team

Top comments (0)