Skip to Content
ePay.lkDocs
API reference

Payments

The Payment object and the /v1/payments endpoints.

The Payment object

FieldTypeDescription
idstringUnique ID, pay_…
object"payment"
statusenumrequires_payment, processing, succeeded, failed, canceled, expired, partially_refunded, refunded — see statuses
amountintegerAmount in minor units
currencyLKR | USD
amount_refundedintegerTotal successfully refunded, minor units
feeintegerePay fee, minor units (0 until succeeded)
netintegeramount − fee
descriptionstring | null
order_idstring | nullYour reference
sourceenumapi, payment_link, invoice, qr, legacy_form
customerobject{ id, name, email, phone } — any may be null
payment_methodobject | null{ type: "card" | "lankaqr", card_brand, card_last4 } once an attempt was made
failureobject | null{ code, message } of the latest declined attempt
metadataobjectYour string key/value pairs
return_urlstring | nullAs provided at creation
cancel_urlstring | nullAs provided at creation
checkout_urlstringCreate response only. Hosted checkout link with a one-time token
payment_link_idstring | nullSet when source is payment_link
invoice_idstring | nullSet when source is invoice
livemodebooleantrue in production
created_attimestamp
expires_attimestampAfter this the payment becomes expired if unpaid
succeeded_attimestamp | null
settled_attimestamp | nullWhen the funds became available

Create a payment

POST/v1/paymentsscope payments:write

Headers: Idempotency-Key (recommended).

Body parameterTypeDescription
amountinteger, requiredPositive, minor units
currencyLKR | USDDefault LKR
descriptionstring ≤ 500Shown on the checkout
order_idstring 1–100Your reference
customerobjectname ≤ 200, email, phone ≤ 30 — all optional
metadataobject≤ 20 keys; key ≤ 40 chars, value ≤ 500 chars
return_urlURLhttp(s), ≤ 2000 chars
cancel_urlURLhttp(s), ≤ 2000 chars
expires_in_minutesinteger5–1440, default 60
Request
curl https://beta.api.epay.lk/v1/payments \
  -H "Authorization: Bearer $EPAY_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order-1042" \
  -d '{ "amount": 125000, "order_id": "1042", "return_url": "https://shop.example.lk/return" }'
Response 200
{
  "id": "pay_8Hq2LxV0cT4mZr7N",
  "object": "payment",
  "status": "requires_payment",
  "amount": 125000,
  "currency": "LKR",
  "amount_refunded": 0,
  "fee": 0,
  "net": 0,
  "description": null,
  "order_id": "1042",
  "source": "api",
  "customer": { "id": null, "name": null, "email": null, "phone": null },
  "payment_method": null,
  "failure": null,
  "metadata": {},
  "return_url": "https://shop.example.lk/return",
  "cancel_url": null,
  "checkout_url": "https://beta.pay.epay.lk/c/cs_Q2h4bW9uZXlfaXNfbm90X3JlYWw",
  "payment_link_id": null,
  "invoice_id": null,
  "livemode": true,
  "created_at": "2026-11-22T10:15:00.000Z",
  "expires_at": "2026-11-22T11:15:00.000Z",
  "succeeded_at": null,
  "settled_at": null
}

Errors: 400 parameter_invalid, 400 currency_unsupported, 422 idempotency_key_reused, 409 idempotency_key_in_use.

Retrieve a payment

GET/v1/payments/:idscope payments:read
Request
curl https://beta.api.epay.lk/v1/payments/pay_8Hq2LxV0cT4mZr7N -H "Authorization: Bearer $EPAY_SECRET_KEY"

Returns the Payment object (without checkout_url). 404 resource_missing if it doesn't exist or belongs to another account.

List payments

GET/v1/paymentsscope payments:read
Query parameterDescription
statusStatus or comma-separated statuses
order_idExact match
limit1–100, default 20
cursorFrom next_cursor
Request
curl "https://beta.api.epay.lk/v1/payments?order_id=1042" -H "Authorization: Bearer $EPAY_SECRET_KEY"
Response 200
{
  "object": "list",
  "data": [{ "id": "pay_8Hq2LxV0cT4mZr7N", "object": "payment", "status": "succeeded", "order_id": "1042" }],
  "has_more": false,
  "next_cursor": null
}

Cancel a payment

POST/v1/payments/:id/cancelscope payments:write

No body. Only for requires_payment; otherwise 409 payment_not_cancelable.

Request
curl -X POST https://beta.api.epay.lk/v1/payments/pay_8Hq2LxV0cT4mZr7N/cancel \
  -H "Authorization: Bearer $EPAY_SECRET_KEY"

Returns the Payment object with status: "canceled" and sends payment.canceled.

On this page