Environments & sandbox
Production and sandbox are separate deployments with separate accounts, keys, data and hostnames. Test everything in the sandbox with the bank simulator and test cards.
Two isolated environments
The sandbox is not a test mode inside production. It's a separate deployment of the same code, with its own database, secrets, queues, storage and hostnames, and it can only talk to a bank simulator — never to a real acquirer. Nothing you do in the sandbox can move real money.
| Production | Sandbox | |
|---|---|---|
| API | https://beta.api.epay.lk | https://beta.sandbox-api.epay.lk |
| Hosted checkout | https://beta.pay.epay.lk | https://beta.sandbox-pay.epay.lk |
| Dashboard | https://beta.merchant.epay.lk | https://beta.sandbox-merchant.epay.lk |
| Legacy form-POST | https://beta.ipg.epay.lk | https://beta.sandbox-ipg.epay.lk |
| Secret keys | sk_live_… | sk_test_… |
| Publishable keys | pk_live_… | pk_test_… |
livemode on objects | true | false |
environment on events | production | sandbox |
| Acquirers | Card acquiring bank (3-D Secure), LankaQR | Bank simulator only |
| Signup | Business verification (KYB) required | Self-serve, active immediately |
What isolation means for you
- Keys only work in their own environment. The API checks the key prefix before anything else: an
sk_test_key sent tobeta.api.epay.lk(or ansk_live_key sent to the sandbox) is rejected with401 api_key_environment_mismatch. - Accounts are separate. Sandbox and production users live in different databases. The same email can exist in both, with different passwords; sessions and keys never cross over.
- Webhook signing secrets, legacy credentials and endpoints are per environment. Configure them in each dashboard.
- Drive everything from configuration. Keep the API base URL and key in environment variables so the same code runs against both:
EPAY_API_URL=https://beta.sandbox-api.epay.lk # https://beta.api.epay.lk in production
EPAY_SECRET_KEY=sk_test_... # sk_live_... in production
EPAY_WEBHOOK_SECRET=whsec_...Sandbox accounts
Sign up at beta.sandbox-merchant.epay.lk. After confirming your email with the one-time code, your business is active with verification auto-approved, so you can create keys and take test payments straight away. Invite teammates from Team exactly as you would in production.
The bank simulator
In the sandbox, the checkout hands payers to the simulator at beta.sandbox-bank.epay.lk instead of a bank. It behaves like a real acquirer:
- Your server calls
POST /v1/paymentswith ansk_test_key and redirects the payer tocheckout_url. - The payer chooses Card on the checkout; ePay creates a simulator session and redirects the browser to
beta.sandbox-bank.epay.lk/pay/…. - The payer enters a test card (and a 3-D Secure code if challenged).
- The simulator sends a signed server-to-server callback to ePay; the payment becomes
succeeded(or the attempt fails), the ledger is updated and webhooks are sent. - The browser returns to the checkout result page and the payer clicks Return to merchant.
The checkout page shows a Sandbox checkout badge and the test card list, so you can't mistake it for production.
Test cards
Use any future expiry date and any 3-digit CVC.
| Card number | Brand | Result | Failure code |
|---|---|---|---|
4242 4242 4242 4242 | Visa | Approved (frictionless 3-D Secure) | — (00) |
5555 5555 5555 4444 | Mastercard | Approved | — (00) |
4000 0000 0000 3220 | Visa | 3-D Secure challenge: OTP 123456 approves, anything else fails | authentication_failed |
4000 0000 0000 0002 | Visa | Declined — do not honour | card_declined (05) |
4000 0000 0000 9995 | Visa | Declined — insufficient funds | insufficient_funds (51) |
4000 0000 0000 0069 | Visa | Declined — expired card | expired_card (54) |
4000 0000 0000 0119 | Visa | Acquirer processing error | processing_error (96) |
4000 0000 0000 7726 | Visa | Approved, but the callback is delayed ~10 s (tests your "processing" handling) | — (00) |
4000 0000 0000 5126 | Visa | Timeout — no callback; the attempt times out after 15 minutes | acquirer_timeout |
Any other Luhn-valid number is approved. Invalid numbers are rejected on the simulator page itself (no callback is sent).
A declined attempt doesn't end the payment: it goes back to requires_payment with failure set and a payment.failed event is sent. The payer can try again (for example with 4242 4242 4242 4242) until the payment expires. See payment statuses.
LankaQR
LankaQR is available in the sandbox. Choose LankaQR on the checkout to get a QR code; the simulator's LankaQR page offers Simulate successful scan and Decline buttons. (In production, LankaQR is enabled per account once the bank integration is live; card payments are always available.)
Refunds in the sandbox
Refunds through the simulator succeed immediately, except amounts whose minor units end in 13 — for example 1013 (LKR 10.13) or 250013 — which fail with refund_rejected. Use them to test your refund.failed handling.
Refund approvals
Refunds above the approval threshold (default LKR 100,000.00, i.e. 10000000 minor units) are created with status requires_approval and must be approved by ePay operations before they're sent to the acquirer. In the sandbox this is done by ePay's sandbox support staff; contact us if you need a pending refund approved for testing. See Refunds.
Webhooks in the sandbox
Add endpoints in the sandbox dashboard under Developers → Webhooks. Deployed environments only deliver to public HTTPS URLs — use a tunnel (for example cloudflared tunnel or ngrok) to receive sandbox events on your laptop. You can resend any delivery from the dashboard.
Going live
Verify your business. Sign up at beta.merchant.epay.lk and complete Verification (business registration, directors, bank account). Production payments are enabled once ePay approves your account.
Create production keys and webhook endpoints in the production dashboard. Production webhook secrets differ from sandbox ones.
Switch configuration, not code: EPAY_API_URL=https://beta.api.epay.lk, EPAY_SECRET_KEY=sk_live_…, EPAY_WEBHOOK_SECRET=whsec_… (production).
Make a small real payment and refund it to confirm the end-to-end flow, including your webhook handler.

