Hotspot bKash Auto Connect - Step by Step Setup
================================================

1) Hosting upload
-----------------
- hotspot_gateway folder upload korun hosting public_html er moddhe.
  Example: public_html/hotspot_gateway
- Browser URL hobe:
  https://hotspot.wifiapp.net/hotspot_gateway/index.php
  https://hotspot.wifiapp.net/hotspot_gateway/pay.php

2) Database setup
-----------------
Option A: phpMyAdmin diye SQL import
- phpMyAdmin > Database select korun.
- ssteleco_hpay.sql import korun.

Option B: install.php diye only payment table create
- https://hotspot.wifiapp.net/hotspot_gateway/install.php open korun.
- Install OK show hole install.php delete/rename korun.

Important:
- ZIP er moddhe install.sql add kora ache, tai install.php ekhon missing file error debe na.

3) config.php edit
------------------
config.php file e nicher value gulo update korun:

APP_URL = apnar exact gateway URL, ending slash chara.
Example: https://hotspot.wifiapp.net/hotspot_gateway

DB_HOST, DB_NAME, DB_USER, DB_PASS = hosting MySQL info.

MT_HOST = MikroTik public/VPN/NAT host.
MT_PORT = API port, default 8728.
MT_USER, MT_PASS = MikroTik API user/pass.

BKASH_SANDBOX = false for live, true for sandbox.
BKASH_APP_KEY, BKASH_APP_SECRET, BKASH_USERNAME, BKASH_PASSWORD = bKash merchant credentials.

Package profile must match MikroTik Hotspot User Profile exact name:
1day, 3day, 7day, 15day, 30day

4) MikroTik setup
-----------------
- MikroTik > IP > Services > api enable korun.
- API port hosting/server theke reachable hote hobe.
- Firewall/NAT e API port allow korte hobe, but only trusted hosting IP allow kora better.
- Hotspot User Profiles create/check korun:
  1day, 3day, 7day, 15day, 30day
- Duplicate profile name rakha jabe na.

5) Walled Garden setup
----------------------
MikroTik terminal e mikrotik_walled_garden_bkash.rsc er command run korun.
Need allow:
- apnar gateway domain
- bKash tokenized payment domain
- required CDN/static domain, jodi bKash page load na hoy.

6) MikroTik hotspot page upload
-------------------------------
- mikrotik_upload folder er files MikroTik Hotspot files e upload korun.
- login.html e bKash button ache.
- bkash.html file e gateway URL check/update korun:
  var gateway = 'https://hotspot.wifiapp.net/hotspot_gateway/pay.php';

7) Payment flow test
--------------------
- Hotspot client device diye login page open korun.
- bKash Pay click korun.
- Package select kore Pay with bKash click korun.
- Payment success hole bKash trxID diye MikroTik hotspot user create/update hobe.
- Username = bKash trxID
- Password = bKash trxID
- Comment = expiry datetime only, example: 2026-06-01 12:31:57

8) Common problem and solution
------------------------------
A) Payment page slow/open hote deri
- pay.php first DB insert kore.
- Tarpor bKash grant token API call kore.
- Tarpor bKash create payment API call kore.
- Ei 2 ta external bKash API call slow hole page open deri hoy.
- Hosting server DNS/SSL/cURL latency slow hole aro deri hobe.
- Hotspot captive browser + walled garden incomplete hole bKash page load delay/fail korte pare.

B) Open this page from MikroTik hotspot error
- Local PC/browser theke pay.php open korle login_url real thake na.
- Hotspot login page/bkash.html theke open korte hobe.

C) MikroTik API connect failed
- MT_HOST/MT_PORT/MT_USER/MT_PASS check korun.
- MikroTik API service enabled kina check korun.
- Firewall/NAT port reachable kina check korun.

D) MikroTik profile not found
- config.php package profile and MikroTik Hotspot Profile exact same korte hobe.
- Example: config profile '1day' hole MikroTik profile name exactly 1day hobe.

E) Payment success but auto-login failed
- login_url missing/wrong.
- Device hotspot network er moddhe thakte hobe.
- Captive portal browser problem hole normal Chrome/Browser e retry korun.

9) Security checklist
---------------------
- config.php public access block thakte hobe (.htaccess already added).
- install.php install er pore delete/rename korun.
- error_log public folder e rakha thik na; delete korun.
- DB/bKash/MikroTik credentials public/share korben na.
- MikroTik API port public open na rekhe only hosting IP allow korun.
- HTTPS/SSL active rakhun.

10) Quick verification
----------------------
- PHP version 8.x OK.
- PHP cURL enabled.
- MySQL connection OK.
- bKash credentials live/sandbox mode matched.
- MikroTik time zone Bangladesh/real time synced.
- Hotspot user profile exact match.
