Create a payment
Create a payment on your server with POST /v1/payments, then send the payer to the hosted checkout.
A payment represents one amount you want to collect from one payer. You create it on your server, redirect the payer to its checkout_url, and ePay takes care of payment methods, 3-D Secure, retries after a decline, and notifying you.
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,
"currency": "LKR",
"description": "Order #1042 — 2 items",
"order_id": "1042",
"customer": { "name": "Nimal Perera", "email": "nimal@example.com", "phone": "+94771234567" },
"metadata": { "cart_id": "c_98431" },
"return_url": "https://shop.example.lk/checkout/return",
"cancel_url": "https://shop.example.lk/cart",
"expires_in_minutes": 30
}'Parameters
| Parameter | Type | Description |
|---|---|---|
amount | integer, required | Amount in minor units. 125000 = LKR 1,250.00. Must be a positive integer. |
currency | LKR | USD | Defaults to LKR. |
description | string ≤ 500 | Shown to the payer on the checkout page and in your dashboard. |
order_id | string 1–100 | Your reference. Returned on the redirect and in webhooks; filterable with GET /v1/payments?order_id=. |
customer | object | name (≤ 200), email (valid email), phone (≤ 30). Prefills the checkout and links the payment to a customer record. |
metadata | object | Up to 20 string key/value pairs (keys ≤ 40 chars, values ≤ 500). Returned unchanged; never shown to the payer. |
return_url | http(s) URL ≤ 2000 | Where the payer goes after the payment ends. ePay appends payment_id, status, order_id. |
cancel_url | http(s) URL ≤ 2000 | Where the payer goes if they cancel on the checkout page. |
expires_in_minutes | integer 5–1440 | How long the checkout stays payable. Default 60. |
Always send an Idempotency-Key so a network retry can't create a second payment.
Response
Returns the Payment object with status requires_payment, plus checkout_url:
{
"id": "pay_8Hq2LxV0cT4mZr7N",
"object": "payment",
"status": "requires_payment",
"amount": 125000,
"currency": "LKR",
"amount_refunded": 0,
"fee": 0,
"net": 0,
"description": "Order #1042 — 2 items",
"order_id": "1042",
"source": "api",
"customer": { "id": "cus_3fD1aQ9wK2", "name": "Nimal Perera", "email": "nimal@example.com", "phone": "+94771234567" },
"payment_method": null,
"failure": null,
"metadata": { "cart_id": "c_98431" },
"return_url": "https://shop.example.lk/checkout/return",
"cancel_url": "https://shop.example.lk/cart",
"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-22T10:45:00.000Z",
"succeeded_at": null,
"settled_at": null
}checkout_url is returned once
checkout_url contains a single-use capability token and appears only in the create response (and in an idempotent replay of it). GET /v1/payments/:id doesn't include it. Redirect immediately, or store it with the order if you redirect later.
Amounts in minor units
Convert at the edge of your system and keep integers everywhere else:
| Display | amount |
|---|---|
| LKR 1.00 | 100 |
| LKR 1,250.00 | 125000 |
| LKR 59,000.50 | 5900050 |
Avoid floating-point arithmetic for money: 19.99 * 100 is 1998.9999999999998 in JavaScript. Use Math.round(value * 100) or, better, store cents as integers in your database.

