Skip to content

Developer notes

Item Value
Add-on id kv_license_keys_codes
Function prefix fn_kv_license_keys_codes_
Language variables kv_license_keys_codes.*
PHP namespace Tygh\Addons\KvLicenseKeysCodes
  • change_order_status: delivers or takes back keys (before the core notifications);
  • delete_order: frees the keys of a deleted order;
  • delete_product_post: removes the product’s pool rows.

Template hooks: orders:details (storefront order page), profiles:my_account_menu, orders:tabs_extra (admin order tab).

kv_lkc_pools, kv_lkc_pool_map (product and variant ids), kv_lkc_keys (encrypted key, HMAC hash, mask), kv_lkc_deliveries (unique on order, line, unit), kv_lkc_orders (waiting orders), kv_lkc_activations, kv_lkc_log, kv_lkc_meta (encryption secret, activation secrets). All are kept on uninstall unless “Delete all data on uninstall” is on.

An order is processed under a named lock; each key is claimed with one conditional UPDATE (status A to S) and the delivery row has a unique index, so parallel processes, retries and double clicks never deliver a unit twice.

  • GET/POST/PUT/DELETE /api/kv_lkc_pools: pools (name, status, key_label, instructions, low_threshold, max_activations, company_id, product_ids[]).
  • GET /api/kv_lkc_keys?pool_id=N masked list; POST /api/kv_lkc_keys with pool_id and keys[] or keys_text; PUT /api/kv_lkc_keys/:id with status V or A; DELETE removes an available or void key.
  • GET /api/kv_lkc_keys?order_id=N&reveal=Y returns the order’s keys in clear text; needs the reveal privilege and is logged.

Signature: hex(HMAC-SHA256(secret, cid "\n" action "\n" key "\n" instance "\n" ts)). Answer header X-Kv-Signature = hex(HMAC-SHA256(secret, body)). States: valid, activated, deactivated, limit_reached, not_sold, void, revoked, unknown. The signature is symmetric (one shared secret per seller): call the endpoint from your own server, never from code you distribute, and regenerate the secret if it leaks. A signed request can be replayed within the 5-minute window; activate and deactivate are idempotent per instance.

REST API and Multi-Vendor: a vendor administrator is always bound to his own company, also when he signs in with a storefront auth token.

Storefront templates live in design/themes/<theme>/templates/addons/kv_license_keys_codes/. Copy one to your own theme to customize it.