API reference
Payments
The Payment object and the /v1/payments endpoints.
The Payment object
| Field | Type | Description |
|---|---|---|
id | string | Unique ID, pay_… |
object | "payment" | |
status | enum | requires_payment, processing, succeeded, failed, canceled, expired, partially_refunded, refunded — see statuses |
amount | integer | Amount in minor units |
currency | LKR | USD | |
amount_refunded | integer | Total successfully refunded, minor units |
fee | integer | ePay fee, minor units (0 until succeeded) |
net | integer | amount − fee |
description | string | null | |
order_id | string | null | Your reference |
source | enum | api, payment_link, invoice, qr, legacy_form |
customer | object | { id, name, email, phone } — any may be null |
payment_method | object | null | { type: "card" | "lankaqr", card_brand, card_last4 } once an attempt was made |
failure | object | null | { code, message } of the latest declined attempt |
metadata | object | Your string key/value pairs |
return_url | string | null | As provided at creation |
cancel_url | string | null | As provided at creation |
checkout_url | string | Create response only. Hosted checkout link with a one-time token |
payment_link_id | string | null | Set when source is payment_link |
invoice_id | string | null | Set when source is invoice |
livemode | boolean | true in production |
created_at | timestamp | |
expires_at | timestamp | After this the payment becomes expired if unpaid |
succeeded_at | timestamp | null | |
settled_at | timestamp | null | When the funds became available |
Create a payment
POST/v1/paymentsscope payments:write
Headers: Idempotency-Key (recommended).
| Body parameter | Type | Description |
|---|---|---|
amount | integer, required | Positive, minor units |
currency | LKR | USD | Default LKR |
description | string ≤ 500 | Shown on the checkout |
order_id | string 1–100 | Your reference |
customer | object | name ≤ 200, email, phone ≤ 30 — all optional |
metadata | object | ≤ 20 keys; key ≤ 40 chars, value ≤ 500 chars |
return_url | URL | http(s), ≤ 2000 chars |
cancel_url | URL | http(s), ≤ 2000 chars |
expires_in_minutes | integer | 5–1440, default 60 |
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" }'{
"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
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 parameter | Description |
|---|---|
status | Status or comma-separated statuses |
order_id | Exact match |
limit | 1–100, default 20 |
cursor | From next_cursor |
curl "https://beta.api.epay.lk/v1/payments?order_id=1042" -H "Authorization: Bearer $EPAY_SECRET_KEY"{
"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.
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.

