Security
Safeguards at every step where money moves
From setting the amount to confirming the payment, notifying the merchant and writing logs, the same rules apply on every PG and USDT payment path.

tid KCP-20261128031500-a1b2c3-0f1e2d3c
- Amount = product price registered on the server
- PG signature verified or PG lookup API rechecked
- Confirmed amount compared with requested amount
- pending → success transition, once
- Merchant callback signed with v1
Payment confirmed
Features
Six safeguards around every payment
The server sets the amount
The amount charged comes from the product price registered in the console. Amounts sent by the client are ignored, and the payment creation API has no amount field.
- Price overrides only with allowCustomPrice plus a merchant server signature (±900 seconds)
- Sale period, quantity and per-user limits checked before payment
- All amounts calculated as integers in minor units; currencies are never mixed
String signed for a price overridehmac canonical = "price:{appId}:{productId}:{CURRENCY}:{price}:{userId}:{priceTs}" priceSig = hex(HMAC-SHA256(webhookSecret, canonical)) priceTs = unix seconds, |now - priceTs| <= 900PG server verification and atomic confirmation
Success is decided only by PG signature verification, a PG lookup API check or, for USDT, chain confirmations — and the amount is compared. The pending → success transition succeeds atomically, exactly once, and only that path sends the callback.
- Browser redirect values alone never confirm a payment
- Repeated or replayed webhooks never confirm twice
- PG webhooks with invalid signatures are rejected
- USDT is confirmed by reading the blockchain, with no private keys
pending → successatomic transactions.findOneAndUpdate( { tid, status: "pending" }, { $set: { status: "success", paidAt } } ) → updated : send signed merchant callback (once) → no match : already confirmed — no second callbackOne signature scheme for callbacks and requests
Merchant callbacks are signed with the webhook secret, and the merchant's REST requests with the API key secret, both as HMAC-SHA256 v1. Timestamps more than 300 seconds off are rejected to stop replay attacks.
- signed_payload = timestamp + "." + rawBody
- Constant-time comparison (timing-safe)
- Request signing is optional — if the header is sent, it is always verified
Request signing (Node.js)node import crypto from "node:crypto" export async function stagepayPost(path, payload) { const body = JSON.stringify(payload) const ts = Math.floor(Date.now() / 1000).toString() const sig = "v1=" + crypto.createHmac("sha256", secret).update(`${ts}.${body}`).digest("hex") return fetch(`https://api.stagepay.io${path}`, { method: "POST", headers: { Authorization: `Bearer ${keyId}:${secret}`, "Content-Type": "application/json", "X-StagePay-Timestamp": ts, "X-StagePay-Signature": sig, }, body, }) }Scoped API keys
Each REST API key is bound to one app, with its own scopes, allowed IPs, expiry and requests-per-minute limit. The secret is shown only once, right after it is issued.
- Example scopes: read:transactions · write:transactions · settlement:read
- Requests from outside the allowed IPs get 403; expired or inactive keys get 401
- Requests for another app's resources return 404
REST API keyactiveExample sk_1f2e3d4c…89abcdef : ••••••••
- Scopes
- read:transactionswrite:transactionssettlement:read
- Allowed IPs
- 203.0.113.10198.51.100.0/24
- Expires
- 2027-06-30
- rate limit
- 600 / min
Log masking and audit logs
Every request, PG exchange, state transition and callback attempt is recorded, with secrets masked before they are stored. Every settlement state change is written to the audit log with the actor and before and after values.
- Masking by key name: password · secret · token · apiKey · signature · card and more
- Card-number-like values (13–19 digits) are masked in the middle
- The callback's originalPayload is sanitized, with secrets removed
systemlogsjson { "category": "pg_io", "requestId": "9b2f0c1e-6c1a-4d3e-9f20-3b1f0a8e7d11", "tid": "KCP-20261128031500-a1b2c3-0f1e2d3c", "data": { "authorization": "***", "signature": "***", "card": "***", "note": "4242********4242" } }Operational anomaly alerts
When payment problems or server errors are detected, StagePay operators are alerted right away.
- Alerts never include card details, tokens or secrets
Merchant checklist
StagePay's safeguards are complete only together with checks on your server. Go through these items before going live.
- Verify every callback signature against the raw body before parsing, and compare in constant time
- Check that X-StagePay-Timestamp is within 300 seconds of the current time
- Process each X-StagePay-Delivery and tid only once
- Match the callback's productId · amountMinor · currency · userId against your order
- Read the transaction state from transactionStatus (status is for v1 compatibility)
- Keep webhook secrets and API keys only in a server secret store — never in app bundles, front-end code or Git
- Build checkout URLs and payment creation calls on your server
- For web postMessage, check that event.origin is a StagePay payment domain
- Give API keys the minimum scopes, allowed IPs and an expiry, and rotate them regularly
- Use HTTPS-only callback URLs
Console
See it in the console
These links open the matching console screen after you sign in. A merchant account only sees its own company's apps.
Frequently asked questions
Does StagePay store card details?
Payment details such as card numbers are handled by the PG. If a card-number-like value appears in a log, its middle digits are masked.
What if our webhook secret leaks?
Rotate the webhook secret right away on the console's app screen and deploy the new value to your server. The full new secret is shown only once, right after it is issued.
Can we restrict callbacks by IP?
You can, but IP restrictions do not replace signature verification. Ask the StagePay operations team for the sending IPs and keep verifying the signature and timestamp.
Do we have to hand over private keys to accept USDT?
No. Customers send funds directly to the configured receiving address, and StagePay only reads the blockchain to confirm the deposit. No private keys are kept on the server.
Start with one integration
Follow the quickstart to create an app, create a payment and verify a callback signature.