Skip to content
API documentationP2P EasyPay

Get started ​

Create a Payin once. Send the customer to our PayPage, or use the returned payment instructions in your own checkout.

1. Set your API key ​

Get your API origin and key from the Merchant back office. Use the matching Sandbox hostname and key for testing. Set PG_API_ORIGIN and PG_API_KEY in your server's secret manager.

Download the helper into your server project. No npm package is needed:

2. Test your key ​

js
import { clientFromEnv } from './client.mjs';
const client = clientFromEnv();
const result = await client.authenticate();
if (!result.ok) throw new Error(result.data?.error?.code ?? 'api_error');
// result.data.available_minor is the available balance in satang.

The helper handles Bearer authentication and HMAC signing. There is no additional login or access-token request.

3. Create a Payin ​

js
// Save this key with the order before sending. Keep the same body/key for retries.
const request = client.payin({
  amount_minor: '10000', // THB 100
  currency: 'THB',
  merchant_reference: 'ORDER-1001',
  end_user_ref: 'customer-1',
  sender: {
    bank_code: '002',
    account_number: '1234567890',
    account_name_th: 'สมชาย ใจดี',
  },
}, 'order-1001-payin');
// orderStore is your application's order storage. Persist before the first send.
await orderStore.saveRequest('ORDER-1001', {
  method: request.method, path: request.path, query: request.query,
  rawBody: request.rawBody, idempotencyKey: request.idempotencyKey, apiVersion: request.apiVersion,
});
const result = await request.send();
if (!result.ok) throw new Error(result.data?.error?.code ?? 'api_error');
// Pass only the required fields into this customer's secure checkout session.
// Do not log result.data: it contains payment information and capabilities.

Replace sample identity fields with the real permitted sender for that mode. Use bank codes confirmed by your service provider. No customer or bank lookup API is required first.

4. Choose your checkout ​

OptionNext step
Our PayPageRedirect to the returned checkout_url. PayPage handles waiting, payment instructions, and slip upload.
Your checkoutRender legs[] when status = awaiting_payment, then upload the slip.

PayPage starts with a ready-to-use default. Optionally open Merchant back office → Settings → PayPage Editor (/settings/paypage) to preview/save your display name, subtitle, accent color, background color, and corner radius. No theme selection or code is required.

Display name and subtitle cannot contain invisible formatting/direction controls or runs of 6 or more digits. Merchant text appears separately from the system payment instructions.

On LIVE, 201 awaiting_payment means a match exists: use only current, unexpired payment data. 202 awaiting_liquidity means the order exists but has no destination yet. Your own checkout must poll GET /v1/pay/deposits/{id} with backoff until expires_at, then obtain slip-token when payable as described in Payin. Do not wait for a matching webhook or ask the customer to transfer early. checkout_url requires PayPage configuration for this Merchant and mode.

Sandbox 201 has no real transfer legs[], upload capability, or slip-token. Use POST /v1/pay/sandbox/deposits/{id}/simulate or the amount ranges in Sandbox payments. Do not transfer real money.

LIVE emits only deposit.settled, deposit.canceled, withdrawal.created, withdrawal.partial_fill, and withdrawal.terminal; see the Live P2P profile. Use GET for readiness, under_review, rejected, and expired transitions. Confirm funds from verified settled evidence. A successful create, slip intake, or return from PayPage does not prove payment.

Six guides ​

GuideEndpoint
AuthenTest with GET /v1/pay/balance
PayinPOST /v1/pay/deposits
Payin upload slipPOST /v1/pay/deposits/{id}/slip at the returned URL
Payin cancelPOST /v1/pay/deposits/{id}/cancel
PayoutPOST /v1/pay/withdrawals
Get Merchant BalanceGET /v1/pay/balance
Amounts, retries, and final results
  • The helper accepts positive integer minor units as a number or canonical decimal string: 10000 or '10000', sending a JSON integer. Maximum: 9007199254740991. Payin must be whole baht (amount_minor % 100 == 0) and meet provider policy. Sandbox accepts whole baht from THB 1 to 10,000,000 (100–1000000000 minor units) per request.
  • Persist each POST key before sending. Retry the same prepared request.send(); the helper generates a fresh nonce/signature. It does not automatically retry.
  • Store the exact JSON text in request.rawBody as text/bytea, not JSONB, with method/path/query/key/API version before the first send. Protect retained PII. After restarting, use client.rebuild(await orderStore.loadRequest('ORDER-1001')), then send(). Never parse/re-serialize the body or generate a new key after a timeout.
  • Slip intake 202 accepts evidence. Wait for settled before confirming funds; see LIVE results and status reads.
  • PHP and curl · Detailed existing contract

เอกสารชุดนี้อิงสัญญา API เวอร์ชัน 2026-08-01