Skip to Content
StagePayDocs v2

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

SecretPurposeWhere to store it
Webhook secret (whsec_…)Callback signature verification, price override signaturesMerchant server
REST API key (sk_…:secret)REST API calls, request signingMerchant server
App API keyRefund API, v1-compatible callback AuthorizationMerchant 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-Signature on 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-Delivery and tid
  • Confirm that the callback's productId, amountMinor, currency, and userId match 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 allowCustomPrice only when you need dynamic pricing, and create priceSig on the merchant server → Price override.
  • Use amountMinor, not amount (display only), when deciding on item grants.

Client trust boundary

  • The /return result message and checkout redirect parameters are for UI handling only. Do not use them as the basis for grants.
  • When receiving postMessage on the web, check that event.origin is 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:read for 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.

On this page