AlixFast PerfectPanel module v2 — ORIGINAL, bug-fixed (Oct 2026)
===============================================================
Built from the live Gill SMM Panel install, with every bug found there
fixed in this zip. Panel base currency stays USD; AlixFast payments are
PAID in PKR and CONVERTED to USD on credit (like Ali SMM Panel).

WHAT IS INSIDE
--------------
alixfast-pay/
  config.php        — keys, DB, table mapping, log path (EDIT THIS ONLY)
  alixfast_lib.php  — API, verified/failed statuses, amount+order-ref
                      guards, PKR->USD conversion, idempotent credit,
                      logging, return recheck helper
  pay.php           — start payment, live min/max from paymentmethods
  return.php        — NO output before decision; rechecks AlixFast and
                      redirects to Add Funds on verified credit
  callback.php      — webhook only; signature-checked, logged, guarded
panel-integration/
  sql/install.sql               — paymentmethods row (id 110, position 1)
  addfunds-Initiator-alixfast.php — panel Initiator (pending row -> pay.php)
  patches.txt                   — dispatch, getForm, methods-list,
                                  quick card, history, admin-settings patches
assets/
  alixfast-logo.png — ORIGINAL AlixFast website logo (861x300)

INSTALL (in order)
------------------
1. Upload alixfast-pay/ to public_html/alixfast-pay/
   Upload assets/alixfast-logo.png to public_html/assets/alixfast-logo.png
2. Edit alixfast-pay/config.php: real public/secret keys (AlixFast merchant
   panel -> Integration), panel DB details, users table mapping.
   Set AFX_LOG_FILE to a path OUTSIDE public_html.
3. Run panel-integration/sql/install.sql in phpMyAdmin (panel DB).
   If methodId 110 is taken, change it in SQL AND in the Initiator file.
4. Copy panel-integration/addfunds-Initiator-alixfast.php to
   public_html/app/controller/addfunds/Initiators/alixfast.php
5. Apply panel-integration/patches.txt (dispatch, getForm, methods list,
   quick card, history-only-successful, admin settings).
6. AlixFast merchant panel -> Integration -> Webhook URL:
     https://YOURPANEL.com/alixfast-pay/callback.php
   (The create-payment call sends NO webhook URL — it must be set in the
   merchant panel, or webhooks will never arrive.)
7. Test with a SMALL real payment (e.g. PKR 10):
   - Checkout shows Total in PKR, gateway confirms.
   - Return redirects to Add Funds with "Paid PKR X -> credited $Y".
   - User history shows ONE Successful Credit row (PKR amount, method,
     Transaction ID). Pending rows never show to users (Admin only).
   - Balance increases by the CONVERTED USD amount only, once.
   - Repeat the return URL: balance must NOT increase again.

BUGS FIXED vs v1 (Gill, Oct 2026)
---------------------------------
- v1 return.php printed a heading before deciding, so it could never
  redirect and a missed webhook stranded payments as "pending" forever.
  v2 return.php rechecks AlixFast and redirects on verified credit.
- v1 accepted only status "verified". v2 also accepts "complete".
- v1 had no callback log, no amount guard, no order-ref guard.
  v2 logs every outcome and refuses mismatched credits.
- v1 credited the PKR amount directly into a USD balance ($10 for PKR 10).
  v2 converts at the panel currencies-table rate (PKR 10 = $0.0361 at
  277.07944836 PKR/USD) and credits only the converted amount.
- v1 form min/max were hardcoded, so Admin changes never showed.
  v2 reads min/max LIVE from paymentmethods on every load.
- v1 history showed Pending rows in USD with no status.
  v2 user history shows ONLY Successful Credit rows, in PKR, with
  Transaction ID; Pending/Failed stay Admin-only.
- v1 placeholder-key fallback could trigger even with real keys saved.
  v2: Admin-saved keys (methodExtras) must be read FIRST in config.php,
  falling back to constants only when Admin has none (see patches.txt 5).

TROUBLESHOOTING
---------------
- callback.php in browser must return "bad signature" (file is live).
- Balance not credited: check AFX_LOG_FILE (outside public_html) and
  confirm the webhook URL is set in the AlixFast merchant panel.
- Theme editor "Forbidden" on Save: edit theme files via Hostinger
  File Manager directly (known Gill issue, Oct 2026).
- Google login /auth/google 500 and New Order category-select escaping
  are SEPARATE panel issues, not part of this module.

NO REAL KEYS ARE SHIPPED IN THIS ZIP. Never share config.php with keys.
