Create P2P Payment

Create a deposit on the P2P rail — the depositor pays a matched withdrawer directly. Same endpoint and body as Create Slip

Same call as Create Slip

Create P2P and Create Slip both use POST /v1/p2p/public/session/create with the same body and response. This page adds how the P2P rail matches deposits with withdrawals

How the P2P rail works

The short tour: what is different from a normal deposit, what falls back to the bank, and which webhook closes the order

How to use in 4 steps

Create the payment, send the customer the link, and process the final webhook. The platform handles matching and payment instructions.

1

Create the payment

You

Same request as Create Slip: send the amount (a whole multiple of 100) and the account the customer will transfer from, plus X-Idempotency-Key — a new UUID per request; it only blocks a double submit within 5 seconds

RequestPOST /v1/p2p/public/session/create
{
  "role": "DEPOSITOR",
  "amount": 200,
  "ttl_seconds": 1200,                // link lives 20 minutes
  "profile": { "depositor": {
    "sender_bank": "SCB",          // account the customer pays from
    "sender_account": "1234567890"
  }},
  "order_id": "ODRW-322863625",
  "order_user_reference": "USER134",
  "return_url": "https://merchant.example.com/deposit/done"
}
Response — one field is all you need200
"redirect_url": "https://demo.sky777881.xyz/pay/slip/yUFSwamgJN…"
2

Send the customer the link

You

Redirect them to the returned URL, or send the link over any channel — the rest happens there.

3

Wait while the customer pays

Customeron our page

The platform matches the deposit with a withdrawal first; the customer then sees the destination account and QR, and has a set window to transfer.

Platform finds a match
Transfer 200 THBwithin 15 min
Attach the sliprejected? attach again

If no withdrawal is available, the platform can switch to a direct bank deposit within the same request. The customer pays the displayed account; a successful deposit still sends PAYMENT_PAID.

The hosted payment page: amount, countdown, PromptPay QR, and the account to transfer from
Hosted page example from Create Slip
4

Take the webhook, close the order

Platform → youPayload examples

Credit the customer once per payment, only after PAYMENT_PAID — not when the create call succeeds or the page returns to return_url

PAYMENT_PAID

Deposit successful — credit the order identified by data.payment.order_id with data.payment.payment_amount (not payment.amount), for both P2P and direct bank deposits

PAYMENT_FAILED

The slip was already used (DUPLICATE_SIGNATURE)

PAYMENT_CANCELED

Cancelled for real — the payer cancelled or an admin released the match; identify the order by data.payment.id. An expired deposit sends no webhook (since 13 Oct 2026)

Matching, waiting for payment, slip checking, expiry, and opening a dispute send no webhook. Check the status by polling GET /v1/payment/info or GET /v1/p2p/public/flow/:flowId instead of assuming silence means completion.

POSTCreate P2P Payment
Endpoint URL
https://testnet.trustsig.xyz/v1/p2p/public/session/create

Authentication Status

API Key is required for all requests Webhook Secret

Headers

x-api-key
Required

Your shop API key

x-signature
Required

HMAC-SHA256 of timestamp|method|fullUrl|body signed with your secret key, sent as 64 hex characters

How to create the signature
x-timestamp
Required

Current Unix time in milliseconds — must be the same value used to create x-signature

X-Idempotency-Key
Required

UUID ใหม่ทุก request ระบบใช้กันการส่งซ้ำภายใน 5 วินาที request ที่ซ้ำในช่วงนั้นจะได้ 409 (code 29000) และไม่ได้ response เดิมกลับมา ถ้าไม่ส่ง header นี้จะได้ 400 (code 1001)

Parameters (Request Body)

role
enum Optional

บทบาทของ session ถ้าไม่ส่งจะเป็น GENERIC ซึ่งได้สิทธิ์ถอนเงินด้วย สำหรับหน้านี้ให้ส่ง DEPOSITOR ทุกครั้ง

ttl_seconds
number Optional

อายุของ session เป็นวินาที (เช่น 1200 = 20 นาที) ถ้าไม่ส่งจะใช้ 1800 (30 นาที) ส่งได้สูงสุด 3600 ควรตั้งให้เกิน 600 เพราะถ้า session เหลือเวลาไม่ถึง 10 นาที ลูกค้าจะเริ่มรายการฝากไม่ได้ (38072)

profile.depositor.sender_bank
string Required

รหัสธนาคารของผู้ฝาก เช่น SCB, KBANK, BBL ตัวพิมพ์เล็กหรือใหญ่ก็ได้ หรือส่งเลขธนาคาร 3 หลักแทน เช่น 014 ถ้าลูกค้าจ่ายผ่านเป๋าตังให้ส่ง G_WALLET ดูรหัสทั้งหมดได้จาก GET /v1/ebank/bankConfig?purpose=payer — role DEPOSITOR ต้องส่ง profile.depositor ทุกครั้ง

profile.depositor.sender_account
string Required

เลขบัญชีธนาคารของผู้ฝาก ยาว 5–30 ตัวอักษร ถ้า sender_bank เป็น G_WALLET ให้ใส่เลขบัญชีธนาคาร 10 หลักที่ลูกค้าใช้เติมเงินเข้าเป๋าตัง ไม่ใช่เลขกระเป๋า

amount
number Optional

จำนวนเงินที่ต้องการชำระ (หน่วยเป็นบาท) ต้องเป็นจำนวนเต็มร้อย เช่น 400 หรือ 1100 ระบบตรวจยอดตั้งแต่ตอนสร้าง session ยอดอย่าง 487 จะได้ 38002 และไม่ได้ session ถ้าร้านยังใช้ยอดแบบตัวเลือก ยอดต้องตรงกับตัวเลือกใน Option List

order_id
string Optional

Your order reference, up to 200 characters. Optional, but recommended: it is attached to the deposit the customer creates from this session. While a session with the same order_id is still alive, a new one is refused with 38045. You may send it as profile.depositor.order_id instead; if both are sent, the profile value wins.

order_user_reference
string Optional

Your ID for the customer (for example the user ID in your system), not their name. Up to 200 characters, optional. A customer with this reference, or with the same sender account, who still has a transfer in progress cannot open a new session (409, 38078). You may send it as profile.depositor.order_user_reference instead; if both are sent, the profile value wins.

return_url
string Optional

URL ที่จะ redirect กลับเมื่อทำรายการเสร็จสิ้น ต้องเป็น URL เต็มที่ขึ้นต้นด้วย https:// หรือ http:// ยาวไม่เกิน 2000 ตัวอักษร

flow_id
string Optional

ใช้เปิด session ใหม่ให้รายการที่มีอยู่แล้ว เช่น เมื่อได้ 409 รหัส 38078 (ลูกค้ายังมีรายการโอนค้าง) ให้ส่ง flow_id ที่อยู่ใน data ของ error นั้น รูปแบบ p2p:<id>, classic:<id> หรือ classic-deposit:<id> ปกติไม่ต้องส่ง

display.color
string Optional

สีของหน้าชำระเงิน ส่งเป็น "สีหลัก" หรือ "สีหลัก,สีพื้น" เช่น "blue,zinc" — สีหลัก: red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose · สีพื้น: gray, zinc, neutral

display.theme
enum Optional

โหมดสีของหน้าชำระเงิน

display.name
string Optional

ชื่อร้านที่แสดงบนหน้าชำระเงิน ไม่เกิน 100 ตัวอักษร — ทั้ง display ใช้ปรับหน้าตาอย่างเดียว ไม่มีผลกับยอดหรือบัญชีปลายทาง ถ้าค่าไม่ถูกต้องจะได้ 422

Track the deposit

The customer creates the deposit on the hosted page, so the create call does not return a flow_id yet. Keep data.session_token from the response and use the two calls below.

1. Find the flow_id — POST /v1/p2p/session/lookup

Same headers as the create call. Works only while the session is alive (ttl_seconds, default 1800, max 3600) — after that it returns 404 38054, so save data.flow.flow_id as soon as it appears. data.flow is null until the customer has created the deposit.

REQUEST
POST /v1/p2p/session/lookup
Content-Type: application/json

{
  "session_token": "yUFSwamgJNkxcvWC_UY-okEzM3C9jOjSaqhMxWpEaAk"
}
RESPONSEtrimmed
{
  "data": {
    "sid": "ccb0978b-be76-49bb-a670-196705cbd0b5",
    "role": "DEPOSITOR",
    "session_status": "active",
    "expires_at": "2026-04-10T04:02:57.609Z",
    "amount": 200,
    "flow": {
      "flow_id": "p2p:6f1c2a9e-3b7d-4e21-9c55-0a8d4b1e7f30",
      "processing_channel": "P2P",
      "status": "PROCESSING",
      "data": { "id": "6f1c2a9e-3b7d-4e21-9c55-0a8d4b1e7f30", "match_status": "MATCHED" }
    }
  },
  "success": true,
  "code": 0
}

2. Poll the status — GET /v1/p2p/flow/:flowId

Reads from the database and never expires. Read data.processing_channel and data.status.

REQUEST
GET /v1/p2p/flow/p2p:6f1c2a9e-3b7d-4e21-9c55-0a8d4b1e7f30
processing_channelflow_idMeaning
P2Pp2p:<match_id>Matched with a withdrawal; the customer pays the withdrawer directly
CLASSIC_FALLBACKclassic-deposit:<payment_id>No match; the customer pays the shop account shown on the page
P2P_QUEUEqueue:<queue_id>Waiting in the queue. Once matched, the response carries a new flow_id — switch to polling that one
statusMeaning
PENDING_MATCHWaiting for a match — no action from the customer yet
PENDING_USER_ACTIONWaiting for the customer to transfer and attach the slip
PROCESSINGIn progress — matched, waiting for the transfer, or checking the slip
COMPLETEDDeposit completed
FAILEDEnded without payment — expired, cancelled, or lost a dispute
Polling is for showing progress and reconciling. Credit the customer only on the PAYMENT_PAID webhook, with data.payment.payment_amount (what was credited, may differ from payment.amount when an admin settled at the amount actually transferred — see data.amount_adjustment). An expired session sends no webhook.

Test on testnet

Close a deposit without a real transfer or slip. The platform completes it with a test slip and sends the same webhooks as production.

REQUESTtestnet only
POST /v1/p2p/acceptForTesting/6f1c2a9e-3b7d-4e21-9c55-0a8d4b1e7f30
Content-Type: application/json
X-Idempotency-Key: 0b5e1f7a-2c4d-4a8e-9f61-3d7c2e5b8a14

{}
  • :id is the part of flow_id after the prefix — the match id of p2p:<id> or the payment id of classic-deposit:<id>. The same call works for both.
  • A deposit still in the queue (queue:<id>) cannot be closed yet — wait until it is matched.
  • The body may be {}. sender_name, sender_bank and sender_account are optional overrides for the test slip.
  • Expect PAYMENT_PAID at your webhook URL. On mainnet the call is refused with 1007.

P2P errors

In addition to the common errors on the right. Body shape: see Error Codes in the Reference section.

HTTPcodeReturned byMeaning
40938045session/createThis order_id already has an active session — use a new order_id
40038002session/createAmount not accepted — not a whole multiple of 100 (e.g. 487), out of range, or amount_option sent while the shop is in free-amount mode
422—session/createA field failed validation, e.g. "display: ..." for a wrong color, theme or name
40438054session/lookupSession expired or not found — use GET /v1/p2p/flow/:flowId with the flow_id you saved