Technical Documentation v1.0.0 WHMCS 9.1.x · PHP 8.2–8.4

Haikhavan Client Experience, Theme Designer & Smart Order

Complete architecture reference, installation guide, database schema, hooks, and troubleshooting.

Quick Installation

  1. Purchase the module and download haikhavan_client_experience_suite-ioncube-8.2-1.0.0-install.zip from your VPSrv Client Area Downloads.
  2. Upload and extract the ZIP into your WHMCS root directory so files land in modules/addons/haikhavan_client_experience_suite/.
  3. Verify PHP 8.2–8.4 with ionCube PHP Loader 14+ / 15.5+ is enabled on your server.
  4. Go to System Settings → Addon Modules in WHMCS Admin, click Activate next to Haikhavan Client Experience, Theme Designer & Smart Order, and assign administrator role access.

Version: 1.0.0
Namespace: Haikhavan\ClientExperience\
Entry Point: modules/addons/haikhavan_client_experience_suite/haikhavan_client_experience_suite.php


1. Architecture & File Inventory

modules/addons/haikhavan_client_experience_suite/
├── haikhavan_client_experience_suite.php   # Config, activate/deactivate/upgrade, Admin & Client dispatchers, autoloader
├── hooks.php                         # 6 WHMCS hooks (ClientAreaHead/Footer/Navbar/HomepagePanels, AdminInvoicesControlsOutput, AdminHomeWidgets)
├── whmcs.json                        # WHMCS Marketplace 1.0 manifest
├── lib/
│   ├── Database.php                  # 6-table Capsule installer, AES-256-CBC+HMAC crypto, HMAC signing key derivation
│   ├── ThemeService.php              # 4 Theme Presets (Haikhavan Modern SaaS, Midnight Dark, Enterprise Slate, Emerald Cloud) & CSS sanitizer
│   ├── MagicLinkService.php          # HMAC-SHA256 signed login-free payment token generator, constant-time verifier & revoker
│   ├── CampaignService.php           # Targeted Popup/Banner rules, event tracker, CMS Landing Pages, OAuth providers & CTR analytics
│   ├── AdminController.php           # 5-tab Admin Console & CSRF-protected AJAX JSON API
│   └── ClientController.php          # Smart Order (view=order), CMS Pages (view=page), Magic Pay (view=pay), OAuth2 (view=oauth)
├── templates/
│   ├── admin/dashboard.php           # Designer, CTR Canvas Chart, CMS Pages, Magic Links & OAuth Hub
│   └── client/
│       ├── smart_order.tpl           # One-Step Smart Order storefront with live Monthly/Quarterly/Annual pricing toggle
│       ├── landing_page.tpl          # Custom CMS promo landing page
│       ├── magic_pay.tpl             # Login-free HMAC-verified express invoice payment view
│       └── oauth_status.tpl          # OAuth2 authorization handoff view
└── assets/
    ├── css/haikhavan_client_experience.css
    └── js/haikhavan_client_experience.js   # Zero-CDN HTML5 Canvas CTR chart & interactive controllers

2. Database Schema

All 6 tables (mod_hk_cx_*) are managed via WHMCS\Database\Capsule::schema().

  1. mod_hk_cx_theme_config: Active visual theme (preset_key, color_mode, primary_color, accent_color, surface_color, text_color, font_family, border_radius, show_dark_toggle, custom_navbar_json, homepage_panels_json, custom_css, custom_head_html, custom_footer_html).
  2. mod_hk_cx_campaigns: Targeted popups & banners (name, kind banner|popup, title, body_html, cta_label, cta_url, badge_text, accent_color, target_pages, audience, frequency_hours, starts_at, ends_at, impressions, clicks, enabled).
  3. mod_hk_cx_landing_pages: Custom CMS promo pages (slug UNIQUE, title, badge_text, hero_headline, hero_subheadline, featured_product_ids_json, features_json, cta_label, cta_url, views, conversions, published).
  4. mod_hk_cx_magic_links: Issued login-free payment links (invoice_id, userid, token_hash SHA-256 UNIQUE, token_preview, signed_token_encrypted, expires_at, max_uses, use_count, last_used_at, status active|used|revoked, created_by_admin).
  5. mod_hk_cx_oauth_providers: OAuth2 config (provider UNIQUE google|github|microsoft|discord, display_name, client_id, client_secret_encrypted, scopes, auto_register, enabled, login_count).
  6. mod_hk_cx_events: Granular conversion/CTR event stream (entity_type, entity_id, event_type, userid, created_at).

Tokens follow <base64url(json_payload)>.<base64url(hmac_sha256)> where:

  • json_payload = {"inv": <invoice_id>, "uid": <userid>, "exp": <unix_ts>, "n": <64-bit random nonce>}
  • hmac_sha256 = HMAC-SHA256(payload_b64, HKDF_key("hk_cx_magic_hmac_v1", $cc_encryption_hash))
  • Verification performs constant-time hash_equals() signature checking, expiry verification, DB hash lookup, revocation status check, and use_count < max_uses enforcement before hydrating read-only invoice summary data.

3.2 Secret Encryption at Rest & CSRF

  • OAuth2 client_secret_encrypted and stored magic links use AES-256-CBC + HMAC-SHA256 (Encrypt-then-MAC) keyed from WHMCS $cc_encryption_hash.
  • Separate 192-bit random CSRF tokens (hk_cx_admin_csrf, hk_cx_client_csrf) are verified via hash_equals() on all Admin and Client AJAX POST mutations (HTTP 403 on mismatch).

4. WHMCS Hooks (hooks.php)

Hook Priority Behavior
ClientAreaHeadOutput 2 Injects active Theme Preset CSS variables, dark mode rules, border radius, custom CSS & head HTML.
ClientAreaFooterOutput 2 Injects matching notification banners/popups (with track_campaign CTR beacons), OAuth buttons on login.php, and custom footer HTML.
ClientAreaPrimaryNavbar 2 Appends configured custom navbar links (Smart Order, etc.).
ClientAreaHomepagePanels 1 Injects configured homepage promo/quick-action panels onto clientarea.php.
AdminInvoicesControlsOutput 1 Adds Generate Magic Pay Link action button on Admin Invoice detail pages.
AdminHomeWidgets 1 Registers Client Experience, Theme & Smart Order Hub dashboard widget.

5. AJAX & Route Reference

  • Admin AJAX (admin/addonmodules.php?module=haikhavan_client_experience_suite&ajax=1, POST + CSRF): apply_preset, save_theme, save_campaign, toggle_campaign, delete_campaign, save_landing_page, delete_landing_page, generate_magic_link, revoke_magic_link, save_oauth.
  • Client / Public Routes (index.php?m=haikhavan_client_experience_suite):
    • &view=order — One-Step Smart Order storefront
    • &view=page&slug=<slug> — Custom CMS landing page
    • &view=pay&token=<signed_token> — Login-free HMAC payment portal
    • &view=oauth&provider=<google|github|microsoft|discord> — OAuth2 authorization handoff
    • &ajax=1 (POST + CSRF): track_campaign, magic_pay_confirm.