Skip to Content
ePay.lkDocs

Quickstart

From a new sandbox account to a completed test payment in five minutes, using nothing but curl.

You'll create a sandbox account, get a secret test key, create a payment, pay it with a test card and confirm it through the API.

Create a sandbox account

Sign up at beta.sandbox-merchant.epay.lk. Sandbox signup is self-serve: confirm your email with the one-time code and your business is active immediately — no verification documents are needed in the sandbox.

Sandbox and production accounts are independent. Signing up for the sandbox doesn't create a production account, and production credentials never work in the sandbox.

Create a secret test key

In the sandbox dashboard go to Developers → API keys → Create secret key. Give it at least the payments:write and payments:read scopes. Copy the key — it starts with sk_test_ and is shown only once.

Terminal
export EPAY_KEY="sk_test_..."   # keep it out of source control

Create a payment

Amounts are integers in minor units: 125000 is LKR 1,250.00.

Terminal
curl https://beta.sandbox-api.epay.lk/v1/payments \
  -H "Authorization: Bearer $EPAY_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: quickstart-order-1042" \
  -d '{
    "amount": 125000,
    "currency": "LKR",
    "description": "Order #1042",
    "order_id": "1042",
    "customer": { "name": "Nimal Perera", "email": "nimal@example.com" },
    "return_url": "https://example.com/checkout/return",
    "cancel_url": "https://example.com/cart"
  }'
Response (abridged)
{
  "id": "pay_8Hq2LxV0cT4mZr7N",
  "object": "payment",
  "status": "requires_payment",
  "amount": 125000,
  "currency": "LKR",
  "order_id": "1042",
  "checkout_url": "https://beta.sandbox-pay.epay.lk/c/cs_Q2h4...",
  "livemode": false,
  "expires_at": "2026-11-22T11:15:00.000Z"
}

checkout_url is returned only in this create response. Redirect the payer there right away (or store it).

Pay with a test card

Open checkout_url in your browser and choose Card. You'll be sent to the bank simulator — enter:

FieldValue
Card number4242 4242 4242 4242
Expiryany future date, e.g. 12/30
CVCany 3 digits

The simulator approves the payment, notifies ePay and sends you back to the checkout, which then offers Return to merchant — your return_url with ?payment_id=…&status=succeeded&order_id=1042 appended. See all test cards.

Confirm the payment on your server

Never fulfil an order based on the browser redirect alone. Check the payment status with your secret key:

Terminal
curl https://beta.sandbox-api.epay.lk/v1/payments/pay_8Hq2LxV0cT4mZr7N \
  -H "Authorization: Bearer $EPAY_KEY"
Response (abridged)
{
  "id": "pay_8Hq2LxV0cT4mZr7N",
  "status": "succeeded",
  "amount": 125000,
  "fee": 3688,
  "net": 121312,
  "payment_method": { "type": "card", "card_brand": "visa", "card_last4": "4242" },
  "succeeded_at": "2026-11-22T10:16:41.000Z"
}

In production you'll usually rely on the payment.succeeded webhook instead of polling.

Next steps

On this page