Skip to Content
ePay.lkDocs

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

ProductionSandbox
Original URLPOST https://beta.ipg.epay.lk/POST https://beta.sandbox-ipg.epay.lk/
Equivalent pathPOST https://beta.api.epay.lk/legacy/ipgPOST 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.

Legacy form (unchanged)
<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 hex

amount 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

FieldRequiredNotes
merchantIdYesYour 6-character merchant code
orderIdYesUp to 100 characters
amountYesMajor units as a decimal string: "1250.00" (up to 2 decimals)
currencyYesLKR
returnUrlYeshttp(s) URL
cancelUrlNoDefaults to returnUrl
notifyUrlNoMust be a public https URL
name, email, phone, descriptionNoPrefill the checkout / payer details
address, city, state, zip, countryNoStored as the billing address
hashYesSee 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 authenticationmd5 of a few fieldsSecret API key over TLS, scoped and revocable
Notification signingmd5, no timestamp — replayableEpay-Signature: HMAC-SHA256 with timestamp, 5-minute replay window
Retries after declineNo — one attempt, then FAILUREPayer can retry until expiry
RefundsDashboard onlyPOST /v1/refunds, full or partial, with webhooks
Duplicate protectionNoneIdempotency-Key on creates
EventsSUCCESS / FAILURE onlypayment.*, refund.*, payout.*, invoice.paid, GET /v1/events
AmountsDecimal stringsInteger minor units
Look-upsNoneGET /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/v1Notes
merchantId (form field)(implied by your API key)The 6-character merchant code is no longer sent
hashAuthorization: Bearer sk_live_…Server-side secret key instead of a per-request md5
orderIdorder_id
amount: "1250.00"amount: 125000Integer minor units: multiply by 100
currencycurrencyOptional, default LKR
descriptiondescription
name, email, phonecustomer.name, customer.email, customer.phone
address, city, state, zip, countrymetadataNot part of the payment object; keep them in your order or metadata
returnUrlreturn_urlReturns with ?payment_id&status&order_id (lowercase statuses)
cancelUrlcancel_url
notifyUrlWebhook endpoint (dashboard)Configured once per account, signed with HMAC-SHA256
status: SUCCESSpayment.succeeded event / status: "succeeded"
status: FAILUREpayment.failed (attempt) · payment.expired · payment.canceledA failed attempt is no longer final
paymentIdid (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.

On this page