WhatsApp Bot V19 - Credit Bill -> Amount -> NayaPay -> Screenshot -> Verified Ledger Settlement
==============================================================================================
BASED ON: V17 full bot + V18 NayaPay pending/CHECK fix; V19 modifies webhook/message_handler.php and nayapay_topup.php only.

CUSTOMER FLOW:
1. Approved credit customer sends BILL (or DUE/BALANCE).
2. Bot reads only THAT customer's current_due from their authorized WhatsApp number and displays their bill.
3. The bill says: "Ap jitni payment krna Chahty hain utni likh kr bta dy.." Example 800.
4. Customer sends a number such as 800, which must be >0 and <= their outstanding bill.
5. Bot then shows NayaPay account title/number from the ACTIVE NayaPay entry in Admin > Payment Methods and requests a screenshot.
6. Customer sends an original payment screenshot to that same WhatsApp bot chat.
7. Existing OCR and independent authenticated NayaPay Gmail receipt checks must verify sender name and exact selected amount; Gmail receipt and transaction cannot be used twice.
8. ONLY after successful verification, an atomic DB transaction inserts a payment, inserts a customer_ledger credit entry, updates customers.current_due and total_payments, marks NayaPay record paid. Wallet balance is NEVER changed for credit payments.
9. Example: Current bill Rs 1200; selected/verified payment Rs 800; new bill Rs 400. Payment amount can be partial.

IMPORTANT:
- Screenshot by itself does NOT settle a bill; original authenticated NayaPay receipt verification is required.
- Pending/unclear/rejected screenshot: no due reduction. Customer may send CHECK PAYMENT or CHECK; background cron can retry receipt checks.
- If screenshot has already been submitted and is pending verification, sending BILL does NOT overwrite proof or ask for duplicate payment.
- Wallet TOPUP continues to work separately.
- Existing NayaPay Gmail OAuth connection, Tesseract OCR installation, and periodic cron/nayapay_verify.php are still required.
- If Tesseract is not installed or Gmail is not connected, auto-payment clearing will NOT function. Review payments manually, carefully.
- Do not submit a duplicate payment simply because a receipt is delayed. Consult admin.
- Existing customer ledger records are NOT deleted or altered by the code update.

INSTALL:
1. BACK UP entire bot directory and MySQL database FIRST.
2. If running V18 already: upload V19_CHANGED_FILES.zip content and replace matching files in cPanel. The V18 adminpanel/nayapay_topups.php is included for installations still on V17.
3. Alternatively upload V19_FULL_BOT.zip contents for a full-site replacement, preserving all production config/database credentials/Google OAuth tokens; be careful with old config/logs.
4. No SQL migration required if the V17 database credit payment schema is already installed. If not, run V17_CREDIT_PAYMENTS_UPGRADE.sql from V17 FULL first.
5. In admin panel, check NayaPay status ACTIVE and the account title/number correct.
6. Verify that Google Gmail OAuth token is valid, and that NayaPay receipts are received in the configured target mailbox.
7. Verify Tesseract OCR and the recurring NayaPay verification cron on your hosting.
8. Test BILL -> 800 -> NayaPay details -> screenshot -> CHECK PAYMENT with an actual small payment. Confirm only one payment / ledger credit and new remaining due. Repeat CHECK and confirm no double credit.

FILES IN THIS PATCH:
- bot.shoaibsubscription.pk/webhook/message_handler.php (V19)
- bot.shoaibsubscription.pk/nayapay_topup.php (V19)
- bot.shoaibsubscription.pk/adminpanel/nayapay_topups.php (V18 diagnostics carried forward)

TESTING: PHP syntax checked; mock PDO flow tests performed. No live NayaPay/Gmail or MySQL end-to-end test performed here.
SECURITY: The FULL ZIP contains private production configuration and token files from the user-provided ZIP. Never publish or share it.
