Webhook/Callback Events and Payloads
The event types, HTTP headers, and complete body fields of the payment completion and refund callbacks StagePay sends to the merchant server.
When a payment is confirmed or refunded, StagePay (pay) sends a POST request to the merchant server. These docs call this a callback (or webhook). It is the same concept as the v1 "purchase callback", with signatures, retries, and event types added in v2.
Receiving URL
| Order | App setting | When used |
|---|---|---|
| 1 | purchaseTestUrl | In the test environment, or for payments matching the test whitelist (IP, userId) |
| 2 | purchaseRealUrl | Production environment |
| 3 | callbackUrl | Fallback when the values above are empty |
GamePot-integrated apps (webhookType = GAMEPOT) send to the GamePot endpoint → GamePot app specifics.
Events
X-StagePay-Event | When it occurs |
|---|---|
payment.succeeded | Right after the transaction transitions pending → success (PG server verification or USDT confirmations complete) |
payment.refunded | Right after a refund is applied and the transaction transitions to partial_refunded or refunded |
No callbacks are sent for failures, cancellations, or expirations. If needed, query the transaction status with the REST API.
Request headers
POST /stagepay/callback HTTP/1.1
Host: game.example.com
Content-Type: application/json
Accept: application/json
User-Agent: StagePay/2 (+https://stagepay.io)
X-StagePay-Event: payment.succeeded
X-StagePay-Delivery: 2f1d8c7a-4b9e-4e57-9a51-0c6d3b2e8f14
X-StagePay-Timestamp: 1767225600
X-StagePay-Signature: v1=<64 hexadecimal characters>
X-Request-Id: 9b2f0c1e-6c1a-4d3e-9f20-3b1f0a8e7d11
Authorization: Bearer <app apiKey>| Header | Description |
|---|---|
X-StagePay-Event | Event name (same as event in the body) |
X-StagePay-Delivery | Delivery ID (UUID). Same value across retries → use it as an idempotency key |
X-StagePay-Timestamp | Signing time (Unix seconds). Reject if it differs from the current time by more than 300 seconds |
X-StagePay-Signature | v1= + hex(HMAC-SHA256(webhookSecret, timestamp + "." + rawBody)) → Signature verification |
X-Request-Id | Trace ID of this delivery (for support inquiries and log tracing) |
Authorization | Bearer <app apiKey> — for v1 backward compatibility, deprecated. New integrations should verify using the signature |
| Custom headers | Headers registered in the app setting webhookHeaders are added |
Body (payment.succeeded)
{
"event": "payment.succeeded",
"tid": "KCP-20260101090000123456-a1b2c3-9f8e7d6c",
"amount": 12000,
"amountMinor": 12000,
"currency": "KRW",
"transactionStatus": "success",
"paidAt": "2026-01-01T00:00:00.000Z",
"orderId": "KCP-20260101090000123456-a1b2c3-9f8e7d6c",
"userId": "user_42",
"playerId": "hero42",
"serverId": "s1",
"paymentMethod": "card",
"status": "completed",
"productId": "gem_100",
"productName": "보석 100개",
"createdAt": "2025-12-31T23:59:40.000Z",
"completedAt": "2026-01-01T00:00:00.000Z",
"pgProvider": "KCP",
"pgTransactionId": "KCP-20260101090000123456-a1b2c3-9f8e7d6c",
"pgTid": "24123456789012",
"remoteIp": "203.0.113.10",
"userAgent": "Mozilla/5.0 ...",
"etc": "",
"meta": "",
"userdata": "{\"orderNo\":\"A-1001\"}",
"appId": "6650f0c2a1b2c3d4e5f60718",
"environment": "production",
"webhookType": "purchase",
"originalPayload": { "...": "..." },
"userID": "user_42",
"orderID": "KCP-20260101090000123456-a1b2c3-9f8e7d6c",
"playerID": "hero42",
"serverID": "s1",
"productID": "gem_100",
"productNAME": "보석 100개",
"pgTransactionID": "KCP-20260101090000123456-a1b2c3-9f8e7d6c",
"remoteIP": "203.0.113.10",
"appID": "6650f0c2a1b2c3d4e5f60718"
}Use transactionStatus to determine the transaction status
v2 integrations tell events apart with event and read the transaction status from transactionStatus. status is a field kept for compatibility with v1 receiving code, and in payment.succeeded it is always "completed". Do not rely on status in new code.
Fields guaranteed in v2
| Field | Type | Description |
|---|---|---|
event | string | payment.succeeded or payment.refunded (same as the X-StagePay-Event header) |
tid | string | StagePay transaction ID |
amount | number | Payment amount (major unit, JSON number). Examples: 9.99, 12000. For display |
amountMinor | integer | Amount used for settlement and verification (minor unit). Examples: USD 999, KRW 12000 |
currency | string | Currency of the transaction (product price). ISO 4217 or USDT |
transactionStatus | string | Transaction status at callback time: success, partial_refunded, refunded |
paidAt | string | Payment confirmation time (ISO 8601, UTC) |
amount, amountMinor, and currency are the original payment amount even in refund events. Use amountMinor and currency to verify item grants.
v1-compatible fields
| Field | Description |
|---|---|
status | v1-compatible status value. payment.succeeded → "completed", payment.refunded → the transaction status (partial_refunded / refunded) |
orderId | Same value as tid |
appId | App ID |
userId / serverId / playerId | Values passed in the payment request |
productId / productName | Product information. If the product has a separate product code, productId is that code |
paymentMethod | Payment method code (e.g. card, TRC20) |
pgProvider | PG code (e.g. KCP, STRIPE, USDT) |
pgTransactionId | v1-compatible field (same value as tid) |
pgTid | PG transaction ID (KCP tno, Stripe PaymentIntent ID, USDT transaction hash, etc.) |
createdAt / completedAt | Transaction creation time / payment confirmation time (same as paidAt) |
remoteIp / userAgent | IP / browser of the customer who made the payment request |
userdata / etc / meta | Free-form data passed in the payment request |
environment | production or test (including the test whitelist) |
webhookType | purchase (payment completed) or refund (refund) |
originalPayload | Sanitized payment method details (structure varies by PG, secrets excluded). v1 sent the PG's original result as is, but v2 sends only sanitized values. Use it for debugging and display only |
userID, orderID, playerID, serverID, productID, productNAME, pgTransactionID, remoteIP, appID | Aliases with uppercase ID (for compatibility with v1 receiving code). Values are the same as the camelCase fields |
Chain information for USDT payments (network, transaction hash, actual deposit amount, etc.) is in originalPayload → How USDT payments work.
Body (payment.refunded)
Refund information is added to the payment.succeeded fields. webhookType is refund, and status and transactionStatus are the transaction status after the refund.
{
"event": "payment.refunded",
"tid": "KCP-20260101090000123456-a1b2c3-9f8e7d6c",
"amount": 12000,
"amountMinor": 12000,
"currency": "KRW",
"transactionStatus": "partial_refunded",
"paidAt": "2026-01-01T00:00:00.000Z",
"status": "partial_refunded",
"webhookType": "refund",
"refundedAmountMinor": 5000,
"refundedAmount": 5000,
"refund": {
"refundId": "rf_01JH2X8Q4M3N",
"amountMinor": 5000,
"pgRefundId": "24123456789012-1",
"amount": 5000
}
}(The example above shows only the refund-related fields. The remaining fields are the same as in payment.succeeded.)
| Field | Description |
|---|---|
refundedAmountMinor | Cumulative refunded amount (minor). If it equals amountMinor, the payment is fully refunded |
refundedAmount | Cumulative refunded amount (major, JSON number) |
refund.refundId | ID of this refund |
refund.amountMinor / refund.amount | Amount of this refund (minor / major) |
refund.pgRefundId | PG refund transaction ID (if provided by the PG) |
Response rules
- A 2xx status code means the delivery succeeded. The body is ignored (any value, such as
ok). - Any non-2xx response, a connection failure, or a 10-second timeout is treated as a failure and retried → Retries and idempotency.
- Return
401if the signature is invalid, and5xxfor a temporary error you cannot handle. If you receive a Delivery you have already processed, you must return200to stop the retries. - If granting takes a long time, store the callback first (enqueue it), respond with
200immediately, and process it asynchronously.
Security recommendations
- Verify the signature and timestamp of every callback
- Prevent duplicate processing using
X-StagePay-Deliveryandtid - Confirm that the callback's
amountMinor,currency, andproductIdmatch your order - Determine the transaction status with
transactionStatus(statusis for v1 compatibility) - Use HTTPS endpoints only
- Keep logs of received request headers and bodies (excluding secrets)
USDT Settlement and Refund Policy
How USDT payments are settled (fee settlement), exchange rate snapshots, why on-chain refunds are manual, and the refund procedure.
Callback Signature Verification
The X-StagePay-Signature HMAC-SHA256 signature specification, verification examples in Node.js, PHP, Python, Go, and Java, and fixed test vectors.