Supported sandbox payment API
Use https://api.sandbox.p2peasypay.com with a test key and the existing request signing scheme. Your operator must enable a simulator-capable release first. Objects carry livemode: false and environment: "sandbox".
Current simulator scope
Test balances, API-driven payment outcomes and signed callbacks to configured test endpoints are supported. Hosted TEST checkout can show current simulated order status. It does not provide a real bank destination, payment QR or slip intake. Passing these tests does not establish live-payment readiness. The 100.00–116.00 table in the sandbox design is an advanced target, not this execution profile's verified scenario catalog.
- Prepare isolated test fundsPOST /
v1/ pay/ sandbox/ topups Use test permissions; payouts must have enough available test balance for principal + fee. - Create a test payin or payoutPOST /
v1/ pay/ deposits or / v1/ pay/ withdrawals Whole THB 1–10,000,000; send integer satang as amount_minor (100–1000000000). Save the original body and Idempotency-Key. - Amount in THB selects the result at creationAutomatic magic amountsResult occurs during CREATE1,001–2,000 → both settled 2,001–3,000 → both rejected 3,001–4,000 → payin reversed; payout rejected 4,001–5,000 → both expiredORAll other amountsPayin awaiting_payment / payout openPOST /
v1/ pay/ sandbox/ deposits/ { id}/ simulate Payin: succeed / fail / expire. Payout uses /v1/ pay/ sandbox/ withdrawals/ { id}/ simulate: succeed / fail only. Terminal orders → 409 sandbox_ transaction_ not_ pending. - Inspect the resulting test stateGET order by ID · GET /
v1/ pay/ events Read test balance too. Payin 3,001–4,000 settles at version 1 then reverses at version 2 in one transaction, for zero net wallet credit. - Verify test webhooks when configuredlivemode: false · environment: sandboxRequires the scheduler and signing keyring. Dedupe event ID and guard versions; event delivery may repeat or arrive out of order.
First test
- Create a test API key from API Keys in an authoritative test Merchant session. Select the necessary
deposits:read/,write withdrawals:read/,write wallet:readandsandbox:writescopes. Onlysandbox:writeis Test-only. Live payment and wallet grants follow the Live P2P profile. - Call
POST /withv1/ pay/ sandbox/ topups {and an"amount_ minor":10000000,"currency":"THB"} Idempotency-Key. - Create a transaction using
POST /orv1/ pay/ deposits POST /, retaining our field names, signatures and integer minor units.v1/ pay/ withdrawals - Read
GET /, the transaction by ID andv1/ pay/ balance GET /. Page events usingv1/ pay/ events since_sequenceandlimit.
Retries use a fresh nonce and signature but the original mutation body and idempotency key. A changed body with the same key returns 409 idempotency_key_reused without another wallet effect or event.
Deterministic outcomes
| Amount in THB | Deposit | Withdrawal |
|---|---|---|
| 1,001–2,000 | settled | settled |
| 2,001–3,000 | rejected | rejected |
| 3,001–4,000 | reversed | rejected |
| 4,001–5,000 | expired | expired |
| Other amounts, including above 5,000 | awaiting_payment | open |
Whole THB amounts (amount_minor % 100 == 0) from 1 to 10,000,000 (100–1000000000 minor units) per request are supported. Fees default to zero. When versioned Sandbox controls are enabled, the Merchant owner can configure test-only fees for new orders as described below. Automatic outcomes are applied during creation without a delayed callback. A reversed deposit settles at version 1 then reverses at version 2 in the same transaction, recording opposite ledger entries and both events. Its final net wallet effect is zero.
Complete a pending deposit using POST / with {"outcome":"succeed"}, {"outcome":"fail"} or {"outcome":"expire"}. The matching withdrawal path accepts only succeed or fail. Both sandbox:write and the corresponding transaction write scope are required. Final transactions return 409 sandbox_.
Withdrawals reserve the principal plus the order's pinned test fee on creation. Insufficient funds return 402 insufficient_balance; success consumes the reservation and failure releases it back into the available balance.
Cancel a pending test deposit
POST / requires the exact { "reason": "..." } body, normal HMAC, deposits:write and an idempotency key. Only an own awaiting_payment deposit in the active run is eligible in the supported D06 profile. Source alone does not establish deployment availability; check the deployment evidence. It preserves the fee/run snapshot and records canceled / outcome: cancel with an immutable deposit.canceled event. Wallet balances do not change and no refund ledger entry is invented. New archive commands return 409 sandbox_; retained exact replay recovers its original receipt before quota/cleanup. No magic amount or simulate outcome is added. Upgrade SDK/UI readers before use; see deposit cancellation.
Cancel an open test withdrawal
POST / with the exact { "reason": "..." } body, normal HMAC, withdrawals:write and an idempotency key releases the active run's original principal-plus-fee reservation. It records canceled / outcome: cancel and an immutable signed withdrawal.canceled event. This is not a new magic amount or simulate option. Archived orders cannot credit a new run. Upgrade closed-enum SDK/UI readers before using it; see withdrawal cancellation.
Test webhooks
Configure an endpoint in the Merchant test session before creating new events. The scheduler signs pinned canonical payload bytes with Ed25519 using the existing webhook verification scheme. Callbacks include X-Environment: sandbox, livemode: false and environment: "sandbox". Scheduler and signing keyring configuration are required; existing events are not backfilled. Deduplicate event IDs and compare transaction versions because delivery may be duplicated or reordered. Failed delivery uses the existing 11-attempt retry schedule.
The Merchant test backoffice Sandbox Tools page can top up this same wallet and complete pending transactions using an employee session with sandbox_tools:write. No API key is entered into the page.
Callback history shows delivery status and bounded attempt details, with all, pending and failed filters. It exposes endpoint hostname/version without payloads or secrets. Manual resend is unavailable. Its cookie-authenticated read endpoint is GET / with sandbox_tools:read. Opaque cursors expire after 15 minutes and bind the employee, scope, filter and page size. The inventory cutoff stays fixed while delivery statuses remain current.
Versioned test fees and runs
These controls are available only when the server advertises sandbox_activity_v2 to the linked Merchant owner in their own TEST home. They require the existing Sandbox Tools permissions and a fresh request-bound OIDC confirmation. Parent, Live and other employee-role sessions cannot use them. The zero-fee default remains compatible with existing integrations.
In Sandbox Tools, fee publication creates a new immutable fee version. Both Payin and Payout use floor(amount_minor × variable_bps / 10000) + fixed_minor. Rates range from 0 to 10000 bps and fixed fees from 0 to 1000000000 minor units. Payin fees are capped at the principal; settlement credits principal minus fee. A reversal removes that exact original net credit and reverses the original fee recognition. Payout reserves and consumes principal plus fee, and releases both on failure or expiry. There is no simulated VAT or commission. Each new order pins its fee version; publishing a new policy never reprices existing orders.
Start a new run archives the current run and starts its available and reserved test balances at zero. It preserves prior orders, statuses, events, ledger entries, delivery attempts and immutable receipts. API keys, endpoints, fee settings and shared quotas are retained. The original idempotent create receipt remains byte-identical, and reading an old public order still returns its stored state. Attempting to simulate an archived pending order returns 409 sandbox_. Reusing a merchant reference is allowed in a different run; idempotency keys remain shared across runs.
Reset uses the current control version, run generation and wallet version. An unexpired callback network lease returns 409 sandbox_ without changing the run. Refresh and explicitly retry after it finishes. An allowed reset cancels remaining old-run pending delivery work, but a POST that already started can still arrive; reset cannot unsend a network request.
The backoffice routes are cookie-authenticated and never accept an API secret:
| Method | Route | Purpose |
|---|---|---|
| GET | / | Versions, current wallet, callback lease count and the six-band amount guide |
| PUT | / | Publish the Payin/Payout test fee policy |
| POST | / | Archive this run and start the next one |
Writes require strong If-Match, Idempotency-Key, same-origin headers and X-Step-Up-Token. Protected operations are sandbox.fees.publish and sandbox.run.reset. Bind the proof to operation, method, concrete path, expected version and the exact body. Success/replay returns a strong version ETag and Idempotent-Replay: false|true; a replay is the original receipt, so refresh the control read to display the current state.
Activity reads under / cover dashboard, deposits, withdrawals, details, reports and statement. By default each Merchant contributes its own active run; an Agent aggregate has no single global generation. Selecting run_generation reads one authorized Merchant's archived run in read-only mode. Parent sessions also provide merchant_scope_id for archive selection. Coverage remains limited by retained history, with nullable balance anchors where data is unavailable. Inventory changes invalidate the bound cursor with 409 sandbox_; restart the read rather than joining incompatible pages. These separate v2 DTOs do not add fields to the strict public payment v1 objects or their stored callback payloads.
Limits
- Payment API and Tools share 60 requests per minute, including reads, and 500 new transaction/topup creations per UTC day per Merchant. Daily limits do not block reading or completing existing pending transactions.
- Lazy 30-day history and receipt cleanup. Pending reservations are retained until resolved; receipt replay is not guaranteed beyond retention.
- Customer persistence, manual webhook replay and advanced slip scenarios remain unavailable. Versioned fee/reset controls require the separate profile below; they are not available through the public payment API. Unsupported payment routes return
SANDBOX_UNSUPPORTED. - Always validate the response environment and separate test handlers from live money processing.