Developer notes
Add-on identity
Section titled “Add-on identity”| 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 |
Hooks used
Section titled “Hooks used”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).
Database tables
Section titled “Database tables”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.
Concurrency
Section titled “Concurrency”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.
REST API
Section titled “REST API”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=Nmasked list;POST /api/kv_lkc_keyswithpool_idandkeys[]orkeys_text;PUT /api/kv_lkc_keys/:idwithstatusV or A;DELETEremoves an available or void key.GET /api/kv_lkc_keys?order_id=N&reveal=Yreturns the order’s keys in clear text; needs the reveal privilege and is logged.
Activation check
Section titled “Activation check”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.
Template overrides
Section titled “Template overrides”Storefront templates live in design/themes/<theme>/templates/addons/kv_license_keys_codes/. Copy one to your own theme to customize it.