=== TINXDK EAN Betaling Lite ===
Contributors: tinxdk
Tags: woocommerce, ean, nemhandel, invoice, payment gateway
Requires at least: 6.3
Tested up to: 7.1
Requires PHP: 8.2.35
Requires Plugins: woocommerce
WC requires at least: 8.0
WC tested up to: 11.2
Stable tag: 2.0.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

EAN (NemHandel) invoice payment for WooCommerce: EAN number with check-digit validation, reference fields, Checkout Blocks and ALTCHA.

== Description ==

**English**

Let business and public-sector customers pay by invoice with their EAN number. The plugin adds the payment method "EAN-betaling" to WooCommerce (classic checkout and Checkout Blocks):

* Validation of the EAN number: 13 digits, GS1 check digit, blocklist and a test number for test orders.
* Reference person and requisition number (required / optional / hidden).
* The EAN data is shown on the order screen, in the orders list, in emails, on the thank-you page and in My Account. HPOS compatible.
* Choose the order status for new EAN orders, keep unpaid EAN orders from being cancelled automatically and limit the method to Danish billing addresses.
* ALTCHA proof-of-work spam protection, self-hosted (no third-party service, no cookies).
* Translated into Danish.

The plugin makes no external requests and needs no account.

**Pro add-on (optional)**

The separate add-on "TINXDK EAN Betaling Pro" (not part of this plugin, needs a licence key from tinxdkcloud.dk) adds live EAN lookup in NemHandel/Peppol and company lookup in the Danish CVR register, selectable production units (P-numbers), risk assessment per order, a handling fee and WooCommerce Subscriptions support. This plugin works fully without it.

**Dansk**

Lad erhvervs- og offentlige kunder betale via faktura med deres EAN-nummer. Pluginet tilføjer betalingsmetoden "EAN-betaling" til WooCommerce (klassisk kasse og Checkout Blocks) med validering af EAN-nummer (13 cifre + kontrolciffer), referenceperson, rekvisitionsnummer, visning af EAN-data på ordrer og i mails samt selvhostet ALTCHA-spambeskyttelse. Dansk oversættelse er inkluderet. Det valgfrie tillæg "TINXDK EAN Betaling Pro" giver live-opslag i NemHandel/CVR, produktionsenheder, risikovurdering, håndteringsgebyr og understøttelse af WooCommerce Subscriptions.

Testnummer til testkøb (kræver testtilstand): 9999888877778.

== Installation ==

1. Install the plugin from the WordPress plugin directory or upload the plugin folder to `/wp-content/plugins/` and activate it (WooCommerce must be active).
2. Go to WooCommerce > Settings > Payments > EAN payment and configure the method.

== Frequently Asked Questions ==

= The checkout shows no EAN fields in Checkout Blocks =
Make sure the payment method is enabled. The block script needs no build step; clear any script-optimisation caches.

= Does the plugin look up the EAN number or the company? =
No. The free plugin only validates the number (13 digits and check digit) and makes no external requests. Live lookup in NemHandel/Peppol and the CVR register is part of the separate Pro add-on.

= Which hooks can I use? =
Add-ons plug in through the actions and filters whose names start with `tinxdk_ean_` (for example `tinxdk_ean_loaded`, `tinxdk_ean_validate_checkout`, `tinxdk_ean_form_fields`, `tinxdk_ean_settings_defaults`, `tinxdk_ean_blocked_numbers` and `tinxdk_ean_is_available`). See README.md in the plugin folder.

= I used "TINXDK WP EAN Betaling" before =
This plugin replaces it (new name and folder). Deactivate and delete the old plugin first, then activate this one: settings and order data are kept because the option names, order meta keys and the gateway id are unchanged.

== External services ==

This plugin does not connect to any external service. The ALTCHA widget script is bundled with the plugin and the proof-of-work challenge is created and verified on your own server.

== Upgrade Notice ==

= 2.0.1 =
Renamed to TINXDK EAN Betaling Lite (no functional change).

= 2.0.0 =
The licence-gated features moved to the separate add-on "TINXDK EAN Betaling Pro". If you used lookup, production units, risk assessment, the handling fee or Subscriptions support, install the Pro add-on with your licence key; your settings and order data are kept.

== Changelog ==

= 2.0.1 =
* Changed: Renamed to TINXDK EAN Betaling Lite (no functional change). Slug, settings and data are unchanged.

= 2.0.0 =
* Changed: The plugin is now two plugins. "TINXDK EAN Betaling Lite" (this plugin, WordPress.org) contains everything that works for everyone: the EAN payment method (classic checkout and Checkout Blocks), EAN validation (13 digits, GS1 check digit, blocklist, test mode), reference person, requisition number, EAN data on orders (HPOS), in emails, on the thank-you page and in My Account, and ALTCHA. The licence-gated features (live EAN lookup in NemHandel/Peppol, CVR company lookup, production units, risk assessment, handling fee, WooCommerce Subscriptions support, API error emails) moved to the separate add-on "TINXDK EAN Betaling Pro", which also contains the licence client and the automatic updates. The free plugin contains no licence or updater code and makes no external requests.
* Changed: Renamed from "TINXDK WP EAN Betaling" (tinxdk-wp-ean-betaling) to "TINXDK EAN Betaling Lite" (tinxdk-ean-betaling). Option names, order meta keys, the gateway id and all constants are unchanged, so settings and orders carry over.
* New: Extension points for add-ons (actions and filters `tinxdk_ean_loaded`, `tinxdk_ean_settings_defaults`, `tinxdk_ean_settings`, `tinxdk_ean_form_fields`, `tinxdk_ean_sanitize_settings`, `tinxdk_ean_admin_sections`, `tinxdk_ean_validate_checkout`, `tinxdk_ean_after_ean_field`, `tinxdk_ean_store_order_data`, `tinxdk_ean_pre_process_payment`, `tinxdk_ean_order_placed`, `tinxdk_ean_gateway_supports`, `tinxdk_ean_order_meta_box`, `tinxdk_ean_badge_level`, `tinxdk_ean_tooltip_lines`, `tinxdk_ean_classic_script_data`, `tinxdk_ean_blocks_data`, `tinxdk_ean_blocks_script_handles`, and `window.tinxdkEan.registerBlocksExtension()` in the block script).
* New: A dismissible hint about the Pro add-on on the plugin's own settings page and a "Pro" link in the plugin row.
* Changed: Tested up to WordPress 7.1; the plugin no longer loads its translations itself (WordPress does).

= 1.1.0 =
* New: License system with a free edition and a licensed edition. Free: EAN payment method, EAN validation (check digit), reference person, requisition number, order data display (admin, emails, thank-you, My Account), ALTCHA. Licensed: live EAN lookup, CVR company lookup, production units, risk assessment, handling fee, Subscriptions support.
* New: Automatic updates through the TINXDK license server (needs an active license). License section in the EAN payment settings.
* Changed: Licensed settings are shown disabled with a "Requires license" label without a license; saved values are kept and apply again when a license is active.

= 1.0.3 =
* Changed: Requires PHP 8.2.35 or newer. On older PHP the plugin stays inactive and shows an admin notice.

= 1.0.2 =
* Fix: Checkout Blocks no longer clears the billing address typed just before choosing or leaving the EAN payment method (the fee refresh no longer X =
* Security: ALTCHA challenges can no longer be forged by moving digits between salt and number (strict salt/number format); replay protection is now atomic (options table, daily cleanup); ALTCHA is verified before any registry lookup.
* Fix: Checkout Blocks now actually passes the EAN fields to the server (the payment context was read with isset, which is always false).
* Fix: The handling fee is decided from the real payment method of the order (Store API request) and can no longer be avoided or leak to other gateways through the client-controlled flag.
* Fix: EAN is no longer hidden for subscription carts in Checkout Blocks.
* Fix: Stock is reduced through wc_maybe_reduce_stock_levels() so it is restored when the order is cancelled.
* Fix: Re-fetching EAN data no longer overwrites existing data when the registry lookup fails; admin notices after re-fetch and misuse report; misuse reports need the manage_woocommerce capability; admin CSS only on order screens.
* Fix: Previous-usage risk only counts earlier orders and no longer silences WooCommerce notices.
* Fix: Availability uses the order's billing country on the order-pay page.
* Fix: Plain-text emails no longer show HTML entities.
* Fix: The classic checkout script is no longer loaded on the block checkout page.
* New: NemHandel Register fallback when the Peppol Directory does not know the EAN number (an unreachable register never rejects an order).
* New: Registry lookups are memoised per request, time out after 5 seconds (filter tinxdk_ean_http_timeout), failures are cached for 5 minutes and "not found" for at most 1 hour; company lookup uses the exact CVR and rejects mismatching companies.
* New: Subscriptions: "Keep subscription active on renewal" setting, EAN data synced for all subscription order types and when a failing payment method is replaced, change of payment method to EAN.
* New: Client IP filter for the rate limiter (IPv6 grouped per /64); uninstall removes transients, replay rows, user meta and works on multisite.
* Improved: Checkout Blocks keeps the entered values when switching payment method, translated and expiring ALTCHA widget, accessibility attributes, description rendered as plain-text paragraphs, message when the EAN is found without company name.

= 1.0.0 =
* Initial release.
