=== GestOO Connector for Peppol Invoicing for WooCommerce ===

Contributors: webdigit
Tags: woocommerce, peppol, invoice, e-invoicing
Requires at least: 6.0
Tested up to: 6.9
Stable tag: 1.0.5
Requires PHP: 7.4
Requires Plugins: woocommerce
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Connect your WooCommerce store to GestOO for official invoices and Peppol e-invoicing. Belgium 2026 compliant. Simple setup.

== Description ==

**Keep your WooCommerce store compliant with Peppol e-invoicing** — mandatory for B2B in Belgium (Jan 2026) and rolling out across the EU. This plugin connects your store to **GestOO**, your Belgian invoicing and accounting platform, so you can create official invoices and send them on the **Peppol** network without complex setup.

* **Simple:** Configure once (API token + trigger status). Orders automatically create invoices in GestOO and can be sent via Peppol.
* **Compliant:** GestOO uses a certified Peppol Access Point — invoices meet B2B e-invoicing requirements.
* **Transparent:** On each order, see sync status, invoice number, Peppol delivery status, and quick links to open in GestOO or retry.
* **Transparent pricing:** €99/year includes 50 documents/month — no hidden fees. See gestoo.be/tarifs for full details.
* **No lock-in:** Official invoicing stays in GestOO. WooCommerce remains your store; GestOO remains your invoicing hub.

**Requirements:**

* WordPress 6.0+
* WooCommerce 7.0+
* PHP 7.4+
* A **GestOO** account with the WooCommerce module enabled and an **API token**

Without a valid API token, plugin settings remain disabled and a clear link to create a GestOO account is shown.

= How it works =

* When an order reaches a trigger status (e.g. Completed), the plugin sends order data to GestOO.
* GestOO creates the invoice and can send it via Peppol (after your account is validated).
* On the order edit screen, a "Peppol Invoice" box shows: sync status, invoice number, Peppol status, and links to open the invoice in GestOO or retry actions.

Support: hello@gestoo.be

== Installation ==

1. Upload the plugin folder to `wp-content/plugins/` or install via WordPress admin.
2. Activate the plugin under **Plugins**.
3. Go to **WooCommerce > Settings > Integrations > Peppol Invoicing**.
4. Enter your GestOO API token, then click **Test connection**.
5. Configure trigger order statuses and optional automatic Peppol send.

== Frequently Asked Questions ==

= Is this compliant with Belgium's 2026 B2B e-invoicing mandate? =

Yes. When used with GestOO, invoices are created in the required Peppol BIS Billing 3.0 format and sent via a certified Peppol Access Point. This meets the mandatory B2B e-invoicing requirements for Belgian VAT-registered businesses.

= What does it cost? =

GestOO WooCommerce + Peppol: €99/year with 50 documents (invoices) per month included. No hidden fees. See gestoo.be/tarifs for full pricing and volume tiers.

= Do I need a GestOO account? =

Yes. Invoicing and Peppol are handled by GestOO. This plugin only connects your store to GestOO. Create an account at gestoo.be and get an API token from your GestOO dashboard.

= Why are settings disabled? =

Settings are disabled until the connection test succeeds (valid API token). This avoids sending data to an invalid or missing backend.

= Who handles Peppol compliance? =

GestOO uses a certified Peppol Access Point to send invoices on the Peppol network. This plugin does not implement Peppol in WordPress.

== Screenshots ==

Settings, order meta box when generation is blocked, and meta box when invoice is generated.

1. WooCommerce Settings > Integrations > Peppol Invoicing (API token, trigger statuses).
2. Order edit screen: Peppol Invoice meta box when status prevents generation (configuration link).
3. Order edit screen: Peppol Invoice meta box with invoice generated (invoice number, Open in GestOO, Download PDF).

== Changelog ==

= 1.0.5 =
* **Fix automatic invoice sync:** order status from WooCommerce has no `wc-` prefix in the status-changed hook, but trigger settings use keys like `wc-completed`. Triggers now match correctly so invoices are created when the order reaches a selected status.

= 1.0.4 =
* **GestOO sending mode alignment:** the send API follows your GestOO account setting (**GestOO → Settings → Modules → Invoicing → Sends tab**): email only, Peppol only, email + Peppol, or disabled. Requires a current GestOO backend; if sending is disabled in GestOO, no invoice is sent automatically from the plugin.
* **Clearer admin errors:** failed sends show a readable message, including the current GestOO sending mode and where to change it in GestOO.
* French translations updated for the new strings (fr_FR .po).

= 1.0.3 =
* Payload now includes payment_method_title (human-readable payment method). When an order is paid, GestOO invoice displays "Commande WooCommerce payée via [method] le [date]" instead of standard payment conditions.

= 1.0.2 =
* Customer payload now includes billing phone. GestOO creates/updates a contact with name, email, and phone when creating invoices from WooCommerce orders.
* VAT number: GestOO stores country code (ISO) and digits separately for PEPPOL compliance.

= 1.0.1 =
* VAT number normalization: extract country code and digits only (no spaces, dots, hyphens) before sending to GestOO. Fixes PEPPOL rejection when WooCommerce stores "BE 056.776.111" or "056.776.111".
* Detailed Peppol error messages (e.g. mod97 invalid) now propagated to WooCommerce order meta and displayed in meta box and event log modal.
* Setting "Normalize VAT for PEPPOL" now applies to all EU countries, not just Belgium.

= 1.0.0 =
* **1.0 stable release.** Production-ready WooCommerce to GestOO connector for Peppol e-invoicing.
* Retry button: full sync + Peppol send when status is Pending, Rejected, or Error. Client data (VAT, address, email) updated from WooCommerce when retrying.
* Sync button in orders list for Pending/Rejected/Error; no Sync when already Delivered (use Retry to resend).
* Peppol error messages: full validation messages (e.g. PEPPOL-COMMON-R043) stored and displayed when send is rejected.
* HPOS compatible. Belgium 2026 B2B e-invoicing compliant.

= 0.9.0 =
* Retry button when Peppol status is Rejected: allows re-attempting send after tenant configuration or VAT correction (calls send-peppol API).
* Refresh status now only reads status; use Retry to re-evaluate and resend.

= 0.8.0 =
* Dates facture : created_at (date création commande) et paid_at (date paiement) transmises à GestOO. Factures non payées marquées comme non soldées.
* Icônes cohérentes : Sync (dashicons-update) et Ouvrir dans GestOO (dashicons-external) dans la liste des commandes.
* Spinner WordPress pendant les actions AJAX (Generate invoice, Sync, Send Peppol, Refresh).
* Rafraîchissement de la colonne Peppol sans rechargement après Sync réussi.

= 0.7.0 =
* Fixed Test payload result not visible (ID conflict between API token and payload result div).
* Improved mapping descriptions: explicit note that keys are tested in order and first non-empty value wins.

= 0.6.0 =
* Reorganized settings page into tabs: General settings | Diagnostic | Test order.
* Fixed Diagnostic and Test payload buttons (were rendered as text inputs; now use proper WooCommerce filter `woocommerce_generate_*_html`).
* Clear separation of concerns: connection/mapping in General, diagnostic in Diagnostic tab, payload test in Test order tab.

= 0.5.0 =
* Added "Test order" section in settings: select an order and run a dry-run payload test without creating an invoice.
* Payload test displays VAT number, language, vat_rate per line, field status (✓/✗), and warnings.
* Toggle to show full JSON payload for debugging.
* Banner "Settings modified. Test an order to validate." shown after saving settings, cleared after a successful test.

= 0.4.0 =
* Added Peppol status columns in the WooCommerce orders list (HPOS + legacy compatible).
* Added smart sync/retry button in the orders list: creates invoice if missing, refreshes Peppol status if already sent.
* Added event log modal (ℹ button) showing timestamped error history per order.
* Stored error log (up to 20 entries) in order meta for diagnostics.

= 0.3.1 =
* Added review prompt (J+30 after activation) to help users rate the plugin.
* Added uninstall cleanup (removes plugin options on deletion).
* Added plugin banner and screenshots on WordPress.org directory page.

= 0.3.0 =
* Renamed plugin to "GestOO Connector for Peppol Invoicing for WooCommerce" (slug: gestoo-connector-for-peppol-invoicing) to comply with WordPress.org trademark guidelines.

= 0.2.0 =
* Added "Requires Plugins: woocommerce" header for WordPress 6.5+ plugin dependency support.
* Replaced inline JS and CSS with proper wp_enqueue_script / wp_enqueue_style / wp_localize_script calls.

= 0.1.1 =
* Text domain aligned with plugin slug.
* Tested up to WordPress 6.9. Removed deprecated load_plugin_textdomain call.
* Default API URL set to https://my.gestoo.be.

= 0.1.0 =
* Initial release.
* Connection to GestOO API (health, create invoice, Peppol send, status).
* WooCommerce integration settings and order meta box.
* HPOS compatible.

== Upgrade Notice ==

= 1.0.4 =
Sending from WooCommerce now respects GestOO invoice sending mode (email / Peppol / both / off). Update GestOO first if you rely on this behavior. Clearer error messages in the admin. Safe to update.

= 1.0.3 =
Payment method displayed on GestOO invoices for paid WooCommerce orders. Safe to update.

= 1.0.2 =
Billing phone sent to GestOO for contact creation. VAT stored with separate country code. Safe to update.

= 1.0.1 =
VAT normalization fix: removes spaces/dots/hyphens from VAT numbers. Detailed Peppol errors (e.g. mod97) now shown in WooCommerce. Safe to update.

= 1.0.0 =
1.0 stable release. Retry syncs client data and resends. Full Peppol error messages displayed. Safe to update.

= 0.9.0 =
Retry button when Peppol send was rejected (e.g. tenant not configured). Use it to re-attempt after configuration. Safe to update.

= 0.8.0 =
Invoice dates from WooCommerce (created_at, paid_at). WordPress spinner during AJAX. Column refresh without page reload. Safe to update.

= 0.7.0 =
Fixes Test payload result visibility and improves mapping field descriptions. Safe to update.

= 0.6.0 =
Settings page now organized in three tabs (General, Diagnostic, Test order). Buttons fixed. Safe to update.

= 0.5.0 =
Adds "Test order" section to validate payload before first real send. Safe to update.

= 0.4.0 =
Adds Peppol status columns and sync/retry button in the orders list. Safe to update.

= 0.3.1 =
Adds review prompt and uninstall cleanup. Safe to update.

= 0.3.0 =
Plugin renamed for WordPress.org directory compliance. Re-activate after update.

= 0.2.0 =
Inline JS/CSS replaced with wp_enqueue calls. Re-activate after update.

= 0.1.0 =
Initial release. Requires WordPress 6.0+, WooCommerce 7.0+, PHP 7.4+, and a GestOO account with API token.
