Integrate once. Accept payments everywhere.
Create a hosted checkout from your server, redirect the customer to its URL, and fulfill the order when a verified payment event arrives.
Set up your project
Ask an administrator to configure your merchant gateway, create a project, and add the exact allowed return URLs. In Developers, select that project and environment, create an API key, and register your server’s public HTTPS webhook URL. Store the API key and webhook signing secret on your server; never embed them in a customer-facing application.
Use an sp_test_ key against the test deployment and an sp_live_ key against the live deployment. The key, project and merchant must be active, and the key’s environment must match the deployment. The API base URL is the payment deployment’s origin; all integration endpoints start with /api/v1. The interactive reference uses the deployment you are viewing.
1. Create a checkout
POST /api/v1/checkouts
Authorization: Bearer sp_test_…
Idempotency-Key: order-1042
Content-Type: application/json
{
"amount_minor": 49000,
"currency": "THB",
"description": "Pro plan",
"external_order_id": "order-1042",
"locale": "en"
}Amounts are integer minor units of the currency: satang for THB, cents for USD and pence for GBP. currency defaults to THB. USD and GBP checkouts and payment links accept card payments only; PromptPay, banking apps and wallets are offered for THB. Retry uncertain requests using the same idempotency key and body. Changing the body with an existing key returns HTTP 409. The maximum supported amount is 999,999,999 minor units; merchant limits may be lower.
{
"amount_minor": 1999,
"currency": "GBP",
"description": "Pro plan",
"external_order_id": "order-1043"
}export PAYMENTS_URL="https://payments.example.com"
export PAYMENTS_API_KEY="sp_test_REPLACE_ME"
curl --fail-with-body "$PAYMENTS_URL/api/v1/checkouts" \
-H "Authorization: Bearer $PAYMENTS_API_KEY" \
-H "Idempotency-Key: order-1042" \
-H "Content-Type: application/json" \
-d '{"amount_minor":49000,"description":"Pro plan","external_order_id":"order-1042"}'const baseUrl = process.env.PAYMENTS_URL!;
const response = await fetch(baseUrl + "/api/v1/checkouts", {
method: "POST",
headers: {
Authorization: "Bearer " + process.env.PAYMENTS_API_KEY,
"Content-Type": "application/json",
"Idempotency-Key": "order-1042",
},
body: JSON.stringify({
amount_minor: 49000, description: "Pro plan",
external_order_id: "order-1042",
}),
});
if (!response.ok) throw new Error(await response.text());
const checkout = await response.json();
// Redirect the customer to checkout.hosted_url.import json, os
from urllib.request import Request, urlopen
request = Request(
os.environ["PAYMENTS_URL"].rstrip("/") + "/api/v1/checkouts",
data=json.dumps({
"amount_minor": 49000, "description": "Pro plan",
"external_order_id": "order-1042",
}).encode("utf-8"),
headers={
"Authorization": "Bearer " + os.environ["PAYMENTS_API_KEY"],
"Content-Type": "application/json",
"Idempotency-Key": "order-1042",
},
method="POST",
)
with urlopen(request, timeout=30) as response:
checkout = json.load(response)
# Redirect the customer to checkout["hosted_url"].Creation returns HTTP 200, including an idempotent retry. The same key retrieves the current resource, so its status may have changed. Idempotency keys are scoped to project, environment and operation and must contain 1–200 characters. A project/environment can have only one checkout for an external_order_id.
Errors and request limits
Errors have the shape {"error":{"code":"invalid_request","message":"…"}}. Correct validation errors (400), credentials (401), missing resource IDs (404), and state conflicts (409) before retrying. JSON bodies are limited to 32 KB (413). The project limit is 120 requests per minute; on 429 wait one minute. There is no Retry-After header.
Retry network failures and transient 5xx responses with bounded exponential backoff, retaining the original creation key and body. Persistent 503 responses can mean payments are disabled or the deployment environment needs configuration. A timeout does not prove creation failed.
2. Redirect the customer
Use the returned hosted_url. Customers choose PromptPay or an enabled wallet or card. Creating a checkout does not create a QR or charge. Wallet sources are created on the server before charging. Customers return here after wallet authorization; only a verified payment event confirms payment. Return URLs must exactly match your configured project URLs.
Retrieve or cancel a checkout
curl --fail-with-body "$PAYMENTS_URL/api/v1/checkouts/CHECKOUT_UUID" \
-H "Authorization: Bearer $PAYMENTS_API_KEY"curl --fail-with-body -X POST "$PAYMENTS_URL/api/v1/checkouts/CHECKOUT_UUID/cancel" \
-H "Authorization: Bearer $PAYMENTS_API_KEY"Read status to recover missed events: paid confirms payment; created and pending are not successful payment. Cancellation requires previous payment attempts to be confirmed closed. A paid checkout returns already_paid (409); an unresolved payment can return payment_in_progress or outcome_unknown (409). Cancel does not require an idempotency key.
Bank app payments (KGP)
K PLUS, Krungsri (BAY), Krungthai (KTB), and SCB can be enabled per PGW live account after contract verification and mobile UAT. Enabled test banks can be tried before mobile UAT. Desktop checkout creates the bank payment and displays a QR code for the approved bank link, with the selected bank’s logo. Customers scan with their phone camera to open the bank app, while desktop checkout waits for payment confirmation. Mobile customers open their selected bank app. Card payments continue through Omise.js.
Bank methods use server-created bill-payment charges. A return to checkout or an authorization redirect does not prove payment. Pending or uncertain bank attempts block another payment until KGP inquiry confirms closure. Staff can request full and partial BAY, KTB, and SCB refunds. K PLUS refunds are unsupported.
Configure account limits, the merchant logo, approved redirect origins and verified final inquiry states in Settings. Register the account’s App Switch callback at /api/kgp/ACCOUNT/app-switch on your HTTPS deployment after deployment is approved. ACCOUNT is the gateway account UUID or its configured callback name. QR uses /api/kgp/ACCOUNT/qr, ODD uses /api/kgp/ACCOUNT/odd, and all PGW refunds use/api/kgp/ACCOUNT/refund. Previous names and UUID URLs remain valid. New bank methods are disabled by default.
Wallets and retries
Cards and wallets share the KPN/Omise webhook at /api/omise/ACCOUNT_ID, including refunds. Supported wallets: TrueMoney, ShopeePay, LINE Pay, and WeChat Pay. Wallet amounts start at THB 20; TrueMoney allows up to THB 50,000 and the other wallets up to THB 150,000, subject to account limits. Cards support THB 20–150,000, and USD or GBP from 1.00 when your KPN account is enabled for that currency. Card details are entered in Omise’s secure form; only a single-use token reaches this application. Card payments capture immediately and may require bank verification.
Customers can retry or switch on the same checkout for 24 hours. A new payment starts only after the previous attempt is confirmed closed. Pending wallet or card payments may need to expire before switching. An attempt failure does not close the order or emit payment.failed; the checkout remains pending while retries are available.
Checkout responses and events include payment_method and provider. Events also identify the payment attempt. Fulfill once per checkout, even when several attempts or event deliveries exist.
3. Verify payment events
HMAC-SHA256(webhook_secret, timestamp + "." + raw_body) x-syndicate-timestamp: UNIX_SECONDS x-syndicate-signature: HEX_DIGEST x-syndicate-event-id: EVENT_UUID
Compare signatures in constant time and reject timestamps more than five minutes old. In one database transaction, deduplicate the event ID, verify the project, environment, order and amount, and fulfill the order once.
import { createHmac, timingSafeEqual } from "node:crypto";
// Read once, before JSON.parse. Use your endpoint's signing secret.
const rawBody = await request.text();
const timestamp = request.headers.get("x-syndicate-timestamp") || "";
const signature = request.headers.get("x-syndicate-signature") || "";
const fresh = /^[0-9]+$/.test(timestamp)
&& Math.abs(Date.now() / 1000 - Number(timestamp)) <= 300;
const expected = createHmac("sha256", process.env.PAYMENTS_WEBHOOK_SECRET!)
.update(timestamp + "." + rawBody).digest("hex");
const a = Buffer.from(expected), b = Buffer.from(signature);
if (!fresh || a.length !== b.length || !timingSafeEqual(a, b)) {
return new Response("Invalid signature", { status: 401 });
}
const event = JSON.parse(rawBody);
// Validate identity, environment, version, order, currency and amount.
// Transaction: deduplicate event.id, lock order, fulfill once, then commit.
// Return 2xx after commit; return 5xx on transient processing failure.Reject timestamps more than five minutes in either direction. Verify api_version, project_id, merchant_id and environment against your configured integration. Match data.external_order_id, currency and amount against your server-owned order. Acknowledge duplicates with 2xx, and record the processed event and fulfillment in the same transaction.
Delivery and recovery
Events may arrive more than once or out of order. Use resource versions and stable event IDs. Failed delivery retries continue for up to 72 hours. Administrators can replay deliveries in the dashboard.
Events
payment.succeeded payment.failed payment.expired payment.canceled refund.pending refund.succeeded refund.failed
A late verified payment may follow an expired event. Payment success is authoritative. Refunds have independent resource versions and do not reopen a checkout.
Payment and refund payloads
Every event includes id, type, api_version, created_at, environment, project_id, merchant_id and data. For payment events, data.id is the checkout ID, data.amount_minor is the checkout amount, and payment.succeeded carries status paid. For refund events, data.id is the refund ID, data.checkout_id identifies the original checkout, and data.amount_minor is the refund amount. refund.succeeded carries status success. Each resource has its own version; compare versions only within that resource.
Both payloads include attempt_id, payment_method, provider, external order/customer IDs and metadata. Full examples and schemas are in the API reference.
Capture and refunds
Capture and refund initiation require staff access through the dashboard. They are not operations in /api/v1. Applications can receive refund events to update their own records.
API-created test checkouts accept capture_mode: "manual" for cards. Authorization leaves payment pending until an administrator captures it in payment details. Manual capture remains test-only pending KPN UAT. Omit capture_mode for automatic capture. Card refunds offer automatic, void-only and refund-only processing, subject to provider eligibility.
Payment links
curl --fail-with-body "$PAYMENTS_URL/api/v1/payment-links" \
-H "Authorization: Bearer $PAYMENTS_API_KEY" \
-H "Idempotency-Key: link-pro-plan" \
-H "Content-Type: application/json" \
-d '{"amount_minor":49000,"description":"Pro plan","usage":"reusable"}'curl --fail-with-body "$PAYMENTS_URL/api/v1/payment-links/LINK_UUID" \
-H "Authorization: Bearer $PAYMENTS_API_KEY"curl --fail-with-body -X PATCH "$PAYMENTS_URL/api/v1/payment-links/LINK_UUID" \
-H "Authorization: Bearer $PAYMENTS_API_KEY" \
-H "Content-Type: application/json" \
-d '{"active":false}'Share the returned url. Set active to true to reactivate a link. Updates do not require an idempotency key and do not cancel existing checkouts. Optional expires_at must be a future timestamp with timezone.
Create single_use or reusable links through POST /api/v1/payment-links or in the dashboard. A link visit does not create a QR; the customer explicitly starts payment. Single-use links retain one checkout permanently, including after a full refund.
Reference
Download the OpenAPI specification. A server-side TypeScript example is included in examples/saas-integration.ts, and a Python example with signature verification is in examples/saas-integration.py.