Nagad
The Nagad merchant gateway in taka: merchant ID and the two keys, the signed and encrypted two-step checkout, verification with Nagad, sandbox testing and troubleshooting.
The Nagad plugin takes payments through the Nagad merchant payment gateway. The client presses a button on the invoice, pays on Nagad's page and returns to the invoice. It works in Bangladeshi taka (BDT) only. It is free and suits shops in Bangladesh that have a Nagad merchant account. With only a personal Nagad number use Mobile Wallet. What all gateways share is in Payment gateways.
Nagad works differently from a gateway with a simple password: your requests are signed with your private key and the sensitive data is encrypted with Nagad's public key. That is why the setup asks for two long keys.
Switching it on
- Open Setup → Payment Gateways, tab All Payment Gateways, press Activate on Nagad.
- Enter the merchant ID and paste the two keys. Save.
- Test in the sandbox, then switch Test mode off.
Activation creates a small table where the plugin remembers each payment it starts; uninstalling drops it. The PHP openssl extension is needed (the installer requires it anyway) and so is curl.
Settings
| Setting | Meaning |
|---|---|
| Display name, Payment instructions, Fee %, Fixed fee | The settings every gateway has. |
| Test mode | Use Nagad's sandbox. |
| Merchant ID | The merchant ID Nagad gave you. |
| Merchant private key | Your private key in PKCS#8 form. Paste the whole PEM block, or just the base64 text. It signs the requests and decrypts Nagad's answers. |
| Nagad public key | The PGW public key Nagad gave you. It encrypts the sensitive data. |
On the page the settings are grouped as Nagad (the merchant ID) and Keys. Without all three the invoice shows Nagad is not set up yet: the merchant ID or a key is missing.
What Nagad needs from you
- A Nagad merchant account and, from Nagad, the merchant ID and Nagad's public key (the "PGW public key"). Your merchant private key is the other half of the key pair you registered with Nagad. Follow the onboarding steps Nagad gives you for how the pair is made and registered.
- Nagad may ask you to register your site address, your callback address and your server's IP address. Ask them when you get the credentials. The callback address is shown at the bottom of the settings page:
https://billing.example.com/callback/nagad. - Sandbox and live use different credentials. Keep both sets safe; switch with Test mode.
How a payment goes
- The client presses Pay ... with Nagad on an unpaid invoice in BDT.
- Step one, initialize: AIOBilling sends Nagad an encrypted and signed request for a new order (the order ID looks like
I12T123456789) and gets a payment reference and a challenge back. The answer's signature is checked. - Step two, complete: the plugin sends the amount and the challenge, with your callback address, and Nagad answers with the address of its payment page. The client is sent there.
- The client pays. Nagad sends the browser back to the callback address with the order ID and the payment reference.
- The plugin never trusts what comes in the address. It asks Nagad to verify the payment reference. The status must be Success, and the order ID, the amount and the merchant ID must match what was asked for.
- The transaction ID is Nagad's issuer reference (or the payment reference), the invoice is marked paid and the client returns to the invoice. A payment that is reported twice is recorded once.
As with bKash there is no separate server notice: the payment is recorded when the browser returns. If a client paid but the invoice is unpaid, check the Nagad merchant portal and use Add Payment on the invoice.
Refunds
There is no refund call. Refund in Nagad and record it on the invoice's Refund tab with Offline refund (record only).
Testing in the sandbox
- Get the sandbox merchant ID and keys from Nagad, enter them and switch Test mode on.
- Pay a small BDT invoice from the client area with Nagad's test account.
- The invoice should turn Paid. Then switch to the live credentials and Test mode off.
Troubleshooting
Look in Billing → Gateway Log (filter Nagad) and Utilities → Module Log.
| Message or result | Cure |
|---|---|
| The Nagad keys could not be read. Check the merchant private key and the Nagad public key. | A key was pasted wrongly: no extra words, the private key must be PKCS#8, and the two keys must not be swapped. |
| Nagad could not start the payment: ... | Nagad's own message follows: a wrong merchant ID, keys of the other environment, or an address or IP not registered with Nagad. |
| Nagad answered with data this site could not read. | The merchant private key does not match the public key Nagad has for you. |
| The answer from Nagad is not signed correctly. | The Nagad public key is wrong or from the other environment. |
| Nagad could not open the payment page: ... | The second step failed; read the message. |
unknown order / mismatch | The callback names an order this site did not create, or the amount or merchant does not match. |
| Nagad takes Bangladeshi taka only. | The invoice is not in BDT. |
More in Troubleshooting.
Was this helpful?
Updated 2026-11-03