Skip to content

Hosted payment page

The quickest integration: create a payment and redirect the payer to its checkout_url. The page shows the amount and the account to transfer to, follows the payment as it goes, and sends the payer back to you when it ends. You build no payment UI.

examples/curl/payments/create.sh
#!/usr/bin/env bash
# Create a payment and send the payer to its checkout_url.
set -euo pipefail
. "$(dirname "$0")/../signed-request.sh"
body=$(cat <<JSON
{
"merchant_order_id": "${ORDER_ID:-order-$(mka_new_key)}",
"amount": "${AMOUNT:-2500.00}",
"currency": "LKR",
"return_url": "https://shop.example.lk/orders/return"
}
JSON
)
mka_request POST "/v1/payments" "$body" "$(mka_new_key)"
Field
merchant_order_id Your order number, 1–128 characters, unique in the project. Sending it again with the same body answers the same payment.
amount A string with two decimals: "2500.00".
currency LKR.
return_url Optional. https:// only. Where the page’s button takes the payer once the payment ended.
locale Optional: en, si, ta or ru. The page’s language when the payer chose none; then the browser’s, then English.
  1. The page opens while the payment is pending and shows the account as soon as it is given.
  2. If your project lets payers choose their bank, they choose it first; the account follows within seconds.
  3. The payer transfers the exact amount from their bank app. The page updates itself: no refresh needed.
  4. On succeeded, failed or cancelled the page says so and offers the way back to return_url.

The link is the same in every answer for this payment, cannot be guessed, and opens while the payment runs and for 24 hours after it ended. It carries no key: send it to the payer as is — a redirect, a link in an e-mail, a QR code.

return_url is a convenience, not a proof. The payer may close the tab, or come back before the money arrived. Decide by the payment’s status — from its webhook or a GET:

examples/curl/payments/get.sh
#!/usr/bin/env bash
# Read a payment: the truth after a webhook, a timeout or a 503.
set -euo pipefail
. "$(dirname "$0")/../signed-request.sh"
payment_id=$(mka_required PAYMENT_ID)
mka_request GET "/v1/payments/$payment_id"