=== GoFactoX E-Invoicing for WooCommerce ===
Contributors: decant, freemius
Tags: facturx, e-invoicing, woocommerce, pdf-invoice, multilingual
Requires at least: 6.4
Tested up to: 7.0
Requires PHP: 8.0
Requires Plugins: woocommerce
WC requires at least: 8.5
WC tested up to: 9.6
Stable tag: 1.4.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Generate Factur-X (PDF/A-3 + XML), CII and UBL compliant e-invoices from WooCommerce orders. Ready for the French e-invoicing mandate 2026.

== Description ==

**GoFactoX E-Invoicing for WooCommerce** automatically generates legally compliant electronic invoices from your WooCommerce orders. Supports **Factur-X** (PDF/A-3 with embedded XML), **CII** and **UBL** formats, the three formats accepted by the French e-invoicing reform.

= Why You Need This =

Starting **September 2026**, all French businesses must be able to receive electronic invoices. By **September 2027**, all businesses (including small businesses) must also **emit** them. This plugin gets you ready now.

= Key Features =

* **Manual Factur-X generation (free)**: Generate PDF/A-3 invoices with embedded XML on demand, Basic and Comfort (EN 16931) profiles
* **PDF/A-3 compliant**: Real PDF/A-3b archivable format with embedded structured XML
* **3 output formats**: Factur-X (PDF+XML), CII (XML only), UBL (XML only)
* **French legal compliance**: SIRET, VAT, full set of legal mentions, late payment penalties, recovery indemnity (40 €), article 293 B for VAT-exempt sellers
* **Sequential numbering**: Legal, gap-free, configurable prefix and format
* **Company logo on PDF**: Upload via the WordPress media library
* **IBAN/BIC on PDF + payment terms**: Configurable (immediate, net 15/30/45/60 days). Wire transfer block shown on every invoice
* **Seller and buyer electronic addresses** (EN 16931 BT-34/BT-49): Required by Plateformes Agréées (PA, ex PDP) such as Iopole, Pennylane, SuperPDP, Chorus Pro
* **B2B checkout fields**: SIREN, SIRET, VAT number, Purchase Order number (BT-10), classic and block-based checkout
* **WooCommerce coupons as structured allowances** (EN 16931 BG-20) in the XML
* **WC Subscriptions compatibility**: Billing period (BT-73/74) on recurring invoices
* **Customer self-service**: Download invoice from My Account and Thank You page
* **WPML and Polylang**: Multilingual ready
* **HPOS and Checkout Blocks**: Compatible with WooCommerce modern stack
* **GDPR exporter and eraser**: Customer invoices included in WordPress personal data export
* **Developer hooks**: gofactox_invoice_data, gofactox_xml_output, gofactox_pdf_template_path, gofactox_pdf_filename

= Pro plan adds =

* **Automatic generation** on order completion and on refund (Factur-X credit notes type 381)
* **SEPA QR code (scan-to-pay)** on EUR invoices
* **Structured SEPA Credit Transfer mapping in XML** (BG-17)
* **AVOIR watermark** on credit note PDFs and distinct credit note numbering
* **End-of-month and custom payment terms**
* **Email auto-attachment** for invoices and credit notes
* **Admin dashboard** with monthly statistics
* **Bulk generation, ZIP export, retroactive generation**
* **REST API and webhooks** (gofactox.invoice.created, gofactox.credit_note.created, ...)
* **Priority email support**

= Business plan adds =

* Everything in Pro, plus 5-site licence
* **PA (ex PDP) transmission** scaffold: Iopole and Pennylane connectors planned, Chorus Pro connector for B2G included
* **FEC export** (Fichier des Écritures Comptables, article A47 A-1 LPF)
* **24-hour support**

= Perfect For =

* French e-commerce businesses preparing for the 2026/2027 e-invoicing mandate
* B2B WooCommerce stores that need compliant invoices with buyer SIRET/VAT
* Accountants and bookkeepers managing WooCommerce client invoices
* Any EU business using WooCommerce that needs structured invoice data

[Learn more about Pro and Business plans](https://gofactox.com)

== Installation ==

1. Go to **Plugins > Add New** in your WordPress admin
2. Search for **GoFactoX E-Invoicing**
3. Click **Install Now** then **Activate**
4. Go to **WooCommerce > Settings > Factur-X** to configure your company information
5. Done! Invoices will be generated for new orders.

== Frequently Asked Questions ==

= Is this plugin ready for the French e-invoicing mandate (réforme de la facturation électronique) ? =

Yes! This plugin generates invoices in all three formats accepted by the reform: Factur-X, CII, and UBL. It includes all mandatory French legal mentions (SIRET, VAT, penalties, recovery indemnity).

Note: the current version handles **invoice generation**. Transmission to a Plateforme Agréée (PA, ex PDP such as Iopole or Pennylane) will be added in the Business plan. Since October 2024, the PPF (Portail Public de Facturation) has been refocused to act only as the central directory, so transmission must go through a third-party PA.

= What is Factur-X? =

Factur-X is a Franco-German electronic invoice standard. It's a hybrid format: a PDF/A-3 document (human-readable) with an embedded XML file (machine-readable). It's based on the European standard EN 16931 and the UN/CEFACT CII data model.

= Which Factur-X profile is used? =

Both **Basic** and **Comfort (EN 16931)** profiles are included in the free plan. Comfort exposes structured allowances and references for sophisticated B2B buyers.

= Does it work with WooCommerce HPOS (High-Performance Order Storage)? =

Yes, the plugin is fully compatible with HPOS and declares compatibility with WooCommerce's custom order tables.

= Is the plugin compatible with WPML and Polylang (multilingual sites)? =

Yes. All user-facing strings go through the WordPress text domain `gofactox-e-invoicing-for-woocommerce`, so WPML String Translation (and Polylang equivalent) picks them up automatically. The generated invoice PDF reflects the active WordPress locale at order creation time, which aligns with WPML's per-language locale switching out of the box. The embedded Factur-X XML follows the EN 16931 standard and is language-agnostic.

Important legal note: for customers established in France, invoices must be in French (mandatory legal mentions, payment conditions). For customers established outside France, invoices can be issued in the customer's language; the French version should be archived or made available to the tax administration on request.

= Does it work with LearnDash or other WooCommerce-based sales? =

Yes. The plugin hooks into standard WooCommerce orders, so any plugin that creates orders through WooCommerce (LearnDash, Subscriptions, Memberships, Bookings, etc.) triggers invoice generation automatically.

= Can I generate invoices for past orders? =

Yes! Use the bulk action "Generate Factur-X Invoices" in the orders list, or use the retroactive generation feature in the dashboard.

= Does the plugin validate the generated Factur-X files? =

The XML is validated against the XSD schema during generation. For full PDF/A-3 validation, we recommend testing with the [FNFE-MPE validator](https://services.fnfe-mpe.org/validation).

= Mon WooCommerce est-il conforme à la réforme 2026 de la facturation électronique ? =

Avec ce plugin, vos factures seront générées au format Factur-X conforme. Pour la conformité complète (transmission via une Plateforme Agréée, PA, ex PDP), une mise à jour future ajoutera cette fonctionnalité côté offre Business.

= Comment générer une facture Factur-X avec WooCommerce ? =

Installez ce plugin, configurez vos informations entreprise dans WooCommerce > Réglages > Factur-X, et les factures seront générées automatiquement à chaque commande.

== External Services ==

This plugin connects to the following external services when the PA (Plateforme Agréée, ex PDP) transmission feature is enabled (Business plan, not yet active):

= Chorus Pro =

The plugin can transmit electronic invoices to the French government's e-invoicing platform (Portail Public de Facturation). This connection is used to send Factur-X invoices and check transmission status. No data is sent unless the user explicitly configures and enables the Chorus Pro connector in the plugin settings.

- Service: [Chorus Pro](https://chorus-pro.gouv.fr)
- Terms of use: [https://communaute.chorus-pro.gouv.fr/mentions-legales/](https://communaute.chorus-pro.gouv.fr/mentions-legales/)
- Privacy policy: [https://communaute.chorus-pro.gouv.fr/politique-de-confidentialite/](https://communaute.chorus-pro.gouv.fr/politique-de-confidentialite/)

Note: The PA transmission feature is currently a scaffold and does not transmit any data. The Chorus Pro connector targets B2G transactions (public sector); Iopole and Pennylane connectors are planned for B2B private. Each connector will be activated once its respective API integration is complete.

== Screenshots ==

1. WooCommerce Settings: Company information configuration
2. Invoice meta box on order page: Generate and download invoices
3. Orders list: Invoice column with direct download links
4. Dashboard: Monthly statistics and invoice list
5. B2B checkout fields: SIREN, SIRET, VAT at checkout
6. Generated PDF invoice: Clean, professional design with all French legal mentions

== Changelog ==

= 1.4.2 =
* New: operation category (catégorie de l'opération: supply of goods, supply of services, or mixed), one of the new mandatory mentions of the French e-invoicing reform. It is auto-detected from the order (virtual or downloadable products count as services, shippable products as goods, a mix is reported as "mixte") or can be set manually in the settings. The mention appears on the invoice and credit note PDF and is carried in the Factur-X XML.
* New: "cadre de facturation" (Chorus Pro invoicing framework, EN 16931 BT-23). Every invoice now carries the safe default A1 (standard supplier invoice); A2, A9 and A12 are also selectable, and emission can be turned off. This value is required when depositing an invoice to a public administration (B2G) through Chorus Pro, and is harmless for ordinary B2B/B2C sales.
* New: delivery address (EN 16931 BG-15) on the invoice and credit note PDF and in the Factur-X XML, shown only when the shipping address differs from the billing address. Another new mandatory mention of the French e-invoicing reform.
* New: optional "VAT paid on debits" legal mention (option pour le paiement de la TVA d'après les débits), toggled in the settings for sellers who have opted to pay VAT on debits. Shown on the PDF and carried in the XML.

= 1.4.1 =
* Tested up to WordPress 7.0 (released May 20, 2026).
* Compliance: passes WordPress Plugin Check with zero errors. Hardened output escaping, input sanitization, and inline script injection patterns.
* Fix: the "Late Payment Interest Rate" placeholder was hardcoded in French; it now respects the active site locale (translatable string).
* Fix: in the Factur-X dashboard table, clicking the PDF action on a credit note row used to open the underlying invoice instead. The link now routes correctly to the credit note PDF.
* Improved: credit notes in the dashboard table now show a small "AVOIR" badge next to the number for quick visual distinction.
* Fix: several French translations were missing or incorrect (Net 60 days, 45 days end of month, Net 15 days). All payment terms strings are now fully translated.
* Improved: end-of-month payment terms (30/45 days EOM) now follow the French majority calculation method (end of current month + N days, instead of date + N days then end of month) and carry the legally precise "à compter de la date d'émission de la facture" wording on the PDF, in line with Code de commerce L441-10.

= 1.4.0 =
* Plan alignment: credit notes (Factur-X type 381) on refunds, SEPA QR code, structured SEPA Credit Transfer mapping in the XML (BG-17), AVOIR watermark, end-of-month payment terms, and REST API are now part of the Pro plan. FEC export and PA (ex PDP) transmission remain on Business. Manual Factur-X invoice generation (Basic and Comfort profiles), the full set of French legal mentions, B2B checkout fields, payment terms (immediate to net 60), IBAN/BIC display on the PDF, GDPR exporter, WC Subscriptions compatibility, and all developer hooks remain free.
* New: B2B checkout fields (SIREN, SIRET, VAT, PO number) now also work with the modern Checkout Blocks (React-based checkout). Until 1.4.0 they only appeared on the classic checkout.
* New: seller electronic address field (EN 16931 BT-34) and buyer electronic address (BT-49) in the XML. Required by several Plateformes Agréées (PA, ex PDP) such as Chorus Pro, SuperPDP, Pennylane to send back receipt acknowledgments and rejection notices.
* New: company logo upload via the WordPress media library. The logo is rendered at the top of every invoice and credit note PDF.
* New: SEPA EPC QR code on invoices. Customers scan the QR with their banking app and the wire transfer is pre-filled (IBAN, amount, invoice number reference). Toggleable.
* New: configurable payment terms (immediate, net 15/30/45/60, end-of-month 30/45, custom). Due date is computed and propagated to PDF + Factur-X XML.
* New: IBAN/BIC/Bank Name fields in settings. Wire transfer block on the invoice PDF + structured SEPA payment means in the XML (UNTDID code 58, EN 16931 BG-17).
* New: optional "Purchase Order Number" (PO ref) field at B2B checkout. Stored on the order, rendered on the PDF, and exposed in the XML (BT-10).
* New: WooCommerce coupons applied on an order are now exported as structured document-level allowances (EN 16931 BG-20) in the XML. The PDF shows the discount lines + net before VAT.
* New: Factur-X "Comfort / EN 16931" output format option, in addition to the existing Basic profile.
* New: FEC export (Fichier des Écritures Comptables, article A47 A-1 LPF) downloadable from the Factur-X dashboard with a date-range selector. Each invoice and credit note produces an accounting entry split across customer (411), sales (707), and VAT collected (44571) accounts.
* New: REST API at /wp-json/gofactox/v1/ (invoices, credit-notes, PDF download) and WooCommerce webhook topics (gofactox.invoice.created, gofactox.credit_note.created, and their regenerated variants).
* New: "Download my Factur-X invoice" button on the WooCommerce order-received (Thank You) page.
* New: WooCommerce Subscriptions compatibility. Subscription orders carry the billing period (EN 16931 BT-73/BT-74) on the invoice PDF and XML.
* New: GDPR / RGPD personal data exporter and eraser. Customer invoices and credit notes are included in WordPress's standard personal data export, with a note that documents are legally retained for 10 years (Code de commerce L123-22).
* New: extensibility filters for third-party developers: `gofactox_invoice_data`, `gofactox_credit_note_data`, `gofactox_xml_output`, `gofactox_pdf_template_path`, `gofactox_pdf_filename`.
* Improved: invoice and credit note PDFs now display the buyer's PO number when provided.

= 1.3.0 =
* New: credit notes (avoirs) support for WooCommerce refunds. Generates a Factur-X credit note (UN/CEFACT type 381) with a reference to the original invoice (EN 16931 BT-25/BT-26), legal mentions and dedicated PDF template.
* New: separate sequential numbering for credit notes (default prefix "AV-", configurable).
* New: "AVOIR" PDF watermark, toggle in WooCommerce > Settings > Factur-X.
* New: auto-generation of credit notes on refund creation (Pro plan).
* New: manual "Generate Credit Note" button per refund in the order edit screen (Starter+).
* New: secure /wfx-credit-note/ download endpoint with per-document token, same permission model as invoices.
* Improved: clear error panel in the order meta box when the company configuration is incomplete, listing the missing fields with a link to the settings page (no more silent fail on click).
* Improved: AJAX errors now surface the underlying exception message instead of a generic "Invoice generation failed" banner.

= 1.2.1 =
* Fixed "Sorry, you are not allowed to access this page" error during plugin registration on installs where the administrator lacked the manage_woocommerce capability (multisite site admins, custom role managers, certain security plugins). The Freemius opt-in and account pages now run as a top-level admin menu under manage_options.
* Improved B2B checkout fields position: SIREN, SIRET and VAT number now appear higher in the checkout form for better visibility.

= 1.2.0 =
* Introduced Pro plan with automation features
* Improved WooCommerce 10.x compatibility

= 1.1.1 =
* Added French (fr_FR) translation
* WPML and Polylang compatibility
* LearnDash compatibility
* Cleaner invoice layout

= 1.1.0 =
* Renamed to GoFactoX E-Invoicing for WooCommerce
* Updated dompdf to 3.1.5
* Added Requires Plugins header for WooCommerce
* Added External Services documentation for Chorus Pro
* Improved code prefixing (gofactox_ prefix)
* Replaced inline scripts with wp_add_inline_script()

= 1.0.0 =
* Initial release
* Factur-X (PDF/A-3), CII, and UBL invoice generation
* Automatic generation on order completion
* French legal compliance (SIRET, VAT, penalties, recovery indemnity)
* B2B checkout fields (SIREN, SIRET, VAT number)
* Sequential numbering with configurable prefix
* Admin dashboard with statistics
* Bulk generation and ZIP export
* Retroactive invoice generation
* Email attachment
* HPOS and Checkout Blocks compatibility

== Upgrade Notice ==

= 1.4.2 =
Completes the four new mandatory mentions of the French e-invoicing reform (operation category, delivery address BG-15, VAT-on-debits option, plus SIREN already supported), and adds the Chorus Pro "cadre de facturation" (BT-23).

= 1.4.1 =
WordPress 7.0 compatibility, Plugin Check compliance, fixes on the credit note download link in the dashboard, French translation completions, and end-of-month payment terms aligned with Code de commerce L441-10.

= 1.4.0 =
Adds payment terms, IBAN/BIC, PO number at checkout, structured coupon discounts, Comfort profile, FEC export, REST API and webhooks.

= 1.3.0 =
Adds Factur-X credit notes (avoirs) for WooCommerce refunds and clearer error feedback when generating documents.

= 1.2.1 =
Fixes a permission error blocking plugin registration on some WordPress configurations (multisite, custom role managers, security plugins).

= 1.2.0 =
Introduces Pro plan with automation (auto-generation, email attachment, bulk actions).

= 1.1.1 =
French translation, WPML and Polylang compatibility, LearnDash support.

= 1.1.0 =
Renamed plugin, updated libraries, improved WordPress coding standards compliance.

= 1.0.0 =
First release, get ready for the French e-invoicing mandate!
