Migrating from the legacy form-POST API
The old beta.ipg.epay.lk HTML form integration keeps working unchanged. Here's how it maps to /v1, and why and how to move.
If your site posts an HTML form to https://beta.ipg.epay.lk with an md5 hash (including the ePay WooCommerce plugin), you don't have to change anything today. The new platform accepts the same form, verifies the same hash, sends the same notification and returns the browser in the same format. Every legacy payment also appears in the new dashboard, reports and payouts.
The legacy endpoint is still supported
| Production | Sandbox | |
|---|---|---|
| Original URL | POST https://beta.ipg.epay.lk/ | POST https://beta.sandbox-ipg.epay.lk/ |
| Equivalent path | POST https://beta.api.epay.lk/legacy/ipg | POST https://beta.sandbox-api.epay.lk/legacy/ipg |
Requests are application/x-www-form-urlencoded browser form posts. On success ePay responds 303 See Other to the hosted checkout; invalid requests get a plain error page.
<form method="POST" action="https://beta.ipg.epay.lk/">
<input type="hidden" name="merchantId" value="AB12CD" />
<input type="hidden" name="orderId" value="1042" />
<input type="hidden" name="amount" value="1250.00" />
<input type="hidden" name="currency" value="LKR" />
<input type="hidden" name="returnUrl" value="https://shop.example.lk/epay/return" />
<input type="hidden" name="cancelUrl" value="https://shop.example.lk/cart" />
<input type="hidden" name="notifyUrl" value="https://shop.example.lk/epay/notify" />
<input type="hidden" name="name" value="Nimal Perera" />
<input type="hidden" name="email" value="nimal@example.com" />
<input type="hidden" name="description" value="Order #1042" />
<input type="hidden" name="hash" value="<md5 hex>" />
<button type="submit">Pay with ePay</button>
</form>Request hash
hash = md5( merchantId + orderId + amount + currency + secret ) // lowercase hexamount and currency are hashed exactly as you post them (e.g. "1250.00", "LKR"). The secret is your legacy credential, found in the new dashboard under Developers → Legacy integration (sandbox credentials live in the sandbox dashboard). Rotating it there requires updating your plugin settings.
Fields
| Field | Required | Notes |
|---|---|---|
merchantId | Yes | Your 6-character merchant code |
orderId | Yes | Up to 100 characters |
amount | Yes | Major units as a decimal string: "1250.00" (up to 2 decimals) |
currency | Yes | LKR |
returnUrl | Yes | http(s) URL |
cancelUrl | No | Defaults to returnUrl |
notifyUrl | No | Must be a public https URL |
name, email, phone, description | No | Prefill the checkout / payer details |
address, city, state, zip, country | No | Stored as the billing address |
hash | Yes | See above |
Notifications
When a legacy payment succeeds or fails, ePay POSTs JSON to notifyUrl (retried on the webhook schedule until your server returns 2xx):
{
"paymentId": "pay_8Hq2LxV0cT4mZr7N",
"merchantId": "AB12CD",
"orderId": "1042",
"amount": "1250.00",
"currency": "LKR",
"status": "SUCCESS",
"hash": "9c2f0e1b6d4a7c8e5f3b2a1d0e9f8c7b",
"createdAt": "2026-11-22T10:15:00.000Z",
"brand": "visa",
"card": "************4242"
}Verify it with:
hash = md5( merchantId + orderId + amount + currency + status + secret )using the values from the notification (amount is always formatted with two decimals, e.g. "1250.00", even if you posted "1250"). brand and card are present for card payments. Legacy payments are one-shot: a declined attempt ends the payment with status: "FAILURE".
Browser return
After the payment, the payer returns to:
https://shop.example.lk/epay/return?order=1042&status=SUCCESS (or status=FAILURE)If they cancel on the checkout, they go to cancelUrl?order=1042. As before, treat these parameters as untrusted and rely on the notification.
Why migrate to /v1
| Legacy form-POST | /v1 API | |
|---|---|---|
| Request authentication | md5 of a few fields | Secret API key over TLS, scoped and revocable |
| Notification signing | md5, no timestamp — replayable | Epay-Signature: HMAC-SHA256 with timestamp, 5-minute replay window |
| Retries after decline | No — one attempt, then FAILURE | Payer can retry until expiry |
| Refunds | Dashboard only | POST /v1/refunds, full or partial, with webhooks |
| Duplicate protection | None | Idempotency-Key on creates |
| Events | SUCCESS / FAILURE only | payment.*, refund.*, payout.*, invoice.paid, GET /v1/events |
| Amounts | Decimal strings | Integer minor units |
| Look-ups | None | GET /v1/payments/:id, ?order_id= |
md5 is no longer considered secure, and the legacy notification has no timestamp, so a captured notification could be replayed. New integrations should use /v1.
Field-by-field mapping
| Legacy | /v1 | Notes |
|---|---|---|
merchantId (form field) | (implied by your API key) | The 6-character merchant code is no longer sent |
hash | Authorization: Bearer sk_live_… | Server-side secret key instead of a per-request md5 |
orderId | order_id | |
amount: "1250.00" | amount: 125000 | Integer minor units: multiply by 100 |
currency | currency | Optional, default LKR |
description | description | |
name, email, phone | customer.name, customer.email, customer.phone | |
address, city, state, zip, country | metadata | Not part of the payment object; keep them in your order or metadata |
returnUrl | return_url | Returns with ?payment_id&status&order_id (lowercase statuses) |
cancelUrl | cancel_url | |
notifyUrl | Webhook endpoint (dashboard) | Configured once per account, signed with HMAC-SHA256 |
status: SUCCESS | payment.succeeded event / status: "succeeded" | |
status: FAILURE | payment.failed (attempt) · payment.expired · payment.canceled | A failed attempt is no longer final |
paymentId | id (pay_…) | Same ID space — legacy payments also have a pay_… id |
Migration steps
Build against the sandbox. Create a sandbox account and an sk_test_ key; implement payment creation, the return handler and a webhook endpoint. Use the test cards.
Replace the form post with a server-side POST /v1/payments and a redirect to checkout_url. Send Idempotency-Key: order-<orderId>.
Replace notifyUrl handling with a webhook handler that verifies Epay-Signature, then fulfils on payment.succeeded.
Switch to production keys and run both integrations side by side if you like — legacy and /v1 payments share the same account, balance and payouts.
Retire the legacy credential in Developers → Legacy integration once no traffic uses it.
WooCommerce
The existing ePay WooCommerce plugin uses the legacy form-POST and keeps working without changes — make sure the plugin's Merchant ID and secret match the legacy credential shown in the new dashboard, and that your store's notify URL is reachable over public HTTPS. A WooCommerce plugin built on /v1 and webhooks (with refunds from the WooCommerce order screen) is planned; until then, issue refunds from the ePay dashboard.

