Automated Deposit & Withdrawal API with Live Sandbox & HMAC-SHA256 Webhooks
One REST integration covering Payin V2 AUTO deposits, idempotent Smart Withdrawals, bank-cleared slip fallback, and raw-body signed callbacks — with endpoint-by-endpoint specs.
Solution Overview
Spec updated 2026-12-04SF PayGate unifies POST /api/v2/payins (merchant_ref_id, currency_code, request_amount), POST /api/v1/payouts (merchant_ref_id idempotency key), GET /api/v1/payins/{id}, POST /api/v1/settlements, and POST /api/v1/payins/{id}/slip under one HMAC-SHA256 signing model with 0 setup and 0 monthly fees.
35
Merchant API Endpoints
100+
Total Routes incl. Sandbox & Issues
3-Way
Signed Webhook + Query API + Slip QR
HMAC-SHA256
Constant-Time Raw-Body Verification
What should engineering, finance, and support sign off in Sandbox before go-live?
Walk through every happy-path and chaos scenario together using our Sandbox UAT and pre-launch sign-off matrix before switching credentials to production.
How do we harden payout state machines and webhook verification?
Pair our idempotent payout engine implementation guide with the HMAC-SHA256 raw-body webhook verification guide.
First Sandbox Call (POST /api/v2/payins)
Inspect the exact headers, request payload, and JSON response returning paypage_url.
# Note: api.example.com is a placeholder — your Sandbox & Production endpoints are issued at onboarding.
# Middleware strips /api before verifying, so compute X-Signature over /v2/payins.
curl -X POST https://api.example.com/api/v2/payins \
-H "Content-Type: application/json" \
-H "X-API-Key: <your-api-key>" \
-H "X-Timestamp: <unix-timestamp>" \
-H "X-Signature: <hmac-sha256-of-path>" \
-d '{
"merchant_ref_id": "unique-order-ref-id-2025001",
"currency_code": "THB",
"request_amount": 1000,
"customer_id": "0198cbc6-fd02-7459-a671-78c306d0a1ad",
"customer_account_id": "0198cbc7-35ec-7c8c-8994-d3ac3e7f5255",
"redirect_url": "https://merchant.example.com/payment/success"
}'Sample JSON Response
{
"id": "0198cbff-db9b-7b6a-9f82-6a55fdfb6575",
"merchant_ref_id": "unique-order-ref-id-2025001",
"status": "pending",
"request_amount": 1000,
"paypage_url": "https://pay.example.com/pay/0198cbff-db9b-7b6a-9f82-6a55fdfb6575"
}How to Integrate Deposits, Withdrawals & Webhooks
1. Create Deposits (POST /api/v2/payins)
AUTO mode routes dynamically across QR or bank transfer and enforces Active Payin Protection (PAYIN_ACTIVE_EXISTS).
2. Idempotent Withdrawals (POST /api/v1/payouts)
Pass a unique merchant_ref_id as the idempotency key; payouts execute via a 24/7 managed queue and remain queryable via GET /api/v1/payouts/{id}.
3. Verify Signed Webhooks (HMAC-SHA256)
Verify X-Signature over raw bytes using timingSafeEqual with X-Timestamp freshness validation, then acknowledge HTTP 200.
4. Bank-Cleared Slip Fallback
Submit transfer slip QR payloads to POST /api/v1/payins/{id}/slip for clearing validation and permanent replay-hash storage.
Automated REST API vs Manual Backoffice Operations
| Workflow | SF PayGate Auto API | Manual Backoffice |
|---|---|---|
| Deposit Reconciliation | Signed Webhook + 24/7 Query API | Manual slip checking in chat queues |
| Slip Fraud Check | Bank-cleared QR payload + replay hash | Human review or editable OCR screenshots |
| Peak Withdrawals | Idempotent Smart Withdraw queue | Manual bottlenecks and duplicate transfers |
30 connected banks
18 Thai banks · 12 Hong Kong FPS banks · USDT TRC20
KBANK
Kasikornbank
SCB
Siam Commercial Bank
KTB
Krungthai Bank
BBL
Bangkok Bank
BAY
Krungsri (Bank of Ayudhya)
TTB
TMBThanachart Bank
GSB
Government Savings Bank
BAAC
BAAC Thailand
GHB
Government Housing Bank
CIMB
CIMB Thai
UOB
UOB Thailand
IBANK
Islamic Bank of Thailand
LHB
LH Bank

TISCO
TISCO Bank
KKP
Kiatnakin Phatra Bank
HSBC
HSBC Thailand
TCRB
Thai Credit Bank
ICBC
ICBC (Thai)
Signing Rule: Middleware strips a leading /api prefix before verifying signatures. Always sign /v2/payins when calling /api/v2/payins, alongside a fresh X-Timestamp.
Frequently Asked Questions
Where should our backend check status if a webhook is delayed?
Webhooks retry automatically until HTTP 200 is returned. Your backend can also poll GET /api/v1/payins/{id} 24/7 for authoritative order state or accept a slip fallback via POST /api/v1/payins/{id}/slip.
Which merchant_ref_id should we send when retrying a timed-out withdrawal?
Always reuse the original merchant_ref_id — never generate a fresh ID on retry, since it acts as the idempotency lock. Exercise timeout scenarios on the dedicated Sandbox debug endpoints before going live.
Is a full Sandbox environment included?
Yes. Sandbox API keys and signing secrets are issued after consultation with no live production domain required upfront.
ENGINEERING & MARKET INSIGHTS
Related Guides
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.
Read guideIdempotent Payout Engine: Stopping Double Withdrawals on a Gambling Payment Gateway
An engineering deep-dive for teams running a Payment Gateway for gambling sites: how retries, timeouts, queue redeliveries and double-clicks create duplicate transfers, and how merchant_ref_id, a state machine and ledger reconciliation prevent them.
Read guideHMAC-SHA256 Webhook Verification Guide for a Payment Gateway in iGaming
A developer guide to signing API requests and verifying webhooks with HMAC-SHA256 on a Payment Gateway for iGaming: raw-body capture, constant-time comparison, replay protection, the /api prefix rule, idempotent handlers and a go-live checklist.
Read guide