Skip to content
StagePay

Developers

Payment integration in a few steps

Start a payment with the checkout URL or the server-to-server payment API, receive results through signed callbacks, and read settlements with the REST API.

Server-to-server payment creationbash
curl -X POST https://api.stagepay.io/api/v1/payments \
  -H "Authorization: Bearer $STAGEPAY_KEY_ID:$STAGEPAY_KEY_SECRET" \
  -H "Idempotency-Key: 3f6c1b2e-8a4d-4c1e-9b7a-2d5e0f1a6c90" \
  -H "Content-Type: application/json" \
  -d '{"productId":"gem_100","currency":"KRW","userId":"user_42","pg":"KCP","method":"card"}'

Integration steps

  1. Create an app and API key

    Register an app in the console and issue an API key and a webhook secret (whsec_…).

  2. Create a payment

    Redirect to the checkout, or call POST /api/v1/payments to get a tid and checkoutUrl.

  3. Handle callbacks

    Verify the signature of payment.succeeded / payment.refunded events and respond with 2xx.

  4. Read settlements

    Fetch settlements with GET /api/v1/settlements and each batch's lines (CSV supported).

Examples

Replace the placeholders (<…>) with the real values from your console. See the docs for all fields.

Checkout URLurl
https://pay.stagepay.io/request?appId=<APP_ID>&pg=KCP&method=card&productId=gem_100&currency=KRW&userId=user_42
Server-to-server payment creationbash
curl -X POST https://api.stagepay.io/api/v1/payments \
  -H "Authorization: Bearer $STAGEPAY_KEY_ID:$STAGEPAY_KEY_SECRET" \
  -H "Idempotency-Key: 3f6c1b2e-8a4d-4c1e-9b7a-2d5e0f1a6c90" \
  -H "Content-Type: application/json" \
  -d '{"productId":"gem_100","currency":"KRW","userId":"user_42","pg":"KCP","method":"card"}'
201 Created responsejson
{
  "tid": "KCP-20261128031500-a1b2c3-0f1e2d3c",
  "checkoutUrl": "https://pay.stagepay.io/checkout?tid=KCP-…&t=<hmac>",
  "expiresAt": "2026-11-28T03:45:00.000Z",
  "amount": "33000",
  "amountMinor": "33000",
  "currency": "KRW",
  "status": "pending"
}
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)
}

Callback retry schedule

Without a 2xx response within 10 seconds, the callback is resent at the intervals below. If all 8 retries fail, it can be resent manually from the admin console.

  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

REST API v1

  1. Authentication

    Authenticate with the Authorization: Bearer <keyId>:<secret> header. Each key can have its own scopes and IP allowlist.

  2. Idempotency

    The Idempotency-Key header makes create-payment retries safe. The same key with a different body returns 409.

  3. Request signing

    Optionally sign requests with X-StagePay-Signature, using the same HMAC scheme as callbacks.

  4. OpenAPI 3.1

    Download the full spec from /api/v1/openapi.json to browse it or generate a client.

Frequently asked questions

How does API authentication work?

REST API v1 authenticates with the Authorization: Bearer <keyId>:<secret> header. You can optionally sign requests with X-StagePay-Signature and apply per-key scopes and IP allowlists.

How do I verify the callback signature?

Check that the v1 value of X-StagePay-Signature equals hex(HMAC-SHA256(webhookSecret, timestamp + "." + rawBody)), that the timestamp is within 300 seconds of now, and that X-StagePay-Delivery has not been processed before.

Is there a test environment?

Each app can have a separate test callback URL. See the payment testing page in the developer docs for details.

Start with one integration

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