Security Guide
Security rules for merchant integrations — managing secrets, verifying callbacks, verifying amounts, least privilege for API keys, and the WebView and client trust boundary.
Secrets
| Secret | Purpose | Where to store it |
|---|---|---|
Webhook secret (whsec_…) | Callback signature verification, price override signatures | Merchant server |
REST API key (sk_…:secret) | REST API calls, request signing | Merchant server |
| App API key | Refund API, v1-compatible callback Authorization | Merchant server |
- Never put secrets in app bundles, web frontends, or repositories (Git). Use environment variables or a Secret Manager.
- If you suspect a leak, rotate the secret in the console immediately → Rotating the secret.
Callbacks
- Verify
X-StagePay-Signatureon every callback against the raw body, using a constant-time comparison - Check the timestamp is within ±300 seconds (replay attack prevention)
- Handle idempotency using
X-StagePay-Deliveryandtid - Confirm that the callback's
productId,amountMinor,currency, anduserIdmatch your order - Do not rely solely on the v1
Authorization: Bearer <apiKey>check (deprecated)
Amounts
- The payment amount is determined by the product price registered on the server. Amounts sent from the client are ignored.
- Enable
allowCustomPriceonly when you need dynamic pricing, and createpriceSigon the merchant server → Price override. - Use
amountMinor, notamount(display only), when deciding on item grants.
Client trust boundary
- The
/returnresult message and checkout redirect parameters are for UI handling only. Do not use them as the basis for grants. - When receiving
postMessageon the web, check thatevent.originis a StagePay checkout domain → In-app/WebView. - Build checkout URLs and payment creation API calls on the server so the client cannot insert an arbitrary
userId.
API keys
- Grant only the scopes you need (e.g. only
settlement:readfor a settlement reconciliation server). - Set allowed IPs and an expiry date on production keys, and rotate them regularly.
- Check the console API logs for calls from unexpected IPs or to unexpected endpoints.
Transport
- Use HTTPS only for callback URLs. Self-signed certificates may fail.
- To restrict incoming callbacks by IP at your firewall, request the list of outbound IPs from the StagePay operations team. IP restrictions do not replace signature verification.
Logging and Tracing
How to trace a payment from the request through PG communication, state transitions, merchant callbacks, and settlement using requestId, plus the log types StagePay keeps and its masking rules.
Operational Alerts (NAVER WORKS)
How to receive payment problems and server errors in a NAVER WORKS bot message room. Covers Developer Console setup, environment variables, the conditions that trigger alerts, severity and grouping rules, and how to test.