# Airtime setup

Back up the hosted airtime script, then upload these files beside conn.php:

- new_buy-airtime.php
- airtime_cashback.php
- airtime_wallet.php
- detect_network.php (the existing file from your supplied ZIP, if not already hosted)

Keep the already deployed verify_transaction_pin.php and payment_pin_guard.php.
Token purchases require the `pin` field. Existing mobile clients using this
purchase endpoint must send it too. No database credentials were changed.

airtime_cashback.php reads the latest cashback.airtime_cashback percentage
and sitesettings.airtimemin/airtimemax. Cards and custom amounts use that rate.
The purchase endpoint independently loads and applies the server's current rate.
Amounts use whole naira because the existing provider payload casts to integer.

The app uses existing detect_network.php with POST phone. This is a prefix
suggestion, not a live ported-network lookup. Unknown/error responses leave
manual selection available. Manual selection supersedes delayed detection.
9MOBILE displays as T2; the PHP network ID stays 3 (MTN=1, GLO=2, AIRTEL=4).

Put network icons beside the welcome images:
assets/images/mtn.png, airtel.png, glo.png, t2.png.
Paths can be changed in AppConfig.networkIcons. A SIM icon is shown until
the assets are added. No unprovided network artwork was generated.

Purchase accounting: InnoDB is required. airtime_wallet.php reserves wallet
funds and records status=2 before contacting the provider. On explicit success,
it marks status=0 and credits sRefWallet cashback once. Explicit provider failure
refunds and marks status=1. Unknown replies/timeouts retain status=2 and the
reservation; never re-submit that purchase blindly. Provider success followed
by a database error also remains pending for reconciliation.

Pending outcomes require reconciliation with the provider/server transaction
history; this change does not add a polling endpoint or webhook integration.
The existing UI receipt is a snapshot. No live debit or deployment was run.
PHP runtime/database execution was not available locally; validate the PHP
deployment on your test server before relying on the new settlement flow.

The original provider routing, airtime prices/profit calculation and site
limits are retained. The main-wallet debit now occurs before provider delivery,
preventing a delivered purchase from escaping payment after a concurrent spend.
