How to Automate bKash & Nagad Payment Verification for SaaS Platforms
- SMS Webhook Gateway: Converts mobile bank SMS notifications into real-time HTTPS webhooks for instant matching. See all platform features →
- Regex TrxID Parsing: Extracts 10-character alphanumeric transaction IDs (e.g. 9A2B3C4D5E) automatically.
- Instant Credit Grant: Grants SaaS account credits in under 2 seconds upon payment matching without human intervention. View credit plans →
If you've ever had to manually check a bKash or Nagad transaction before unlocking a user's subscription, you know exactly how painful that process gets at scale. One person sends money, messages you on WhatsApp, and then waits while you cross-check their Transaction ID, update a spreadsheet, and manually add credits. Multiply that by 50 users a day and you have a serious operational bottleneck.
This guide explains the architecture VelorOps built to solve this problem completely — from the moment a user sends a payment to the moment their account credits appear, with zero human involvement.
1. Why Manual Payment Verification Breaks SaaS Operations
Bangladesh's mobile financial ecosystem is unique. bKash and Nagad together process over 90% of digital payments in the country, but neither offers a direct developer API that's practical for SaaS billing. What they do provide — the SMS confirmation that lands on the merchant's phone after every transaction — turns out to be the perfect data source, if you know how to read it.
The information in that SMS is everything you need: the Transaction ID, the amount, the sender number, and a timestamp. The challenge is getting it out of a phone and into your backend automatically. That's where the SMS Webhook Gateway pattern comes in.

2. The Architecture: How It Works End to End
Here's the complete flow from payment to credit, broken into steps that you can understand — and potentially replicate — regardless of your stack:
Step 1: User submits their Transaction ID
After sending payment via bKash or Nagad, the user opens the VelorOps billing portal and enters their Transaction ID — typically a 10-character alphanumeric string like 9A2B3C4D5E. The system creates a pending payment record in the database, tied to their account and the expected package amount.
Step 2: The merchant phone forwards the SMS
The merchant's SIM (which receives bKash/Nagad confirmation messages) runs an SMS forwarder app that sends incoming payment SMS to a secure backend endpoint: /api/webhooks/sms. This happens within seconds of the payment being processed.
Step 3: Regex parsing extracts the transaction data
The backend immediately parses the SMS body to extract the Transaction ID and paid amount using strict regular expressions:
const trxMatch = smsBody.match(/TrxID\s+([A-Z0-9]+)/i); const amountMatch = smsBody.match(/Tk\s+([0-9,.]+)/i);
If either pattern fails to match — for example, if the SMS format changed or the forwarder sent something unexpected — the system logs an error and stops processing. It never guesses.
Step 4: Database matching and atomic credit grant
The parsed Transaction ID gets matched against pending payment records. If there's a match, and the paid amount equals or exceeds the expected plan price, a database transaction atomically marks the payment as COMPLETED and adds the corresponding credits to the user's account. The entire operation takes under 2 seconds from SMS receipt to credit grant.
3. Security: Where Most Implementations Get It Wrong
Payment systems attract fraud attempts. The SMS webhook pattern is sound, but it only stays secure if you implement these three protections correctly:
- Webhook secret validation: Every request to
/api/webhooks/smsmust include a pre-shared secret in the headers. Requests without it are rejected immediately. This prevents anyone who knows your endpoint URL from submitting fake payment notifications. - Replay attack prevention: Each Transaction ID can only be applied once. The database enforces a unique index constraint on TrxIDs, so even if the same webhook fires twice (which can happen with SMS forwarder apps), the second attempt hits a conflict error and is safely ignored.
- Amount validation: Credits are only granted if the paid amount exactly matches or exceeds the plan price. Partial payments don't get partial credits — they get logged for manual review. This closes the gap where someone might send ৳1 and hope to receive a full subscription.
4. What You Need to Set This Up
If you're building something similar for your own SaaS, here's the practical checklist. See VelorOps platform features for how this integrates with the full publishing and billing workflow.
A dedicated merchant SIM: You need a separate SIM that receives bKash/Nagad merchant confirmations. Don't share it with a personal account — you want clean, parseable SMS from payment notifications only.
An SMS forwarder app: Several Android apps can forward incoming SMS to a webhook URL. Test it thoroughly — some apps batch forward, which can cause delays. Real-time forwarding is what you want.
A robust regex library and test suite: bKash and Nagad occasionally change their SMS format slightly. Your regex needs to be tested against real SMS examples, and you should alert yourself when an incoming SMS doesn't match any known pattern.
Database-level constraints, not just application-level checks: Unique constraints on TrxID and status transitions need to be enforced at the database level. Application-level checks can fail under concurrent load. Check out VelorOps credit plans to see how we handle credit allocation.
5. The Result
When this system is working properly, the user experience is almost magical from the customer's side: they send money, go back to the app, and their credits are already there. No waiting, no messaging support, no delays. That kind of instant fulfillment significantly reduces support volume and builds trust — both of which matter a lot in a market where SaaS is still earning user confidence.
VelorOps uses this exact architecture in production. The system has processed thousands of bKash and Nagad payments with a false-positive rate of effectively zero, thanks to the strict validation stack described above.
Automate Your Billing and Publishing Together
VelorOps handles both bKash/Nagad auto billing and cloud video publishing in one platform. Start free and see how it works.
Get Started Free