<aside> 🔁 Synced from GitHub #7cdcc4e59c03. Edit in the paidhr-system-docs repository, not here: changes made in Notion are overwritten.
</aside>
Status: Built Implemented on development branches with an offline test suite; needs deployed end-to-end validation before staging and production.
💡 In plain words
Not everyone has a smartphone or data, so PaidHR also works over USSD codes, WhatsApp and Telegram.
Employees can check their earnings, take early pay (EWA) and pay bills by dialling a short code or chatting. This is just another way in: the same rules and limits apply as in the app.
A phone-banking menu, but for your PaidHR pay.
Who's involved: employees (dial or chat), and PaidHR (checks who they are and applies the usual rules).
Many employees have no smartphone or data, so PaidHR offers earned wage access and bill payments over USSD (Africa's Talking, for example *384*1234#), WhatsApp and Telegram. A separate bot (paid-ussd-whatsapp-bot, Python) handles the provider webhooks and menus. It owns no money logic: identity comes from core-backend, EWA rules and withdrawals from ewa-service, and bills from wallet-service through ewa-service. The bot and ewa-service trust each other through HMAC-signed session exchanges; after that, every call carries a short-lived channel session token.
flowchart LR
PH[Employee's phone] -->|USSD session| AT[Africa's Talking]
PH -->|chat| WA[WhatsApp / Telegram]
AT --> BOT[paid-ussd-whatsapp-bot]
WA --> BOT
BOT -->|"Channel OTP, Bot/Authenticate<br/>(chat linking)"| CORE[core-backend]
BOT -->|"signed session, then<br/>X-Channel-Session-Token"| EWA[ewa-service<br/>ussd-channel / bot-channel]
EWA -->|payroll eligibility,<br/>signed| CORE
EWA -->|bills, wallet balance| WAL[wallet-service<br/>ussd-channel/*]
| Native USSD | Chat bot (WhatsApp, Telegram) | |
|---|---|---|
| Session request | POST /v1/ussd-channel/sessions with phone number, provider session id, service code |
POST /v1/bot-channel/sessions with padeUserId, chat id, platform |
| Signature | HMAC-SHA256 over USSD, phone, session id, service code, timestamp, nonce, using USSD_CHANNEL_SECRET |
HMAC-SHA256 over BOT, padeUserId, chat id, platform, timestamp, nonce, using BOT_CHANNEL_SECRET |
| Who is the user | Looked up by phone number in EWA | The chat was linked to the employee when they signed in through core-backend; the signature asserts that link is live |
| Login token | None: the bot never holds a core-backend employee token for USSD | Bot session in core-backend (Bot/* endpoints, UserBotSession) |
The leading USSD / BOT in the signed string stops a signature for one channel being replayed on the other. Timestamps and nonces stop replays within a channel.
| Action | USSD endpoint (ewa-service) |
|---|---|
| See EWA balance, status and allowed destinations | GET /v1/ussd-channel/wallet |
| Pick a withdrawal reason | GET /v1/ussd-channel/withdrawal-reasons |
| See the fee before withdrawing | GET /v1/ussd-channel/fees/calculate?amount= |
| Withdraw (PIN required, idempotent) | POST /v1/ussd-channel/withdraw; check later with GET /withdrawals/:idempotencyKey |
| Buy airtime, data, electricity, cable | bill-payments/context, /options, /resolve, /purchase, /status/:key |
| Change PIN (three attempts per session) | pin-change/authorize, pin-change, pin-change/status/:key |
USSD sessions drop easily, so every money action takes an idempotency key and has a status endpoint to find out what happened.
ussdWithdrawalDestinationPolicy (BANK, WALLET or BOTH), set by a PaidHR admin through PUT /v1/misc/settings. Without a policy, employees with bank details get both; others get wallet only.For the PaidLife "Inner Circle" event game (run from the control panel), both channels can earn a guest a key. Any message from a WhatsApp or Telegram chat that is linked to a PaidHR account earns key 5 (reported by the bot, develop). Dialling the USSD code, when the phone number matches exactly one active employee, earns key 6 (reported by ewa-service when the USSD session starts, staging). Both are off unless INNER_CIRCLE_AWARD_URL and INNER_CIRCLE_AWARD_SECRET are set on the service, and a report never slows down or breaks the chat reply or USSD menu.