Skip to main content
Back to all insights
ระบบฝาก-ถอนออโต้ API2026-12-05·12 min read

Sandbox UAT and Pre-Launch Sign-Off Matrix for Automated Pay-In and Payout APIs

Why single happy-path Sandbox tests cause Friday-night 401 failures, duplicate withdrawals, and support blind spots, plus the 10-case UAT matrix and 4-role sign-off framework.

Reviewed by the SF PayGate Payment Engineering & Reconciliation Desk · Updated December 2026

Sandbox UAT and Pre-Launch Sign-Off Matrix for Automated Pay-In and Payout APIs

Summary

Launching an automated pay-in and payout API infrastructure after running a single happy-path Sandbox deposit is the leading cause of Friday-night 401 signature errors, duplicate payouts on retry, and unmapped fee ledgers. A production-grade User Acceptance Testing (UAT) cycle exercises failure paths across signing, active-order locks, three-way slip fallbacks, 5x concurrent payout retries, and settlement previews, backed by written sign-off from Engineering, Finance, Support Operations, and your Go-Live Approver.

01Why happy-path Sandbox testing fails on Friday night

Across high-concurrency platforms, the same anti-pattern repeats constantly: a backend developer wires up Sandbox keys on Thursday afternoon, runs one 500 THB deposit with ASCII-only fields, sees HTTP 200 and a payment link, and marks the task complete. On Friday evening, right before peak weekend traffic, the team switches keys to production.

Within minutes, three failures collide. Inbound webhooks fail with HTTP 401 because real player names contain Thai UTF-8 bytes that an upstream JSON parser re-serializes before hashing. Impatient players tapping deposit twice hit an unhandled active-order lock instead of recovering their open payment page. Worst of all, a brief network timeout triggers an application retry loop that invents new withdrawal references and drains treasury float.

Meanwhile, night-shift support has never opened the merchant portal, lacks a trace ID workflow, and floods chat rooms with cropped screenshots, while Finance discovers Monday morning that fee columns never matched their ledger. Preventing this requires joint Sandbox UAT sign-off across three leads — Engineering, Finance/Reconciliation, and Support Operations — under final authorization from your Go-Live Approver.

02Outbound and inbound cryptographic signing verification

UAT starts with credential separation and bidirectional signature checks. SF PayGate separates `X-API-Key` from your Signing Secret by design: `X-API-Key` identifies your account in request headers and appears in proxy logs, whereas the Signing Secret never crosses the network and stays server-side to compute digests. Verify both live in separate vault entries and never leak into error logs.

On outbound calls to SF PayGate, gateway middleware strips the leading `/api` prefix before checking `X-Signature`. Calling `POST /api/v2/payins` requires signing `/v2/payins`, and `GET /api/me/balances` requires signing `/me/balances`. Run a negative test signing `/api/v2/payins` or sending an expired `X-Timestamp` in Sandbox to verify your client logs the 401 cleanly and halts without blind retries.

On inbound callbacks, follow the HMAC-SHA256 webhook signature specification over raw unparsed bytes before JSON parsing runs. Enforce an `X-Timestamp` freshness window on NTP-synced hosts, compute the digest over `${timestamp}:${rawBody}`, and compare via constant-time `crypto.timingSafeEqual` or `hash_equals` using realistic Thai and Chinese UTF-8 customer fixtures.

03Deposit scenarios, active-order locks, and sender binding

Begin deposit UAT by binding player bank accounts via `POST /api/v1/customers/{id}/accounts` across SF PayGate's 18 Thai banks and 12 Hong Kong FPS banks. The returned UUIDv7 `customer_account_id` enforces first-party sender matching on deposits and withdrawals. Test both a verified first-party transfer and an unbound third-party transfer so Operations sees mismatched funds quarantined rather than auto-credited.

Next, exercise the automated deposit v2 endpoint specification via `POST /api/v2/payins` to receive `paypage_url`, then immediately tap deposit a second time while the order remains unpaid. Active Payin Protection returns `PAYIN_ACTIVE_EXISTS`; verify your cashier re-opens the active `paypage_url` or cancels the pending order via `POST /api/v2/payins/{id}/cancel` before creating a new amount.

Validate amount bounds at both UI and API layers: standard THB deposits span 50 to 45,000 THB, and channels enforcing multiples of 100 THB must reject out-of-range inputs like 20 THB, 50,000 THB, or odd denominations with clear player guidance. Confirm expired and cancelled orders incur 0 fees, while completed deposits book exact agreed rates (2.5% THB or 3.5% HKD FPS).

04Three-way confirmation and transfer slip replay drills

Relying solely on instant webhook delivery leaves cashiers exposed whenever a proxy restarts or bank alerts lag during weekend peaks. SF PayGate pairs signed webhooks with two independent fallback layers, and Sandbox UAT must deliberately break Layer 1 so Engineering and Support prove Layers 2 and 3 recover orders without manual wallet edits.

Execute the Webhook 504 Drill first: configure your staging webhook endpoint to return HTTP 504 on the first two deliveries of a paid Sandbox order, then HTTP 200 on the third. Confirm SF PayGate retries automatically until HTTP 200, and verify that when webhooks stay blocked, your poller reconciles state via `GET /api/v1/payins/{id}` while unique constraints credit the wallet once.

Next, test Layer 3 via `POST /api/v1/payins/{id}/slip`, which verifies bank QR payloads against bank records (never relying on spoofable OCR) and stores a permanent `slip_hash`. Run four UAT slip cases: a valid slip resolving a delayed order, a cropped unreadable QR, a genuine slip with the wrong amount, and a replay of an already-verified slip on a second order — confirming all three invalid cases credit zero funds.

05Withdrawal idempotency and Smart Withdraw chaos drills

Deposit bugs delay credit, whereas withdrawal bugs cause irreversible cash loss on push-payment rails. Integrating the idempotent Smart Withdraw payout API requires persisting a unique `merchant_ref_id` and locking withdrawable player funds inside an ACID transaction before calling `POST /api/v1/payouts` (standard THB range 100 to 45,000 THB).

Prove timeout safety with the 5x Concurrent Retry Drill: force an HTTP timeout on `POST /api/v1/payouts`, then launch five concurrent retries carrying that exact `merchant_ref_id`. UAT passes only when all five calls return the single existing payout `id`, one transfer enters the 24/7 queue, and retry workers never append suffixes like `-retry2`.

Test Smart Withdraw multi-step callbacks alongside `GET /api/v1/payouts/{id}` across `queued`, `processing`, and `succeeded` or terminal `failed`. Verify `processing` updates never double-deduct balances, duplicate `succeeded` callbacks are ignored, and holds release only when both the terminal callback and `GET /api/v1/payouts/{id}` confirm permanent failure — booking the 1.0% fee strictly on completed transfers.

06Pre-settlement previews and operational support endpoints

Treasury sweeps and support escalations break under weekend load if left out of UAT. Finance and Engineering must jointly validate the merchant account operations endpoints starting with `GET /api/me/balances` and `GET /api/me/limits`, verifying backoffice views separate `available_amount` from `pending_amount` per currency and enforce active ceilings.

Before live sweeps, Finance must rehearse `POST /api/v1/settlements/preview` to verify gross, fee, and net figures prior to calling `POST /api/v1/settlements` or intra-group transfers via `POST /api/v1/organization-settlements` with dual-side ledger entries. While API settlement queues run 24/7 without T+1/T+2 holds, Finance SOPs must note Portal USDT (TRC20) settlements run daily 14:00–22:00 UTC+7, queuing after-hours submissions for 14:00 next day.

Support leads must practice raising tickets via `POST /api/me/issues` linked to a Sandbox order `id` and storing the returned `request_id`. On live night shifts, agents share that `request_id` via Telegram `@SFPayGateAgent` for instant tracing rather than pasting raw payloads or credentials in chat.

07Automating regression checks with a Sandbox smoke runner

Hand-editing timestamps and signatures in Postman invites mistakes right before launch. Turning core UAT assertions into a repeatable smoke script verifies stripped `/api` signing, active-payin locking, 5x concurrent payout idempotency, balance checks, settlement previews, and issue creation in seconds on every staging build.

Aligned with the developer API integration reference, the TypeScript runner below isolates `SFP_SANDBOX_API_KEY` from `SFP_SANDBOX_SIGNING_SECRET`, signs stripped paths (`/v2/payins`, `/v1/payouts`, `/me/balances`), checks `PAYIN_ACTIVE_EXISTS` before calling `/cancel`, and fires five parallel payouts sharing one `merchant_ref_id`.

Run this script in CI whenever cashier, wallet, webhook, or treasury code changes, and attach its output to your Engineering UAT sign-off ticket. Rerunning it after proxy, WAF, or runtime upgrades catches subtle serialization regressions early.

import crypto from "node:crypto";

const BASE = process.env.SFP_SANDBOX_BASE_URL!; // issued at onboarding
const KEY = process.env.SFP_SANDBOX_API_KEY!;
const SECRET = process.env.SFP_SANDBOX_SIGNING_SECRET!;

async function sfp(method: string, pathNoApi: string, body?: unknown) {
  const raw = body ? JSON.stringify(body) : "";
  const ts = Math.floor(Date.now() / 1000).toString();
  // Strip /api when signing: sign /v2/payins for POST /api/v2/payins
  const sig = crypto.createHmac("sha256", SECRET).update(`${method}:${pathNoApi}:${ts}:${raw}`).digest("hex");
  const res = await fetch(`${BASE}/api${pathNoApi}`, {
    method,
    headers: { ...(raw ? { "Content-Type": "application/json" } : {}), "X-API-Key": KEY, "X-Timestamp": ts, "X-Signature": sig },
    body: raw || undefined,
  });
  return { status: res.status, data: await res.json().catch(() => ({})) };
}

export async function runUatSmoke(customerId: string, accountId: string) {
  const baseIn = { currency_code: "THB", request_amount: 1000, customer_id: customerId, customer_account_id: accountId, redirect_url: "https://staging.merchant.local/return" };
  const p1 = await sfp("POST", "/v2/payins", { ...baseIn, merchant_ref_id: `uat-in-${Date.now()}` });
  const p2 = await sfp("POST", "/v2/payins", { ...baseIn, merchant_ref_id: `uat-dup-${Date.now()}` });
  console.assert(p2.data?.code === "PAYIN_ACTIVE_EXISTS", "Expected active lock");
  await sfp("POST", `/v2/payins/${p1.data.id}/cancel`);

  const outRef = `uat-out-${Date.now()}`;
  const runs = await Promise.all(Array.from({ length: 5 }, () => sfp("POST", "/v1/payouts", { merchant_ref_id: outRef, currency_code: "THB", request_amount: 500, customer_id: customerId, customer_account_id: accountId })));
  console.assert(new Set(runs.map((r) => r.data?.id)).size === 1, "Expected 1 payout id");

  await sfp("GET", "/me/balances");
  await sfp("POST", "/v1/settlements/preview", { currency_code: "THB", request_amount: 10000 });
  const issue = await sfp("POST", "/me/issues", { order_id: p1.data.id, category: "UAT_DRILL", summary: "Trace check" });
  return issue.data?.request_id;
}

08Comprehensive 10-case Sandbox UAT execution matrix

Credible UAT reconciles three views side by side for every case: the SF PayGate Portal, your Game Wallet state machine, and Finance's immutable ledger. If a Sandbox deposit shows `succeeded` in the portal and credits 1,000 THB in the wallet, but Finance misses the 25 THB fee line, UAT has not passed.

Run all ten scenarios below in a joint session with Engineering, Finance, and Support. Never skip negative scenarios (`UAT-04`, `UAT-06`, `UAT-07`), as boundary errors, bad slips, and third-party transfers generate most first-month support tickets.

Log the Sandbox `id`, `merchant_ref_id`, HTTP status, and timestamp per row so Support agents can practice backoffice lookups and `request_id` escalations before live traffic begins.

Test Case IDScenarioExpected Portal StateExpected Game Wallet StateExpected Finance Ledger Entry
UAT-01Outbound `/v2/payins` signed properly vs unstripped `/api/v2/payins`Valid call creates order; unstripped call rejected 401PayPage opens on valid call; clean error with no retry loop on 401Zero balance or fee entries
UAT-02Bound sender 1,000 THB deposit (`POST /api/v2/payins`) paidMoves `pending` -> `succeeded` with matched senderCredited +1,000 THB once after raw-body HMAC passGross +1,000 THB, fee 25 THB (2.5%), net +975 THB
UAT-03Double-tap hitting `PAYIN_ACTIVE_EXISTS`, then `POST /api/v2/payins/{id}/cancel`Single active order kept; moves to `cancelled`Re-opens active `paypage_url`; unlocks new amount after cancel0 THB fee and zero ledger change
UAT-04Bounds check: 20 THB, 50,000 THB, and non-100-multipleRejected 400/422 outside THB 50–45,000 or denomination ruleUI blocks invalid input with clear range hintNo order or fee written
UAT-05Webhook 504 timeout + `GET /api/v1/payins/{id}` fallback pollLogs 504 retries then 200 OK; order `succeeded`Credited once via poll or retry; duplicate ignoredSingle credit keyed on gateway `id`
UAT-06`POST /api/v1/payins/{id}/slip`: valid vs cropped, wrong amount, replayValid verifies `BANK_QR_RECORD` & `slip_hash`; 3 bad rejectedValid credited once; 3 invalid slips credit 0Valid books net credit; bad slips in audit log only
UAT-07Unbound third-party bank sender vs `POST /api/v1/customers/{id}/accounts`Flagged as sender mismatch on `customer_account_id`Auto-credit blocked; prompts support contactQuarantined in exception bucket
UAT-08Timeout + 5 concurrent retries on `POST /api/v1/payouts` with same `merchant_ref_id`Single payout `id` created (THB 100–45,000)Single pre-call hold persisted; zero duplicate payoutsSingle principal debit + 1.0% fee on `succeeded`
UAT-09Smart Withdraw callbacks (`queued` -> `processing` -> terminal `failed`)Sequential logs; `failed` confirmed via `GET /api/v1/payouts/{id}`Hold kept during `processing`; refunded once on failureHold reversal posted; 0 THB fee
UAT-10`GET /me/balances`, `/me/limits`, `/v1/settlements/preview` -> `/v1/organization-settlements` + `/me/issues`Preview matches execution; dual-side org ledger; returns `request_id`Isolated from player walletsNet settlement and org transfer tied out to exact satang
10-Case Sandbox UAT Matrix Across Portal, Game Wallet, and Finance Ledger

09Four-role sign-off responsibility and security hardening

Passing code tests still leaves operational exposure if portal permissions, IP allowlists, and night-shift playbooks remain unverified. Splitting sign-off across four roles prevents Engineering from self-certifying Finance math or Security controls.

Your Security/Admin Go-Live Approver must verify platform IP allowlisting and access controls before releasing production keys: lock egress IPs on API and Portal allowlists, enforce 2FA on 100% of portal seats, and set menu/CRUD RBAC so Support queries orders and files `/me/issues` without seeing secrets or initiating settlements.

Attach sign-off evidence from all four leads below to your release ticket before switching URLs to production. Any gap goes back to Sandbox first.

Sign-Off RoleMandatory Sandbox VerificationsProduction Hardening GateSign-Off Deliverable
Engineering LeadStripped `/api` signing, raw-body HMAC, `PAYIN_ACTIVE_EXISTS`, 5x `merchant_ref_id` retry, 3-way confirmationSeparate `X-API-Key` & Secret vaults, NTP alerts, zero logged secrets, async webhook queueGreen smoke-runner log (`UAT-01` to `UAT-09`)
Finance Lead2.5% THB / 3.5% HKD pay-in & 1.0% payout fees, 0 fee on failed/cancelled, `/me/balances`, `/me/limits`, `/v1/settlements/preview`, `/v1/organization-settlements`Daily tie-out schedule, bank/TRC20 destinations checked, 14:00–22:00 UTC+7 Portal USDT window notedSigned ledger tie-out (`UAT-02`, `UAT-08`, `UAT-09`, `UAT-10`)
Support Ops Lead`POST /v2/payins/{id}/cancel`, `GET /v1/payins/{id}`, slip rejections (`UAT-06`), sender mismatch (`UAT-07`), `POST /me/issues`Night-shift SOP ready, `request_id` escalation tested, zero manual credits from screenshotsApproved shift SOP + Sandbox `request_id` sample
Security / Go-Live Approver10-case UAT review, secret rotation drill, compliance check blocking scam/phishing/Ponzi flowsAPI & Portal IP allowlists locked, 2FA on all seats, least-privilege menu/CRUD RBACSigned Go-Live Authorization
Pre-Launch 4-Role Sign-Off Matrix Before Switching Keys to Production

10Controlled production cutover sequence and shift handover

Schedule cutover during a mid-week daytime window (Tuesday or Wednesday morning UTC+7) when Engineering, Finance, Support, and bank rails are fully staffed. Never cut over on a Friday evening or right before major live events.

Coordinate your window via the merchant onboarding and cutover desk on Telegram `@SFPayGateAgent`. SF PayGate enforces merchant compliance review (prohibiting scam, phishing, fake investment, or Ponzi operations while merchants remain responsible for market licensing) with 0 setup fees and 0 monthly fees.

Follow the nine steps below in order before ramping to full traffic, keeping all teams in a shared channel across the first two shift changes.

  1. 1Freeze cashier and wallet deploys, confirm NTP sync, and verify raw-body webhook capture behind production proxies.
  2. 2Load production `X-API-Key` and `Signing Secret` into separate vaults and verify egress IPs on the SF PayGate allowlist.
  3. 3Confirm mandatory 2FA on every Portal seat and verify menu/CRUD RBAC across Support, Finance, and Engineering.
  4. 4Sync cutover readiness via Telegram `@SFPayGateAgent` and confirm your TLS webhook route returns HTTP 200 under 500ms.
  5. 5Run a live 100 THB canary deposit from a bound account via `POST /api/v2/payins`, pay on `paypage_url`, and verify HMAC, credit, and 2.5% fee.
  6. 6Tap deposit twice to verify `PAYIN_ACTIVE_EXISTS` re-opens the link, then cancel via `POST /api/v2/payins/{id}/cancel` at 0 fee.
  7. 7Run a live 100 THB canary withdrawal via `POST /api/v1/payouts`, confirm `succeeded` via `GET /api/v1/payouts/{id}`, and check the 1.0% fee.
  8. 8Call `GET /api/me/balances`, `GET /api/me/limits`, and `POST /api/v1/settlements/preview` to reconcile live Finance totals.
  9. 9Ramp traffic gradually (10% -> 50% -> 100%), monitor 401 alerts for two shifts, and escalate via `POST /api/me/issues` (`request_id`).

Frequently asked questions

Why do outbound API calls return HTTP 401 in Sandbox when our Signing Secret is correct?
Usually because the signed path included `/api` (signing `/api/v2/payins` instead of `/v2/payins`). Middleware strips `/api` before verifying `X-Signature`. Also check `X-API-Key` was not used as the HMAC secret, clocks run NTP, and JSON bytes match.
How should our cashier handle PAYIN_ACTIVE_EXISTS in UAT and production?
When an unpaid deposit already exists, `POST /api/v2/payins` returns `PAYIN_ACTIVE_EXISTS`. Re-open the active `paypage_url` so the player can pay, and provide a change-amount action calling `POST /api/v2/payins/{id}/cancel` (0 fee) first.
Will deposits be lost if our webhook server times out during peak traffic?
No. SF PayGate retries webhooks until HTTP 200, backed by 24/7 polling via `GET /api/v1/payins/{id}` and bank QR verification via `POST /api/v1/payins/{id}/slip`. Use unique transaction ID constraints so retries never double-credit.
How do we verify our payout service cannot double-pay on timeouts?
Commit a unique `merchant_ref_id` and balance hold before calling `POST /api/v1/payouts`, then simulate a timeout in Sandbox and fire five concurrent retries with that exact `merchant_ref_id`. Confirm one payout `id` returns and never generate new references on timeout.
Which four roles sign off before switching Sandbox keys to production?
Engineering Lead (signing, webhooks, payout idempotency), Finance Lead (fees, `/me/balances`, `/v1/settlements/preview`, 14:00–22:00 UTC+7 Portal USDT window), Support Lead (`/cancel`, slip checks, `/me/issues` `request_id`), and Security/Admin Approver (IP allowlist, 2FA, RBAC).
Where do we coordinate Sandbox access and live cutover support?
Exclusively via Telegram `@SFPayGateAgent`. After launch, submit transaction tickets via `POST /api/me/issues` first and share the returned `request_id` on `@SFPayGateAgent` for fast tracing.

ENGINEERING & MARKET INSIGHTS

Related guides

All guides