Skip to content
StagePay

Products · Merchant callbacks

Receive payment results as signed callbacks

The moment a payment passes server verification and is confirmed, a signed POST request goes to your server. The delivery ID stays the same across retries, so delivering items exactly once is easy.

Merchant callbackExample

POST https://merchant.example/stagepay/callback

X-StagePay-Event:
payment.succeeded
X-StagePay-Delivery:
7c1e9a42-3b6d-4f0e-9a51-5d0b
X-StagePay-Timestamp:
1795835700
X-StagePay-Signature:
v1=5f9a0c7d…e21b
Payment confirmed·Delivered200 · 84 ms · #1

The problem

Where payment notifications usually go wrong

  • Results relayed by the browser

    Redirect parameters or results passed to the app can be changed on the user's device, so they cannot justify delivering items.

  • A notification you only get once

    If the notification fails while your server is briefly down, the payment is made but the item is never delivered.

  • The same notification, twice

    When a retry or a lost response brings the same notification again, a server without idempotency delivers twice.

Features

What callbacks guarantee

  1. Two events, fixed fields

    payment.succeeded is sent right after the transaction moves from pending to success, and payment.refunded right after a refund is applied. Failed, cancelled and expired payments send no callback.

    • Guaranteed fields: event · tid · amount · amountMinor · currency · transactionStatus · paidAt
    • Read the transaction state from transactionStatus (status is kept for v1 compatibility)
    • Refund events add the cumulative refunded amount and this refund's details
    payment.succeeded body (key fields)json
    {
      "event": "payment.succeeded",
      "tid": "KCP-20261128031500-a1b2c3-0f1e2d3c",
      "amount": 33000,
      "amountMinor": 33000,
      "currency": "KRW",
      "transactionStatus": "success",
      "paidAt": "2026-11-28T03:15:42.000Z",
      "userId": "user_42",
      "productId": "gem_100",
      "serverId": "s1",
      "playerId": "hero42",
      "userdata": "{\"orderNo\":\"A-1001\"}",
      "environment": "production"
    }
  2. HMAC-SHA256 v1 signature

    The timestamp and raw body are signed with the app's webhook secret (whsec_…) and sent in the X-StagePay-Signature header. Verify against the raw body before parsing, and compare in constant time.

    • signed_payload = timestamp + "." + rawBody
    • Reject anything more than 300 seconds from the current time
    • Rotate the secret on the console's app screen — the full value is shown once, right after issuing
    Merchant callback headershttp
    POST https://merchant.example/stagepay/callback
    Content-Type: application/json
    X-StagePay-Event: payment.succeeded
    X-StagePay-Delivery: 7c1e9a42-3b6d-4f0e-9a51-8e2f4c6d5d0b
    X-StagePay-Timestamp: 1795835700
    X-StagePay-Signature: v1=<hex(hmac_sha256(webhookSecret, timestamp + "." + rawBody))>
    Callback signature verification (Node.js)node
    import crypto from "node:crypto"
    
    export function verifyStagePaySignature(rawBody, timestamp, signature, secret) {
      if (!/^\d+$/.test(timestamp ?? "")) return false
      if (Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) return false
      const expected =
        "v1=" + crypto.createHmac("sha256", secret).update(`${timestamp}.`).update(rawBody).digest("hex")
      const a = Buffer.from(expected)
      const b = Buffer.from(signature ?? "")
      return a.length === b.length && crypto.timingSafeEqual(a, b)
    }
  3. A delivery ID built for idempotency

    X-StagePay-Delivery keeps the same value however many times the event is resent. Record it first in a table with a unique constraint and answer duplicates with 200 to stop the retries.

    • Primary key: X-StagePay-Delivery, secondary key: tid + event
    • Record the idempotency key and deliver the item in the same DB transaction
    • Callback order is not guaranteed — query the REST API for the latest state
    Idempotency table example (PostgreSQL)sql
    CREATE TABLE stagepay_deliveries (
      delivery_id  uuid PRIMARY KEY,
      tid          text NOT NULL,
      event        text NOT NULL,
      received_at  timestamptz NOT NULL DEFAULT now(),
      UNIQUE (tid, event)
    );
  4. Review and resend in the console

    The console's Callbacks menu shows failed callbacks and the full delivery log. Fix the cause and resend: the same delivery ID is used and the retry schedule starts over.

    • Request headers and body, response code and duration recorded per attempt
    • The timestamp and signature are recalculated on every resend
    • Send a test callback from the app screen to check your receiving server
    Callback delivery logExample
    tid
    KCP-20261128031500-a1b2c3-0f1e2d3c
    X-StagePay-Delivery
    7c1e9a42-3b6d-4f0e-9a51-8e2f4c6d5d0b
    1. #103:15:425031.2 sFailed
    2. #203:16:43timeout10 sFailed
    3. #303:21:5320084 msDelivered
    +1m · +5m · +15m …Resend

Retry schedule

Non-2xx responses, connection failures and 10-second timeouts count as failures and are retried at the intervals below, up to 8 times. From the first attempt to the last retry is about 46 hours.

  1. #1

    0s

  2. #2

    +1m

  3. #3

    +5m

  4. #4

    +15m

  5. #5

    +1h

  6. #6

    +3h

  7. #7

    +6h

  8. #8

    +12h

  9. #9

    +24h

  • Redirects (3xx) are not followed, so register the final URL.
  • If no callback URL is set, or it is not http(s), the callback is marked failed immediately without retries.
  • If all 8 retries fail, the status becomes failed and you can resend from the console.

Request headers

Every callback sends a Content-Type: application/json body with the headers below.

Request headers
HeaderMeaning
X-StagePay-EventEvent name. Same as event in the body.
X-StagePay-DeliveryDelivery ID (UUID). Unchanged across retries — use it as the idempotency key.
X-StagePay-TimestampSigning time (Unix seconds). Reject if it is more than 300 seconds from now.
X-StagePay-Signaturev1= + hex(HMAC-SHA256(webhookSecret, timestamp + "." + rawBody))
X-Request-IdTrace ID for this delivery. Include it when you contact us.

Frequently asked questions

Which URL receives the callback?

Payments in the test environment or matching the test whitelist go to purchaseTestUrl, and live payments go to purchaseRealUrl. If both are empty, callbackUrl is used. All of them are set on the console's app screen.

Do failed or cancelled payments send callbacks?

No. Callbacks are sent only for confirmed payments (payment.succeeded) and refunds (payment.refunded). For other states, query the transaction through the REST API.

Can I verify with the Authorization header?

The Authorization: Bearer <app apiKey> header is deprecated and kept only for v1 compatibility. New integrations should verify the X-StagePay-Signature signature and the timestamp.

Is it the same for GamePot apps?

GamePot apps send callbacks to the GamePot regional endpoint with the same signature headers and retry rules. payment.refunded is not sent to GamePot apps.

Start with one integration

Follow the quickstart to create an app, create a payment and verify a callback signature.