Skip to Content
StagePayDocs v2

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

OrderApp settingWhen used
1purchaseTestUrlIn the test environment, or for payments matching the test whitelist (IP, userId)
2purchaseRealUrlProduction environment
3callbackUrlFallback when the values above are empty

GamePot-integrated apps (webhookType = GAMEPOT) send to the GamePot endpoint → GamePot app specifics.

Events

X-StagePay-EventWhen it occurs
payment.succeededRight after the transaction transitions pending → success (PG server verification or USDT confirmations complete)
payment.refundedRight 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>
HeaderDescription
X-StagePay-EventEvent name (same as event in the body)
X-StagePay-DeliveryDelivery ID (UUID). Same value across retries → use it as an idempotency key
X-StagePay-TimestampSigning time (Unix seconds). Reject if it differs from the current time by more than 300 seconds
X-StagePay-Signaturev1= + hex(HMAC-SHA256(webhookSecret, timestamp + "." + rawBody)) → Signature verification
X-Request-IdTrace ID of this delivery (for support inquiries and log tracing)
AuthorizationBearer <app apiKey> — for v1 backward compatibility, deprecated. New integrations should verify using the signature
Custom headersHeaders 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

FieldTypeDescription
eventstringpayment.succeeded or payment.refunded (same as the X-StagePay-Event header)
tidstringStagePay transaction ID
amountnumberPayment amount (major unit, JSON number). Examples: 9.99, 12000. For display
amountMinorintegerAmount used for settlement and verification (minor unit). Examples: USD 999, KRW 12000
currencystringCurrency of the transaction (product price). ISO 4217 or USDT
transactionStatusstringTransaction status at callback time: success, partial_refunded, refunded
paidAtstringPayment 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

FieldDescription
statusv1-compatible status value. payment.succeeded → "completed", payment.refunded → the transaction status (partial_refunded / refunded)
orderIdSame value as tid
appIdApp ID
userId / serverId / playerIdValues passed in the payment request
productId / productNameProduct information. If the product has a separate product code, productId is that code
paymentMethodPayment method code (e.g. card, TRC20)
pgProviderPG code (e.g. KCP, STRIPE, USDT)
pgTransactionIdv1-compatible field (same value as tid)
pgTidPG transaction ID (KCP tno, Stripe PaymentIntent ID, USDT transaction hash, etc.)
createdAt / completedAtTransaction creation time / payment confirmation time (same as paidAt)
remoteIp / userAgentIP / browser of the customer who made the payment request
userdata / etc / metaFree-form data passed in the payment request
environmentproduction or test (including the test whitelist)
webhookTypepurchase (payment completed) or refund (refund)
originalPayloadSanitized 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, appIDAliases 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.)

FieldDescription
refundedAmountMinorCumulative refunded amount (minor). If it equals amountMinor, the payment is fully refunded
refundedAmountCumulative refunded amount (major, JSON number)
refund.refundIdID of this refund
refund.amountMinor / refund.amountAmount of this refund (minor / major)
refund.pgRefundIdPG 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 401 if the signature is invalid, and 5xx for a temporary error you cannot handle. If you receive a Delivery you have already processed, you must return 200 to stop the retries.
  • If granting takes a long time, store the callback first (enqueue it), respond with 200 immediately, and process it asynchronously.

Security recommendations

  • Verify the signature and timestamp of every callback
  • Prevent duplicate processing using X-StagePay-Delivery and tid
  • Confirm that the callback's amountMinor, currency, and productId match your order
  • Determine the transaction status with transactionStatus (status is for v1 compatibility)
  • Use HTTPS endpoints only
  • Keep logs of received request headers and bodies (excluding secrets)

On this page