Complete iShoppingBot Installation & Administration Guide
1. Before you start
This is the primary operator manual for version 1.0.0. Prepare an HTTPS domain/subdomain, an empty database, a Telegram Bot Token and the numeric Telegram Admin ID before installation.
db.sql is the complete database baseline. migrations/ is reserved for future updates; a fresh 1.0.0 install does not depend on historical development migrations.2. Server requirements
| Item | Requirement |
|---|---|
| PHP | 8.1+ |
| Database | MySQL/MariaDB with CREATE/ALTER/INDEX privileges |
| Extensions | pdo_mysql, curl, json, openssl, mbstring, fileinfo |
| Web | Valid HTTPS |
| Writable | shop/config and storage |
| Jobs | Cron or systemd/process manager |
| Outbound | Telegram API plus enabled payment/SMS providers |
Correct server time is important for payments, TOTP, queues and expiration.
3. Create the Telegram Bot
- Create a bot with BotFather and copy its token.
- Send
/startto the bot. - Prepare the numeric Telegram user ID of the owner/admin.
- If mandatory channel membership is used, add the bot with required permissions and prepare Channel ID/Link/Name.
4. Database preparation
Create a database and a dedicated database user in cPanel/DirectAdmin, grant the required privileges, and use a clean database for the first installation. On shared hosting, use the full prefixed database/user names.
5. Step-by-step installation
- Extract the ZIP into the domain/subdomain document root.
- Confirm
db.sql,setup/,shop/andstorage/exist. - Open
setup/.install-codein File Manager and copy the install code. - Open
https://bot.example.com/setup/. - Enter install code, store name, database credentials, Bot Token, Admin ID, APP URL and optional channel settings.
- APP URL must be HTTPS and end in
/shop/. - The installer validates requirements/connectivity, installs the database baseline, creates local configuration/secrets and configures the Telegram webhook.
- After success, test the bot, Web Admin and Health Center.
777. Use correct ownership and appropriate file/directory permissions for your host.6. Installer fields
| Field | Purpose |
|---|---|
| Install code | Read from setup/.install-code |
| Store name | Bot/store display name |
| Bot Token | Official BotFather token |
| Admin ID | Numeric Telegram user ID |
| APP URL | HTTPS application URL ending in /shop/ |
| DB Host/Name/User/Password | Database connection |
| Channel ID/Link | Optional mandatory-membership channel |
7. All base configuration keys
The installer creates shop/config/local.php. .env.example documents supported configuration.
| Key | Purpose |
|---|---|
| BOT_TOKEN / BOT_USERNAME / BOT_NAME | Telegram identity and store name |
| ADMIN_IDS | Numeric administrator IDs |
| APP_URL | HTTPS application URL |
| TELEGRAM_WEBHOOK_SECRET | Webhook validation secret |
| DB_HOST / DB_NAME / DB_USER / DB_PASSWORD | Database connection |
| CHANNEL_ID / CHANNEL_LINK / CHANNEL_NAME | Membership channel |
| PAYMENTS_ENABLED | Global online-payment switch |
| ZARINPAL_MERCHANT_ID | Legacy/direct Zarinpal compatibility setting |
| GATEWAY_AMOUNT_MULTIPLIER | Provider amount-unit multiplier; configure carefully |
| PAYMENT_DESCRIPTION | Base transaction description |
| BROADCAST_BATCH_SIZE / PREPARE_BATCH_SIZE / MAX_ATTEMPTS / LEASE_SECONDS / RATE_PER_SECOND / IDLE_SLEEP_MS | Broadcast queue tuning |
| APP_KEY | Encryption key for integration secrets; do not rotate casually after secrets are stored |
| SMS_BATCH_SIZE / SMS_MAX_ATTEMPTS / SMS_LEASE_SECONDS / SMS_IDLE_SLEEP_MS | SMS queue tuning |
| DEFAULT_LANGUAGE | fa or en |
8. Web Admin
Web Admin contains Dashboard, Products, Categories, Orders, Customers, Import/Export, Integrations, Mini App, Growth & Finance, Support, Returns, Health, Logs, Admins & Roles, Audit and Profile. Review Profile/security and enable TOTP 2FA after the first login.
9. Products and variants
Supported commerce flows are Physical, Digital and VPN/Subscription, with optional variants.
- Physical: stock, warehouse and shipping.
- Digital: protected asset/delivery; never expose private files as fixed public URLs.
- VPN/Subscription: plan, provisioning and service inventory.
- Variants: duration, capacity, color, plan, volume, etc.; price and stock may be independent.
10. Languages and translations
UI language, country, market and currency are independent. Users can switch with /language or /lang. Language files live in shop/resources/lang/. Persian and English ship with the product. To add a language, copy an existing file, change its code/meta/direction and translate all keys. Product, category and variant translations are stored separately.
11. Market, Country, Currency and pricing
A user may use Persian UI while having Country=CA and Currency=CAD. An explicit saved country wins over IP/edge hints. Market prices may vary by Country, Currency, Variant and quantity. Decimal currencies use minor units: CAD 14.99 is stored as 1499. Order/item language, market, country and currency are snapshotted so later configuration changes do not rewrite historical orders.
12. Tax and FX
Configure Tax Rules and FX Rates in the payment/integrations area. Tax rules may match Market, Country, Currency and Product Type. Tax rates use basis points (1300 = 13%) and may be inclusive or exclusive. FX stores base/quote currency, rate, markup and expiry. Do not use stale rates for checkout.
13. Payment gateways
Providers use either Direct API or Secure Bridge. Configure and enable an integration, then define Gateway Routing.
Direct API
| Provider | Main fields |
|---|---|
| Zarinpal | merchant_id, sandbox, amount_multiplier |
| Zibal | merchant, amount_multiplier |
| IDPay | api_key, sandbox, amount_multiplier |
| NextPay | api_key, amount_multiplier |
| Vandar | api_key, amount_multiplier |
| AqayePardakht | pin, sandbox, amount_multiplier |
| Pay.ir | api_key, amount_multiplier |
| Sepal | api_key, amount_multiplier |
| IranDargah | api_token, amount_multiplier |
Secure Bridge / PSP
Catalog entries include Stripe, PayPal, custom international, PayPing, Jibit, BitPay, RayanPay, Toman, Custom PayFac, Mellat, Saman, Parsian, Pasargad, Sadad, IranKish, AsanPardakht, Sepehr, Fanava Card, Mabna Card, Payment Novin, Sayan Card and Custom PSP. Bridge providers require bridge_url and bridge_secret, with optional merchant/terminal IDs. A catalog entry is not a payment account; real credentials/endpoints are still required.
Gateway Routing can match Market, Country, Currency, Product Type and amount range. Payment callbacks are idempotent to suppress duplicate processing.
14. SMS and notifications
SMS providers: Kavenegar, SMS.ir, IPPanel, FarazSMS, Ghasedak, MeliPayamak, MAGFA Bridge and Custom HTTP Bridge. Save and enable the integration, send a test where supported, and make sure the SMS worker is running for queued messages.
15. Cart, checkout and order lifecycle
Checkout combines market price, variant, discounts, shipping, tax, wallet and eligible gateways. Use official order workflows for state changes. Paid state may trigger inventory, rewards, affiliate commission, invoice, digital/VPN delivery and notifications.
16. Multi-currency wallet
Legacy IRT credit remains for compatibility. Other currencies use separate accounts/ledgers with idempotent credit/debit operations. Balances are never silently converted between currencies.
17. Coupons and discounts
Discount rules support scoped redemption. Validate currency/market for fixed-amount discounts, plus limits, dates and product/category scope. Reservations should be released on cancelled/expired checkout flows.
18. Referral, Reward and Affiliate
Referral handles invitations/rewards; Affiliate handles sales commissions. Reward Engine can issue points, wallet credit or coupons with event-key idempotency. Affiliate supports accounts, referrals, commissions, approval delay, payout requests, settlement/rejection and reversal. Runtime settings include affiliate_enabled, default commission, approval days, minimum payout and payout mode.
19. Inventory and shipping
Inventory supports warehouses, stock, reservations, movements, transfers, adjustments, low-stock and dormant-product views. Multi-warehouse is controlled by inventory_multiwarehouse_enabled. Configure shipping zones/methods/slots for physical products and test last-unit concurrency in staging.
20. Subscriptions and VPN
Subscriptions support order sync, renewal orders, early renewal, lifecycle notifications and expiry. Relevant settings include subscription_enabled and subscription_early_renewal_days. VPN uses plans, accounts and provisioning jobs. External provisioning should be retryable and observable.
21. Digital delivery
Digital assets and deliveries are stored separately. Secure download tokens are used for access. Do not deliver private assets with permanent public URLs. Test paid delivery and token expiry.
22. Invoices
Enable invoices with invoice_enabled. Settings include prefix, seller name/address/phone/tax ID and fallback tax percentage. Invoice records should use order snapshots rather than current product prices.
23. Support and returns
Support provides tickets, messages and media messages. Returns have their own request/status flow. Before financial refund, inspect return state, fulfillment and provider status. Refund Ledger records refund lifecycle; actual online refund requires provider/bridge API support.
24. Mini App
- Enable Mini App in Web Admin.
- Use HTTPS.
- Configure Main Mini App in BotFather.
- Configure slides/featured/settings.
- Test Home, Categories, Product, Cart, Checkout, Orders and Deliveries on a real phone.
- Verify Language/Market/Currency matches the Telegram bot.
25. Webhook and user commands
Main user commands include /start, /language//lang and /market. Some flows also use /cancel//skip. Health Center exposes Telegram API, webhook, pending updates and recent errors. Do not use getUpdates concurrently with an active webhook.
26. Cron and workers
* * * * * /usr/local/bin/php /home/USERNAME/public_html/shop/cli/commerce_worker.php --once --max-jobs=30 >/dev/null 2>&1 * * * * * cd /home/USERNAME/public_html && /usr/local/bin/php shop/cli/sms_worker.php --once >/dev/null 2>&1 * * * * * /usr/bin/flock -n /tmp/ishoppingbot-broadcast.lock /usr/bin/php /home/USERNAME/public_html/shop/cli/broadcast_worker.php --max-runtime=50 >/dev/null 2>&1 17 3 * * * /usr/local/bin/php /home/USERNAME/public_html/shop/cron/stability_cleanup.php >/dev/null 2>&1
Replace paths for your server. Example systemd services for broadcast and SMS are included in deploy/. Verify fresh queue/worker heartbeats after enabling jobs.
27. Admins, roles and permissions
Use separate admin accounts and least privilege. Permissions cover dashboard, product view/edit/import/export, categories, order view/edit, customers, integrations, Mini App, health view/manage, support, returns, audit, finance, inventory, subscriptions, discounts, affiliate and growth. Enable TOTP 2FA in Profile. Login is rate-limited.
28. Health, logs and audit
Use Health Center for PHP/database/Telegram/webhook/queue operational checks, Logs for technical failures and Audit for sensitive admin changes. Run Health before and after updates.
29. Backup and restore
Back up before updates, large imports, gateway changes or database work. Keep off-server copies. Validate disaster recovery by restoring into staging, running Health, testing bot/webhook/admin/orders/integrations and completing a test order. A restore operation should create a safety backup first.
30. Update Manager
1.0.0 is the baseline. Future database changes should arrive as official update migrations. Update Manager validates release metadata/compatibility/checksums and coordinates backup, install and rollback. After updating, verify migrations, Health, webhook, workers and checkout.
31. Import / Export
Use admin Import/Export for bulk catalog operations. Use UTF-8, back up first, test a small sample in staging, and carefully map product/variant IDs, SKU, currency and prices.
32. File layout
| Path | Purpose |
|---|---|
db.sql | Complete 1.0.0 database baseline |
setup/ | Web installer |
shop/ | Bot/Admin/Mini App/API/payment/workers |
shop/config/ | Application configuration |
shop/resources/lang/ | Language catalogs |
storage/ | Writable runtime/backup data; protect from direct access |
deploy/ | Cron/systemd examples |
migrations/ | Reserved for future official migrations |
release.json | Release metadata/minimum PHP |
SHA256SUMS | Release file checksums |
33. Production security
- HTTPS everywhere.
- Keep APP_KEY and secrets private.
- Enable admin 2FA.
- Use strong unique passwords.
- Avoid permanent 777.
- Do not expose PHP errors publicly.
- Keep off-server backups.
- Use webhook and bridge secrets.
- Apply least privilege to admin/database accounts.
- Keep PHP/MySQL/SSL current.
34. Complete go-live checklist
- Fresh install succeeds on target server.
- Health has no critical error.
- /start, language and market work.
- Webhook is healthy.
- Admin login, roles and 2FA tested.
- Workers have fresh heartbeats.
- Products/variants correct.
- Physical inventory/shipping tested if used.
- Digital delivery tested if used.
- VPN/subscription tested if used.
- Market/country/currency/price correct.
- Tax/FX tested if enabled.
- Gateway routing exposes only eligible providers.
- One sandbox/small live payment completed end-to-end.
- Duplicate callback does not double-pay.
- Coupon/reward/referral/affiliate tested if used.
- SMS/notifications tested.
- Invoice tested if enabled.
- Cancel/expire releases reservations.
- Return/refund flow tested if used.
- Backup and restore tested in staging.
35. Troubleshooting
| Problem | Check |
|---|---|
| Bot silent | Token, HTTPS, webhook URL/secret, Telegram connectivity, last error, logs |
| Webhook conflict | Do not run getUpdates with webhook; re-register webhook and inspect pending updates |
| HTTP 500 | PHP/extensions, local config, DB credentials, permissions and logs |
| Admin login fails | Password, rate limit, session/cookie, HTTPS, TOTP and server time |
| Wrong price | Market, country, currency, variant, market price and FX; language is not pricing |
| Gateway missing | Integration enabled/default, routing, country/currency/product type/amount |
| Charged but not Paid | Callback, authority/reference, provider verify, APP URL, payment event and logs |
| SMS not sent | Credentials, test mobile, SMS worker, queue, logs |
| Digital not delivered | Paid state, asset, token, file permission, worker |
| VPN not provisioned | Plan, job, bridge/API, queue, retry/error |
| Queue stalled | Cron, PHP CLI path, lock, permissions, heartbeat |
| TOTP fails | Sync server and phone clocks; verify correct secret |
| Update rejected | Manifest, min PHP, required version, checksum, write access, disk space |
| Restore fails | DB privileges, disk, backup compatibility and logs |
36. Maintenance
Daily: Health, queues, payment failures, stuck orders.
Weekly: off-server backup, low stock, audit, worker errors, disk space.
Before every release: staging update, backup/restore, checkout, webhook, workers, fulfillment and payment-callback tests.
37. Product and commerce field reference
| Group | Available fields |
|---|---|
| Identity | Name, Slug, SKU, Category, Status, Featured, Sort Order |
| Content | Title/Description/Short Description, SEO Title, SEO Description, Post-purchase Message, Language |
| Pricing | Price, Sale Price, Sale Start/End, Score, Market Price, Currency, Min Qty |
| Inventory | Stock, Stock Mode/Value, Low Stock Threshold, Allow Preorder, Warehouse |
| Physical | Requires Shipping, Weight Grams, Shipping configuration |
| Digital | Digital File/Asset, Max Downloads, Download Expires Hours |
| VPN | Protocol, Duration Days, Traffic GB, Device Limit, Provisioning Mode |
| Subscription | Enabled, Default Months, Grace Days, Renewal Price 1m/3m/12m, Early Discount |
| Variant | Name, SKU, Attributes, Price, Stock, Status |
| Images | Image/Image URL, Alt Text, Product Images |
38. Runtime and Growth/Finance settings reference
| Setting | Purpose |
|---|---|
| affiliate_enabled | Enable affiliate system |
| affiliate_default_commission_percent | Default commission |
| affiliate_approval_days | Commission approval delay |
| affiliate_minimum_payout | Minimum payout |
| affiliate_payout_mode | Payout mode |
| discount_engine_enabled | Discount engine |
| inventory_multiwarehouse_enabled | Multi-warehouse inventory |
| subscription_enabled | Subscriptions |
| subscription_early_renewal_days | Early renewal window |
| invoice_enabled | Invoices |
| invoice_prefix | Invoice number prefix |
| invoice_seller_name/address/phone/tax_id | Seller identity on invoice |
| invoice_tax_percent | Legacy tax fallback; market Tax Engine rules take precedence when used |
| miniapp_enabled | Mini App |
39. Mini App content settings
Mini App administration includes Enabled, Menu Button, Menu Text, featured products/order and slides. A slide may contain Title, Subtitle, Button Text, Link Type/Value, Image and Sort Order. Run sync after changes and verify the result inside the real Telegram client.
40. Secure Bridge setup
- Deploy the bridge on a separate HTTPS endpoint.
- Generate a strong random secret.
- Store
bridge_urlandbridge_secretin the integration. - Add Merchant/Terminal ID where required.
- Test request, callback and verify in sandbox.
- Configure provider IP allowlists and SSL requirements.
41. VPS installation with systemd
- Install PHP CLI/MySQL and configure an HTTPS web server.
- Deploy to a path such as
/var/www/ishoppingbotwith correct service ownership. - Run the web installer.
- Copy the example
deploy/ishoppingbot-*-worker.service.exampleunits and adjust paths/user. - Run systemctl daemon-reload, enable and start the services.
- Verify with systemctl status and Health Center.