Skip to content

Developer notes

← Overview

app/addons/kv_vendor_kyc_verification/
addon.xml settings, 12 tables, 4 privileges, 6 e-mail templates, install/uninstall functions
init.php / func.php hooks, settings info handlers, storefront data, licence helpers
controllers/backend/kv_vendor_kyc_verification.php admin pages, vendor Verification page, downloads, cron
controllers/backend/companies.pre.php payout hold in core Accounting
controllers/backend/kv_vendor_payouts.pre.php payout hold in Vendor Payouts Automation
controllers/backend/products.pre.php "Add product" notice for restricted vendors
controllers/backend/index.post.php vendor dashboard notice
controllers/frontend/init.post.php badge data for the storefront templates
controllers/backend/kv_vendor_kyc_verification_license.php "Check now" and licence cron
schemas/menu/*.post.php admin menu (Vendors) and vendor panel menu
schemas/permissions/*.post.php privileges, vendor modes, cron as trusted controller
schemas/block_manager/blocks.post.php block cache: our table + licence/settings key on product and vendor blocks
Tygh/Addons/KvVendorKycVerification/
Config.php settings
Types.php document types and their scope (plans, countries, business type), install defaults
Documents.php submissions, approve/reject/re-upload, expiry, queue, retention, erasure
Files.php secure storage: upload checks, AES-256-GCM, download, deletion
Vendors.php requirement states, levels, restrictions, storefront map
Notifier.php e-mails
Cron.php scheduled task (expiry, levels, reminders, retention)
Log.php audit log
Vrb.php optional integration with Vendor Onboarding & Registration Builder
StorageData.php run marks (files instead of storage_data while the full page cache is on)
License/, Upgrade/ licence client, self-healing upgrades
design/backend/templates/addons/kv_vendor_kyc_verification/ admin + vendor panel views, components, licence UI
var/themes_repository/responsive/templates/addons/kv_vendor_kyc_verification/ badge component + hooks
var/langs/en/addons/kv_vendor_kyc_verification.po
Table Purpose
kv_vkyc_types + kv_vkyc_type_descriptions Document types: required, expiry mode (N none, D date from the vendor, M months after approval), validity months, scope (plan_ids, countries, business_type ''/I/C), allowed extensions, size and file limits, status, position; name and instructions per language
kv_vkyc_documents Submissions: vendor, type, status (P pending, A approved, R rejected or new upload requested, S superseded), expiry, vendor note, reason, source (V vendor, A administrator, R vendor application), uploader, reviewer, reminder marks, purge time
kv_vkyc_files Files of a submission: original name, storage path, size, MIME type, SHA-256 of the original, encrypted flag
kv_vkyc_vendors Per vendor: level (U, P, V, E, N), restricted flag, business type, exempt flag, first time documents were required, verified time, earliest expiry. The only table the storefront reads; rows are written only when a value changes
kv_vkyc_log Audit log

DAC7 (1.1.0):

Table Purpose
kv_vkyc_tax_profiles Seller tax details per company; tin_data, birth_data, account_data encrypted
kv_vkyc_dac7_requests Requests and reminders (company, year, step 0-2, time, channel)
kv_vkyc_dac7_years Per year: EUR rate and its source, statement publication time
kv_vkyc_dac7_filings Built files: year, Member State, MessageRefId, message type (DPI401/402/403), operator DocRefId and data hash, status (B built, F filed, A accepted, R rejected), storage path of the encrypted file, SHA-256
kv_vkyc_dac7_records One record per seller and file: DocTypeIndic (OECD1/2/3), DocRefId, CorrDocRefId, data hash, encrypted snapshot

Classes: Tygh\Addons\KvVendorKycVerification\Dac7\{Calculator, TaxProfiles, Requests, Filings, Xml, Schema, Csv, Statements, Years, Settings, Countries, Crypto}. The calculator reads ?:vendor_payouts (types order_placed, order_changed, order_refunded, exclude_from_balance = N, order status in the core payout statuses) joined with ?:orders; commission_amount is used when the core Vendor plans add-on created the column. Admin controller kv_vendor_kyc_dac7 (privilege manage_kv_vkyc_dac7); vendor modes tax, update_tax, statement (own company only).

Table kv_vkyc_inform_sellers (one row per vendor that was flagged or acted on): hv (Y/N), qualified_at, best 12-month period (window_*), sales and revenue of the last 12 months, disclosure (Y at USD 20,000), data_status (M missing, S submitted, V verified, R rejected), data_enc (all collected data, AES-256-GCM, kvd1: format of the DAC7 module), disc_json (the plain consumer disclosure, written only for a verified seller that must be disclosed), partial, cert_due_at, notice_at/deadline_at, suspended, exempt (P, C, V). The storefront reads only the plain columns.

Classes Tygh\Addons\KvVendorKycVerification\Inform\{Sales, Rules, Settings, Sellers, Engine, Mail}. Sales and Rules are pure (no database): Sales::evaluate($events, $now, $tz) tests every 12-month period (calendar months in the shop time zone) that lies in the previous 24 months; Rules::state($row, $now) says what is due. Both are covered by tests/unit-inform.php. Engine::run() is called by the add-on cron. Controller kv_vendor_kyc_inform: vendors reach seller, save, certify only (the schema lists every other mode with permissions => false and the controller checks it again); administrators need the privilege manage_kv_vkyc_inform.

Log actions: inform_flag, inform_unflag, inform_data, inform_verify, inform_reject, inform_certify, inform_notice, inform_suspend, inform_unsuspend, inform_exempt, inform_reveal, inform_export, inform_purge. The log never contains bank or tax data.

Suspension hides the vendor’s products through the same get_products / get_product_data conditions as the visibility restriction, and blocks new products through update_product_pre. Full page cache: the storefront block is the same for every visitor and comes from one indexed read of kv_vkyc_inform_sellers.

Files are encrypted with AES-256-GCM (openssl_encrypt). The key is HMAC-SHA256("kv_vendor_kyc_verification|files|v1", config crypt_key). A stored file is KVK1 + 12-byte IV + 16-byte tag + ciphertext. The SHA-256 of the original is kept for integrity checks. Encryption is used only with the local file storage backend; on other backends files are stored as they are (still only through the storage API and the permission-checked controller).

DAC7 values, report files and filed records use AES-256-GCM with the key HMAC-SHA256("kv_vendor_kyc_verification|dac7|v1", config crypt_key), stored as kvd1: + base64(IV, tag, ciphertext). Without OpenSSL AES-256-GCM they are stored as kvp1: + base64 and the DAC7 page shows a warning.

The badge and the hidden products are the same for every visitor. They come from one indexed query on kv_vkyc_vendors per storefront request, so pages cached by the full page cache carry that table as a cache tag and are purged when a level or restriction changes. Product and vendor blocks get kv_vkyc_vendors in their update_handlers and a callable cache key with the licence and settings state. The add-on writes nothing during storefront requests.

Core hooks used (identical signatures in 4.17.2 and 4.21.2): get_products and get_product_data (hide products of restricted vendors on the storefront), update_product_pre (no new products from restricted vendors in the vendor panel), delete_company (remove documents, files, log, level), before_dispatch (hourly pseudo-cron from panel page views).

Template hooks: companies:vendor_rating, companies:featured_vendors, companies:product_company_data, companies:products (pre), companies:view (pre).

Hooks of the add-on (fn_set_hook):

Hook Arguments Use
kv_vendor_kyc_verification_document_submitted $doc, $type, &$decision Runs after every upload. Integration point for identity verification services: send the files to a provider and set $decision = ['action' => 'approve', 'expires_at' => <timestamp>] or ['action' => 'reject', 'reason' => '...'] to review the upload automatically; leave it empty for manual review.
kv_vendor_kyc_verification_document_reviewed $doc, $action After approve, reject or re-upload request.
kv_vendor_kyc_verification_level_changed $company_id, $old_level, $new_level After a vendor’s level changed ('' as old level for a new vendor row).
kv_vendor_kyc_verification_is_restricted $company_id, $restriction, &$result Change whether a restriction (payouts, hide_products, new_products) applies to a vendor.

File contents of a submission: \Tygh\Addons\KvVendorKycVerification\Files::contents($file_row) returns the decrypted bytes.

Dispatch Who Method
kv_vendor_kyc_verification.manage (&tab=vendors), .vendor, .types, .type, .log Administrators (view_kv_vkyc) GET
.approve, .reject, .reupload, .set_expiry, .admin_upload, .import_vrb, .update_vendor, .erase, .update_type, .delete_type, .run_cron Administrators (manage_kv_vkyc) POST
.verification, .upload, .update_business Vendors (own company only) GET / POST
.download&file_id= Administrators; vendors for their own files GET
.cron Console, or HTTP with the core cron password GET

All POST requests are protected by the core form token.

fn_kv_vendor_kyc_verification_is_licensed() (License\Client::isActive()) together with the Enable setting gates vendor uploads, the restrictions, the storefront badge and the reminder e-mails. Reviews, downloads, the audit log, retention and erasure always work, so documents never become inaccessible. The licence check itself runs only in the admin panel or from cron (php admin.php --dispatch=kv_vendor_kyc_verification_license.check).