=== ZadKeys – License Key Delivery for WooCommerce ===
Tags: woocommerce, license keys, digital products, supplier, license delivery
Requires at least: 5.8
Tested up to: 7.1
Requires PHP: 7.4
WC requires at least: 5.0
WC tested up to: 11.1
Stable tag: 0.4.1
License: GPL-2.0+
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Sync supplier products into WooCommerce and deliver supplier-allocated license keys, with retries, admin recovery, logging and HPOS support.

== Description ==

ZadKeys – License Key Delivery for WooCommerce connects your WooCommerce store to a supplier that allocates digital license keys.

* Manual product sync (Sync products button) from the supplier's WooCommerce REST API, with three modes: create only, update imported products, or update price and stock only.
* Automatic license key delivery for paid orders, with keys stored encrypted.
* Automatic retries and manual admin recovery for failed deliveries.
* Global markup percentage (automatic pricing) or manual WooCommerce pricing.
* Operational logging.
* Compatible with WooCommerce High-Performance Order Storage (HPOS).

= Free version and ZadKeys Pro =

* This free plugin imports up to 3 supplier products. Products that are already imported keep updating. Every other feature is fully available.
* ZadKeys Pro is a separate premium plugin, sold and delivered through Freemius, with unlimited imported products. It includes a 30-day free trial (no credit card required). Upgrade from WooCommerce > ZadKeys > Upgrade.
* Product sync is manual (Sync products button) in both versions. There is no automatic or scheduled sync.


= Interface languages =

Bundled translations: Arabic, German and Turkish. English is the default. The admin interface follows the WordPress user language; other messages follow the current site/request language. Any other language uses English for ZadKeys messages. Regional variants without a matching translation catalog also fall back to English. Freemius screens use their own SDK translations.

== Installation ==

1. Install and activate WooCommerce.
2. Upload and activate ZadKeys – License Key Delivery for WooCommerce.
3. Go to WooCommerce > ZadKeys and enter the supplier API URL, Consumer Key and Consumer Secret.
4. Click Test Connection, then run a product sync.

== Frequently Asked Questions ==

= Does it require WooCommerce? =

Yes, WooCommerce 5.0 or newer.

= What happens when the free product limit is reached? =

New supplier products are skipped and an admin notice explains why. Products that are already imported keep syncing. To import more products, upgrade to ZadKeys Pro, the separate premium plugin.

== External services ==

This plugin connects to the following external services.

= Supplier API (configured by the store owner) =

Product sync and license key delivery call the WooCommerce REST API of the supplier store whose URL, Consumer Key and Consumer Secret you enter under WooCommerce > ZadKeys. Product sync requests the supplier's product list. When an order that contains synced products is paid, the plugin sends the order ID and order item ID, the product and supplier SKU and the quantity, and receives the allocated license keys. Nothing is sent until you configure the supplier and sync products or receive such orders. The supplier's own terms and privacy policy apply.

= Freemius =

The plugin includes the Freemius SDK (https://freemius.com), used for the optional opt-in, licensing, updates of ZadKeys Pro, and the in-dashboard pricing and checkout pages.

* Opt-in: only if you click "Allow & Continue", the admin's name and email, the site URL, WordPress and PHP versions, site language and plugin version, and (optional) the list of active plugins and themes are sent to Freemius. You can skip the opt-in or opt out at any time. Optional deactivation feedback is sent only if you give it.
* Pricing, checkout and account: loaded from Freemius when you open WooCommerce > ZadKeys > Upgrade or Account.
* ZadKeys Pro: license activation and update checks are sent to Freemius (api.freemius.com).

Freemius terms: https://freemius.com/terms/ and privacy policy: https://freemius.com/privacy/

== Changelog ==

= 0.4.1 =
* New: Kinguin connection type with price limits, asynchronous keys and webhooks.
* Improved: webhooks can use a shared secret header.

= 0.4.0 =
* New: OAuth2 and login-token authentication for the Generic REST API.
* New: suppliers that deliver keys later (status checks and signed webhooks).
* New: automatic product sync (hourly, twice a day or daily).

= 0.3.9 =
* New: Generic REST API connection type with field mapping for suppliers that offer a JSON API.
* New: Connection type setting; the compatibility test previews the first mapped product.
* Safety: unreadable or partial generic orders are never re-ordered automatically.

= 0.3.8 =
* New: "Additional HTTPS ports" setting for suppliers that use a port other than 443 (for example 8443).
* Improved: internal supplier connection layer prepared for more supplier APIs. Existing supplier connections work exactly as before.

= 0.3.7 =
* Improved: supplier URLs use port 443 by default; other ports can be allowed with the `wclb_supplier_allowed_ports` filter.
* Improved: supplier responses are only accepted when the connection was bound to the checked address.
* Fixed: an interrupted delivery attempt is now flagged for review even after automatic retries are used up.

= 0.3.6 =
* Hardened supplier connections: delivery and product sync only connect to public supplier addresses, connect to the address that was checked, and do not follow redirects.
* Improved: license keys are shown only in customer emails, not in the store's "New order" email.
* Improved reliability: reprocessing a "Needs manual review" item now asks for an explicit confirmation and shows a clear warning that the supplier may already have delivered the keys.

= 0.3.5 =
* Fixed: manual key delivery retry is now limited to completed orders.
* Improved: delivery status is tracked per item, separately from the WooCommerce order status; an item is marked Delivered only after the supplier response is verified.
* New: "Needs manual review" status when the supplier outcome is unknown (for example a timeout after the request was sent). Such items are not retried automatically; reprocessing reuses the same request ID.
* Improved: smart retry. Temporary errors (HTTP 5xx, 429 with Retry-After, connection failures before sending) retry with a bounded backoff (5, 15, 30, 60, 180 minutes, at most 5 retries). Rejected credentials, bad requests and confirmed out-of-stock results are not retried automatically.
* Improved: an interrupted delivery attempt is detected and flagged for review instead of staying in processing.
* Improved: the order screen shows the real result of "Retry now", and customer emails/order pages say when keys are not ready yet instead of implying delivery.
* Fixed: the WooCommerce "Completed order" email now includes the delivered license keys, or says that keys are not ready yet.
* New: supplier compatibility test button (HTTPS, public address, credentials, product list and /wclb/v1/license contract). No key is used and no order is created.

= 0.3.4 =
* Updated Freemius SDK to the latest version.

= 0.3.3 =
* Fix: supplier Consumer Key/Secret sanitize no longer nests ciphertext when an already-encrypted value is passed through the Settings API sanitize filter (e.g. update_option after register_setting).
* Fix: re-saving when a double-encrypted value's inner ciphertext layer is re-posted heals to a single ciphertext layer.
* Fix: Consumer Key field does not echo nested ciphertext after a corrupted store.
* Fix: failed credential encryption keeps the previous good stored value (never stores plaintext, never wipes a good secret).

= 0.3.2 =
* Fix settings, AJAX and JavaScript messages following the WordPress language.
* Bundle Arabic, German and Turkish translations; use English for unsupported languages.
* Improve Arabic spacing, alignment and narrow-screen settings layout.
* Preserve current product sync, pricing, delivery and retry behavior.

= 0.3.1 =
* Changed: The free plugin contains no license or trial check. The Pro unlock exists only in ZadKeys Pro.
* Removed: The old ZadKeys License Manager (the WooCommerce > License page and its daily check against zadkeys.com). Licensing now runs only through Freemius, and automatic delivery no longer depends on a license check. On update, the old license key, its status and its daily check are deleted. If the old check paused any orders, an admin notice lists them so you can deliver them with Retry now.

= 0.3.0 =
* New: Freemius SDK for the optional opt-in and the in-dashboard upgrade to ZadKeys Pro.
* New: ZadKeys Pro, a separate premium plugin with unlimited imported products and a 30-day free trial, no credit card required.
* New: The free plugin imports up to 3 supplier products.
* Fix: No opt-in redirect when WooCommerce is inactive.
* Fix: Uninstall also removes the pricing options and the free limit notice.

= 0.2.1 =
* New: Global markup percentage and automatic/manual pricing modes.

== Upgrade Notice ==

= 0.4.1 =
Adds the Kinguin connection type. Existing connections are unchanged.

= 0.4.0 =
Adds OAuth2, delayed key delivery with webhooks and scheduled product sync. Existing connections are unchanged.

= 0.3.9 =
Adds the Generic REST API connection type. Existing connections are unchanged.

= 0.3.8 =
Adds a setting for suppliers on HTTPS ports other than 443. No change for existing connections.

= 0.3.7 =
Maintenance release with connection and retry handling fixes. Recommended update.

= 0.3.6 =
Hardened supplier connections and improved reliability of manual reprocessing. Recommended update.

= 0.3.5 =
More reliable key delivery and retries, a "Needs manual review" status, and a supplier compatibility test.

= 0.3.4 =
Updated Freemius SDK to the latest version.

= 0.3.3 =
Hardens supplier credential save against nested encryption. Update in place; do not uninstall. Re-enter Consumer Key/Secret from WooCommerce > ZadKeys if Test Connection fails after a prior double-encrypted store.

= 0.3.2 =
Language and interface maintenance update. Update the existing plugin in place; do not delete/uninstall it, as uninstall removes settings. No database migration.

= 0.3.1 =
Removes the old WooCommerce > License page and its daily check against zadkeys.com. Orders it paused are listed in an admin notice for delivery with Retry now.

= 0.3.0 =
Adds the Freemius SDK and ZadKeys Pro (separate premium plugin, 30-day free trial). The free plugin imports up to 3 supplier products.
