API referenceDashboard

API reference

Base URL https://luyra.app/v1. JSON in, JSON out. Every request needs a secret key: Authorization: Bearer lk_test_… for your test store, lk_live_… for your live one. Same API, same webhooks. Test payments are simulated with the buttons on the checkout page, move no money and never count toward your plan. Keys live on your server, never in a browser or app.

Quick start

  1. 01

    Create a test key

    Sign in. Your account already has a test store. Create a key on it; it starts with lk_test_.

  2. 02

    Create a payment

    Send your customer to checkout_url, or draw qr_string yourself.

  3. 03

    Listen for the result

    Add a webhook endpoint and mark the order paid when payment.completed arrives.

  4. 04

    Go live

    When the flow works, connect your ABA PayWay merchant ID and API key under Stores, ask ABA to whitelist luyra.app for your merchant, and swap in the lk_live_ key.

Create a payment

POST/v1/payments

amount is USD, at least 0.01, at most two decimals. reference_id (≤255 chars) and metadata (a JSON object, ≤1,000 keys, 1 MB, 8 levels) are yours. Send an Idempotency-Key header (or idempotency_key field) so a retry returns the same payment with 200 instead of creating a second one. Reusing a key with a different amount, reference_id or metadata returns 400 idempotency_key_reused.

Request
curl https://luyra.app/v1/payments \
  -H "Authorization: Bearer lk_live_…" \
  -H "Idempotency-Key: order_1042" \
  -H "Content-Type: application/json" \
  -d '{ "amount": 12.50, "reference_id": "order_1042", "metadata": { "table": 4 } }'
201 Created
{
  "id": "Xk2…32 chars",
  "status": "pending",
  "amount": "12.50",
  "currency": "USD",
  "reference_id": "order_1042",
  "metadata": { "table": 4 },
  "qr_string": "00020101021229…6304A1B2",
  "deeplink": "abamobilebank://ababank.com?type=payway&…",
  "checkout_url": "https://luyra.app/pay/Xk2…",
  "approved_at": null,
  "created_at": "2026-11-21T12:00:00.000Z",
  "expires_at": "2026-11-21T12:05:00.000Z"
}

Statuses: pending → scanned → paid, or expired after about five minutes, or failed. The last three are final. Only paid counts toward your plan. deeplink opens ABA Mobile straight on the payment, for customers paying on the same phone; it is null in test mode.

Retrieve a payment

GET/v1/payments/:id

Returns the same object with the latest status. Poll it every 3 seconds if you don't use webhooks.

List payments

GET/v1/payments?status=paid&limit=20

Newest first, in data. limit defaults to 20, maximum 100.

Test mode

POST/v1/payments/:id/simulate

With an lk_test_ key nothing is charged or counted, and no bank app can pay the QR. Settle a payment yourself instead: send { "outcome": "paid" } (the default) or { "outcome": "failed" }. The payment changes status and your webhooks fire exactly as they would live, including invoice.paid and subscription.active when the payment belongs to an invoice. The hosted checkout page of a test payment has the same two buttons. A live key gets test_mode_only.

Subscriptions

A subscription gets one invoice per period, and each invoice has its own page where the customer pays by KHQR or card. A customer who saves a card or ABA account while paying is charged automatically from then on (see Automatic renewals); everyone else gets the next invoice to pay.

Luyra does not message your customers. Send them hosted_invoice_url yourself (email, Telegram, SMS) when invoice.created arrives, or share a price's subscribe_url and let them sign up on their own.

A subscription is incomplete until its first invoice is paid, then active. The first period starts at that payment. The next invoice is issued 3 days before a monthly or yearly period ends (1 day before for weekly, at the end for daily). If the period ends unpaid the subscription is past_due, and after 7 more days it is canceled and its open invoices become void.

Products and prices

POST/v1/products


POST/v1/prices

A product is what you sell. A price is a plan on it: interval is month (default), day, week, year or one_time, and interval_count (1 to 36) bills every N intervals. GET /v1/products, /v1/prices and /v1/customers list, and adding /:id retrieves one.

Request
curl https://luyra.app/v1/products \
  -H "Authorization: Bearer lk_live_…" -H "Content-Type: application/json" \
  -d '{ "name": "Pro membership", "description": "Every course, billed monthly" }'

curl https://luyra.app/v1/prices \
  -H "Authorization: Bearer lk_live_…" -H "Content-Type: application/json" \
  -d '{ "product": "prod_…", "amount": 9, "interval": "month" }'
201 Created
{
  "id": "price_m3X…",
  "product": "prod_…",
  "amount": "9.00",
  "currency": "USD",
  "interval": "month",
  "interval_count": 1,
  "active": true,
  "subscribe_url": "https://luyra.app/subscribe/price_m3X…",
  "created_at": "2026-11-21T12:00:00.000Z"
}

Create a subscription

POST/v1/subscriptions

customer is an id from POST /v1/customers, or an object with name and optional email and phone. A customer is matched by email, and a customer who already has a live subscription to the price gets that one back, not a second.

Request
curl https://luyra.app/v1/subscriptions \
  -H "Authorization: Bearer lk_live_…" -H "Content-Type: application/json" \
  -d '{ "price": "price_m3X…", "customer": { "name": "Sokha Chan", "email": "sokha@example.com" } }'
201 Created
{
  "id": "sub_8Hq…",
  "status": "incomplete",
  "customer": "cus_…",
  "price": "price_m3X…",
  "current_period_start": "2026-11-21T12:00:00.000Z",
  "current_period_end": "2026-12-21T12:00:00.000Z",
  "cancel_at_period_end": false,
  "canceled_at": null,
  "latest_invoice": {
    "id": "inv_…",
    "status": "open",
    "amount": "9.00",
    "due_at": "2026-11-22T12:00:00.000Z",
    "hosted_invoice_url": "https://luyra.app/invoice/inv_…"
  }
}

DELETE/v1/subscriptions/:id?at_period_end=true

Cancels now and voids open invoices. With at_period_end=true, an active subscription stays active until the period the customer paid for ends, and is not renewed. Sends subscription.updated.

POST/v1/subscriptions/:id/resume

Undoes at_period_end before the period ends; the subscription renews as before. Sends subscription.updated.

Customer portal

POST/v1/customers/:id/portal

Returns a link where the customer sees their subscriptions and invoices, pays an open invoice, cancels at period end or keeps a subscription, and removes a saved card. You build none of it. The link is signed and works for 24 hours, so create one each time you send it. The dashboard's Subscriptions page has a Portal link for every subscriber.

200 OK
{ "object": "portal_session", "customer": "cus_…",
  "url": "https://luyra.app/portal/cus_….1795…",
  "expires_at": "2026-11-26T09:00:00.000Z" }

Invoices

GET/v1/invoices/:id

Statuses: open, paid, void. POST /v1/invoices with a one_time price and a customer bills a single charge.

POST/v1/invoices/:id/pay

Returns a payment object (the same as Create a payment) for an open invoice, for when you show the QR yourself. It returns the same payment while its QR can still be scanned. The payment's reference_id is the invoice id, and it sends the usual payment.* events as well as invoice.paid.

Automatic renewals

On a subscription's invoice, the checkout offers Save a card (Visa, Mastercard, JCB, UnionPay, local or foreign) and Link ABA account (approved in ABA Mobile). The invoice is paid with it at once, and the subscription's collection becomes automatic. When each period ends Luyra charges the saved method for the renewal invoice. If that charge is declined, Luyra retries it 1, 3 and 5 days after the due date, inside the 7-day grace period. Each decline sends invoice.payment_failed with attempt and next_retry_at (null after the last try), and the invoice stays open for the customer to pay by KHQR or card meanwhile. The invoice shows attempt_count and next_payment_attempt.

Saved methods live at your own ABA PayWay merchant (Credentials on File), never on Luyra: ask ABA to enable it with the CITO_FLEX flag. ABA account links expire 90 days after their last charge, so a monthly plan keeps them alive. Events: payment_method.attached, invoice.payment_failed.

GET/v1/payment_methods

DELETE/v1/payment_methods/:id

Removing a method deletes it at PayWay (this cannot be undone) and switches its subscriptions back to invoices.

POST/v1/payment_links

A fixed amount behind a URL you send anywhere: Telegram, SMS, email or a printed QR. Each visit opens the checkout, where the customer pays by KHQR or card; payments carry payment_link and fire the usual payment.* events. Fields: title (required), amount (required, USD), description, max_payments (closes after that many paid), expires_at (ISO 8601), metadata. Luyra does not send the link for you.

Request
curl https://luyra.app/v1/payment_links \
  -H "Authorization: Bearer lk_live_…" -H "Content-Type: application/json" \
  -d '{ "title": "The Mekong Cookbook (e-book)", "amount": 4.5, "max_payments": 100 }'
Response
{
  "id": "plink_…",
  "url": "https://luyra.app/l/plink_…",
  "title": "The Mekong Cookbook (e-book)",
  "amount": "4.50",
  "max_payments": 100,
  "paid_count": 0,
  "active": true
}

GET/v1/payment_links/:id

DELETE/v1/payment_links/:id

Deleting a link closes it; past payments are kept.

Usage

GET/v1/usage

200 OK
{ "plan": "pro", "limit": 5000, "used": 1204, "remaining": 3796,
  "period_start": "2026-11-01T00:00:00.000Z", "period_end": "2026-12-01T00:00:00.000Z" }

Plans count paid subscription and invoice payments. One-time payments (this API and payment links) are free and unlimited, and test mode is never counted. The quota is shared by every store on the account. At zero, paying a new subscription's first invoice or a one-off invoice returns 402 quota_exceeded; renewals of existing subscriptions, one-time payments and invoices already shown to customers still work.

Telegram alerts: connect your own bot in Settings and Luyra posts payments, declined renewals and cancellations to your chat or group as they happen.

Hosted checkout

checkout_url opens a page with the store's logo, colour and support email, the QR, a countdown, a live status and Pay by card, which hands the customer to ABA PayWay's card page (local and foreign Visa, Mastercard, JCB, UnionPay) and back. A paid payment's payment_method is khqr, card or saved. When the payment ends, it redirects to the success or failure URL set on the store, adding ?status=success|failed&payment_id=…&reference_id=…. Treat the redirect as a hint only. Confirm with a webhook or GET /v1/payments/:id.

Webhooks

Events: payment.scanned, payment.completed, payment.expired, payment.failed, invoice.created, invoice.paid, subscription.active, subscription.past_due, subscription.updated, subscription.canceled, invoice.payment_failed, payment_method.attached, payment.unapplied (money PayWay took that Luyra could not apply, such as a second payment for a paid invoice, or a payment for the wrong amount: refund it in ABA PayWay; data has payment, amount, reason (invoice_void, payment_paid, amount_mismatch, …), and invoice or tran_id; an amount_mismatch also has currency and expected), and ping from Send test. Each POST carries X-Luyra-Event and X-Luyra-Signature: t=<unix>,v1=<hex>, an HMAC-SHA256 of `${t}.${rawBody}` with the endpoint's signing secret. Answer 2xx within 10 seconds. Anything else is retried up to 8 times, waiting 1, 2, 4 … 64 minutes.

Verify a signature (Node.js)
import crypto from "node:crypto";

export function verify(rawBody, header, secret) {
  const { t, v1 } = Object.fromEntries(header.split(",").map((kv) => kv.split("=")));
  if (Math.abs(Date.now() / 1000 - Number(t)) > 300) return false;
  const want = crypto.createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex");
  return v1.length === want.length && crypto.timingSafeEqual(Buffer.from(v1), Buffer.from(want));
}
Event body
{ "id": "evt_…", "type": "payment.completed", "created": 1795000000,
  "data": { "id": "Xk2…", "status": "paid", "amount": "12.50", "reference_id": "order_1042", … } }

QR renderer

GET/api/render/khqr/<qr_string>.svg

Free, no key. Draws any valid KHQR string as SVG (error correction H), cached for a year. Strings over 512 characters or with a bad CRC return 400 invalid_khqr.

Errors

Every error looks like { "error": { "code": "quota_exceeded", "message": "…" } }.

StatusCodeWhat to do
400invalid_request · idempotency_key_reused · invalid_amount · invalid_status · amount_too_low · amount_too_high · payment_link_disabled · store_not_active · invalid_khqr · test_mode_only · payway_credentials_invalid · payway_domain_not_whitelisted · payway_khqr_not_enabled · payway_cof_not_enabled · payment_link_closedFix the request. The payway_ codes mean your ABA PayWay merchant needs new keys, Luyra's domain whitelisted, or KHQR or Credentials on File enabled by ABA.
401unauthorizedMissing, invalid or revoked API key.
402quota_exceededYour plan is out of subscription and invoice payments for this period. Renewals of existing subscriptions and one-time payments are never blocked.
403account_suspendedThe account is suspended.
400invoice_not_openThe invoice is already paid or void.
409charge_in_progressA renewal charge to the saved card or account is still being processed. Retry in a few minutes.
404payment_not_found · product_not_found · price_not_found · customer_not_found · subscription_not_found · invoice_not_found · payment_link_not_found · payment_method_not_found · not_foundNo such object for this store, or unknown endpoint.
405method_not_allowedWrong HTTP method.
413payload_too_largeBody over 5 MB.
429rate_limited60 creates or 600 reads per minute per key, counted across all our servers. Wait for Retry-After.
502payment_provider_errorThe payment network did not respond. Safe to retry with the same Idempotency-Key.