=== IFX Live Invoices for WooCommerce ===
Contributors: invoiceflowx
Tags: woocommerce, invoice, xrechnung, zugferd, e-invoice
Requires at least: 6.0
Tested up to: 6.6
Requires PHP: 8.0
Stable tag: 0.1.0
Requires Plugins: woocommerce
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Send WooCommerce invoice PDFs to InvoiceFlowX and attach the returned ZUGFeRD/XRechnung PDF to customer emails.

== Description ==

IFX Live Invoices for WooCommerce connects WooCommerce with the InvoiceFlowX Live API.

When an eligible WooCommerce order is created or changes status, the plugin finds the original invoice PDF, submits it to InvoiceFlowX, waits for the processed e-invoice PDF and attaches that returned ZUGFeRD/XRechnung PDF to the WooCommerce customer email.

The waiting time is configurable. If the waiting time is set to `0` seconds, WooCommerce sends the original customer email immediately and the plugin sends a second email with the InvoiceFlowX e-invoice PDF after the webhook callback arrives.

This plugin is a connector for the InvoiceFlowX software-as-a-service platform. An InvoiceFlowX account and a Live API key are required.

== External services ==

This plugin connects to the InvoiceFlowX Live API to process invoice PDFs into ZUGFeRD/XRechnung PDFs.

The plugin sends the following data to InvoiceFlowX:

* The original WooCommerce invoice PDF.
* The WooCommerce order ID and order number.
* The configured source value `woocommerce`.
* The webhook URL of the WordPress site.
* A webhook secret hash/signature value for callback verification.
* Technical request metadata required to process and return the generated invoice PDF.

The plugin does not send the InvoiceFlowX Live API key to customers. The API key is stored in the WordPress administration settings and is only used for authenticated server-to-server requests to InvoiceFlowX.

InvoiceFlowX uses the submitted PDF and order metadata to generate and return the e-invoice PDF. Processing requires an active Live API subscription and available included generations or sufficient InvoiceFlowX wallet balance.

Service provider:

* InvoiceFlowX: https://www.invoiceflowx.de/
* Documentation: https://www.invoiceflowx.de/dokumentation/
* Terms: https://www.invoiceflowx.de/nutzungsbedingungen/
* Privacy policy: https://www.invoiceflowx.de/datenschutz/

== Privacy ==

Invoice PDFs can contain personal data, business addresses, invoice line items, tax information and payment details. Site administrators must make sure that their privacy policy covers the transfer of invoice PDFs to InvoiceFlowX for e-invoice processing.

The plugin only contacts InvoiceFlowX after the administrator has installed, activated and configured the plugin with a Live API key.

== Installation ==

1. Upload the plugin ZIP file in WordPress under `Plugins > Add New > Upload Plugin`.
2. Activate the plugin.
3. Open `WooCommerce > IFX Live Invoices`.
4. Enter the InvoiceFlowX endpoint, Live API key, webhook secret, original PDF folder and filename pattern.
5. Set the customer email waiting time.
6. Make sure the displayed webhook URL is reachable from InvoiceFlowX.

Default endpoint:

`https://app.invoiceflowx.de/api/import-document.php`

== Frequently Asked Questions ==

= Do I need an InvoiceFlowX account? =

Yes. The plugin requires an InvoiceFlowX account with Live API access and a Live API key.

= What happens if the InvoiceFlowX wallet is empty? =

If the included API generations are used and the wallet has insufficient balance, InvoiceFlowX returns `wallet_insufficient_funds`. The plugin records an order note, informs the administrator and can continue the WooCommerce email flow with the original invoice PDF as fallback.

= Can the plugin send the normal WooCommerce email immediately? =

Yes. Set the waiting time to `0` seconds. WooCommerce sends the first customer email immediately and the plugin sends a second customer email when the InvoiceFlowX e-invoice PDF is available.

== Review notes for WordPress.org ==

This plugin is intended as a SaaS connector. The actual e-invoice generation is performed by InvoiceFlowX, not locally inside WordPress.

Before submission and before each release, the plugin should be checked for the common WordPress.org review issues:

* All output must be escaped with WordPress escaping functions such as `esc_html()`, `esc_attr()` and `esc_url()`.
* All incoming settings, request values and webhook values must be sanitized with WordPress sanitizing functions.
* All administration forms and state-changing actions must use WordPress nonces and capability checks.

These checks are especially important because unescaped output, unsanitized data and missing nonces are common reasons for WordPress.org review rejection.

== Changelog ==

= 0.1.0 =
* Initial release.
