K-LINK Pay Docs · K-LINK Pay · llms.txt

Quick start

Take your first QR payment in test mode in about ten minutes. Building an AI agent? See Using K-LINK Pay from an AI agent.

K-LINK Pay is a REST API at https://api.klinkpay.net/v1. You create a payment from your server, show the customer a QR code (or send them to our hosted checkout), and we tell your server when it is paid with a signed webhook. Every amount is an integer in the currency's smallest unit: 1300 is SGD 13.00, and 15200 is MMK 15,200 because MMK has no decimals. See Amounts and currencies.

[!NOTE] Payment methods and currencies K-LINK Pay takes QR payments on Southeast Asia's national QR standards, wallet push and cards. Each payment is in the currency of one of your currency accounts, and a currency works in live mode once its account is active. See Amounts and currencies. The examples on this page use MMK; send the currency of your own account.

1. Get a test key

  1. Sign up and set up two-factor sign-in.
  2. Open Developers → API keys in the dashboard and create a test secret key. It starts with kp_test_ and is shown once: store it as a secret on your server (e.g. KLINK_PAY_SECRET_KEY).

[!NOTE] Test keys work from the moment you sign up. Live keys (kp_live_) can be created once your account has been reviewed and is active. See Authentication.

2. Create a payment

Call POST /v1/payments from your server with the amount and your own order reference. Send an Idempotency-Key so a retry never creates a second payment.

curl https://api.klinkpay.net/v1/payments \
  -H "Authorization: Bearer kp_test_…" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order-1001" \
  -d '{
    "amount": 15200,
    "currency": "MMK",
    "reference": "order-1001",
    "description": "Table 4",
    "return_url": "https://shop.example.com/orders/1001"
  }'
// Node 18+ (built-in fetch)
const res = await fetch("https://api.klinkpay.net/v1/payments", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.KLINK_PAY_SECRET_KEY}`,
    "Content-Type": "application/json",
    "Idempotency-Key": "order-1001",
  },
  body: JSON.stringify({
    amount: 15200, // smallest unit: MMK has no decimals, so this is MMK 15,200
    currency: "MMK",
    reference: "order-1001",
    description: "Table 4",
    return_url: "https://shop.example.com/orders/1001",
  }),
});
if (!res.ok) throw new Error((await res.json()).error.message);
const payment = await res.json();
// Redirect the customer to payment.checkout_url, or draw payment.qr_payload as a QR code.
<?php
$ch = curl_init("https://api.klinkpay.net/v1/payments");
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer " . getenv("KLINK_PAY_SECRET_KEY"),
        "Content-Type: application/json",
        "Idempotency-Key: order-1001",
    ],
    CURLOPT_POSTFIELDS => json_encode([
        "amount" => 15200,
        "currency" => "MMK",
        "reference" => "order-1001",
        "description" => "Table 4",
        "return_url" => "https://shop.example.com/orders/1001",
    ]),
]);
$payment = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($status >= 400) {
    throw new Exception($payment["error"]["message"]);
}
header("Location: " . $payment["checkout_url"]);
import os
import requests

res = requests.post(
    "https://api.klinkpay.net/v1/payments",
    headers={
        "Authorization": f"Bearer {os.environ['KLINK_PAY_SECRET_KEY']}",
        "Idempotency-Key": "order-1001",
    },
    json={
        "amount": 15200,
        "currency": "MMK",
        "reference": "order-1001",
        "description": "Table 4",
        "return_url": "https://shop.example.com/orders/1001",
    },
    timeout=15,
)
if not res.ok:
    raise RuntimeError(res.json()["error"]["message"])
payment = res.json()
# Redirect to payment["checkout_url"], or render payment["qr_payload"] as a QR code.

The response is a payment in status pending:

{
  "id": "pay_4Nq7xY2mKc8vTz1aB3dE9f",
  "object": "payment",
  "livemode": false,
  "status": "pending",
  "amount": 15200,
  "currency": "MMK",
  "method": "mmqr",
  "reference": "order-1001",
  "bank_reference": "KP7GQ2M9XW4T",
  "description": "Table 4",
  "checkout_url": "https://checkout.klinkpay.net/c/pay_4Nq7xY2mKc8vTz1aB3dE9f",
  "qr_payload": "00020101021226…6304A1B2",
  "redirect_url": null,
  "customer_phone": null,
  "return_url": "https://shop.example.com/orders/1001",
  "metadata": {
    "order_id": "1001"
  },
  "failure_reason": null,
  "expires_at": "2026-11-27T10:15:00Z",
  "succeeded_at": null,
  "created_at": "2026-11-27T10:00:00Z",
  "amount_refunded": 0,
  "fees": null,
  "net": null,
  "payment_link": null
}

3. Let the customer pay

Pick one of two ways:

  • Redirect to the hosted checkout. Send the customer to checkout_url. It shows the amount, the QR, a countdown and the live status, and returns them to your return_url after a successful payment (with payment_id and status added to the query string).
  • Show the QR yourself. Draw qr_payload as a QR code (any QR library) in your app, on a screen at the counter, or as an image message in a chat. The customer scans it with a banking or wallet app that supports that QR standard.
import QRCode from "qrcode";

const svg = await QRCode.toString(payment.qr_payload, { type: "svg", margin: 1 });
// Put the SVG on your page; show payment.amount and a timer until payment.expires_at.
// In a chat, render a PNG instead and send it as an image: see the AI agent guide.

[!NOTE] The customer's banking app shows K-LINK as the payee, because every payment goes through K-LINK's merchant account. The hosted checkout says "Pay <your business> via K-LINK Pay" so your customers aren't surprised.

To push a payment request into the customer's mobile wallet app instead of showing a QR (the payer approves it in the app), create the payment with "method": "ayapay_push" and their customer_phone.

4. Handle the webhook

Add an endpoint under Developers → Webhooks in the dashboard (or with the API) and keep its signing secret. When the payment succeeds we POST a payment.succeeded event to it. Verify the Klink-Signature header, then fulfil the order. Answer with a 2xx quickly; anything else is retried.

import crypto from "node:crypto";
import express from "express";

const app = express();
const SECRET = process.env.KLINK_PAY_WEBHOOK_SECRET;
const TOLERANCE_SECONDS = 300;

// Use the raw body: the signature covers the exact bytes we sent.
app.post("/webhooks/klink-pay", express.raw({ type: "application/json" }), (req, res) => {
  const header = req.get("Klink-Signature") ?? "";
  const parts = Object.fromEntries(header.split(",").map((p) => p.split("=", 2)));
  const t = Number(parts.t);
  const body = req.body.toString("utf8");

  const expected = crypto.createHmac("sha256", SECRET).update(`${t}.${body}`).digest("hex");
  const given = Buffer.from(parts.v1 ?? "", "hex");
  const valid =
    given.length === expected.length / 2 &&
    crypto.timingSafeEqual(given, Buffer.from(expected, "hex")) &&
    Math.abs(Date.now() / 1000 - t) <= TOLERANCE_SECONDS;
  if (!valid) return res.status(400).send("bad signature");

  const event = JSON.parse(body);
  // Deduplicate by event.id, then hand off to a queue and answer quickly.
  if (event.type === "payment.succeeded") {
    markOrderPaid(event.data.object.reference);
  }
  res.sendStatus(200);
});
<?php
$secret = getenv("KLINK_PAY_WEBHOOK_SECRET");
$body = file_get_contents("php://input"); // raw body
$header = $_SERVER["HTTP_KLINK_SIGNATURE"] ?? "";

$parts = [];
foreach (explode(",", $header) as $part) {
    [$k, $v] = array_pad(explode("=", $part, 2), 2, "");
    $parts[$k] = $v;
}
$t = (int) ($parts["t"] ?? 0);
$expected = hash_hmac("sha256", $t . "." . $body, $secret);

if (!hash_equals($expected, $parts["v1"] ?? "") || abs(time() - $t) > 300) {
    http_response_code(400);
    exit("bad signature");
}

$event = json_decode($body, true);
// Deduplicate by $event["id"].
if ($event["type"] === "payment.succeeded") {
    mark_order_paid($event["data"]["object"]["reference"]);
}
http_response_code(200);
import hashlib
import hmac
import json
import os
import time

from flask import Flask, abort, request

app = Flask(__name__)
SECRET = os.environ["KLINK_PAY_WEBHOOK_SECRET"].encode()

@app.post("/webhooks/klink-pay")
def klink_pay_webhook():
    body = request.get_data()  # raw bytes
    parts = dict(p.split("=", 1) for p in request.headers.get("Klink-Signature", "").split(",") if "=" in p)
    t = int(parts.get("t", "0"))
    expected = hmac.new(SECRET, f"{t}.".encode() + body, hashlib.sha256).hexdigest()

    if not hmac.compare_digest(expected, parts.get("v1", "")) or abs(time.time() - t) > 300:
        abort(400)

    event = json.loads(body)
    # Deduplicate by event["id"].
    if event["type"] == "payment.succeeded":
        mark_order_paid(event["data"]["object"]["reference"])
    return "", 200

[!WARNING] Trust the webhook, not the redirect Customers can close the page before they are sent back to return_url, and anyone can open that URL. Mark an order paid only from a verified webhook, or by fetching the payment with GET /v1/payments/:id.

5. Test it

Open the checkout_url of a test payment. Test mode has Simulate payment and Simulate failure buttons instead of a real bank; your webhook receives the event as it would in live mode. See Test mode.

6. Go live

  1. In the dashboard, complete the onboarding checklist: business profile, documents, bank account, then Submit for review.
  2. Once your account is active, create a live key and a live (or both-modes) webhook endpoint.
  3. Swap kp_test_ for kp_live_ on your server. Successful payments are paid out to your bank account after your payout delay, on your payout schedule.