Bill SMS in credits and add IRT top-up in Super Admin.

Show credit balance in business settings; Super Admin tops up by IRT (adds credits) and tracks SMS sent per business.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Alireza Hassani
2026-09-09 11:10:22 +03:30
co-authored by Cursor
parent a8676854fb
commit 6bc57f26ed
8 changed files with 139 additions and 34 deletions
+6 -4
View File
@@ -319,11 +319,13 @@ Products accept optional `brandId` on create/update.
- `POST /businesses/:businessId/customers/sms` — bulk SMS via Gama **SendBulk** (or per-recipient when template/vars); body `{ message, userIds?, templateId? }` — empty/omitted `userIds` → all enabled customers
- Free-text SMS source: `settings.sms.senderNumber` (Super Admin only) or advertising shortcode `5000990009`
- Verified SMS template → service shortcode `5000110005` (fixed); unverified template → `5000990009`
- Per-business prepaid `businesses.sms_balance` (IRT) — all Meshkee SMS (OTP login/forgot-password, customer SMS, partner/public SMS for linked domains) costs **400 IRT per 64 characters** per recipient (`ceil(len/64)*400`). Insufficient balance blocks send.
- New businesses created in Super Admin start with **500,000 IRT** SMS balance
- Per-business prepaid `businesses.sms_balance` (**SMS credits**) — all Meshkee SMS (OTP login/forgot-password, customer SMS, partner/public SMS for linked domains) costs **1 credit per 64 characters** per recipient (`ceil(len/64)`). Insufficient balance blocks send.
- Top-up (Super Admin): enter IRT amount → adds `floor(IRT / 500)` credits (e.g. 1,000,000 IRT → 2,000 credits)
- New businesses created in Super Admin start with **1,000** SMS credits
- `businesses.sms_sent_count` — lifetime messages billed (one per recipient)
- External domains (no Meshkee website) still bill via their business row once the domain is linked
- Business Settings → **SMS settings**: balance (read-only) + template CRUD
- Super Admin business overflow → **SMS settings** modal: sender number + SMS balance top-up
- Business Settings → **SMS settings**: credit balance (read-only) + template CRUD
- Super Admin business overflow → **SMS settings** modal: sender number + current credits + IRT top-up
- Super Admin → **SMS Templates** (`/sms-templates`): verify / unverify
- Online payment gateways live under **Website → Settings** (not main Settings)
- Template vars: `{{user.name}}`, `{{user.lastname}}`, `{{user.title}}`