Skip to documentation
/

verifySettlementCallback()

Signature#

typescript example
.ts
verifySettlementCallback(  rawBody: Uint8Array,  signature: string | null | undefined,  secret: string | Uint8Array,): boolean;

Example#

typescript example
.ts
import { verifySettlementCallback } from '@aggregator-network/sdk'; const secret = process.env.AGGREGATOR_CALLBACK_SECRET;if (!secret) throw new Error('Set AGGREGATOR_CALLBACK_SECRET'); const valid = verifySettlementCallback(  rawBody,  signatureHeader,  secret,);if (!valid) {  // Reject before parsing or accepting the settlement.}

rawBody must contain the untouched bytes received by your backend before JSON parsing. Node.js Buffer is a Uint8Array. Read signatureHeader from x-callback-signature. The callback secret is separate from the Game API key.

Verification rules#

The signature is exactly sha256= followed by 64 lowercase hexadecimal characters. The helper computes HMAC-SHA256 over the original body and compares digest bytes in constant time. Missing or malformed signatures, an empty secret or invalid byte input return false.

The helper authenticates body bytes only. It does not authenticate timestamp headers, enforce freshness, parse the event or apply any balance change. Re-serializing JSON before verification changes the bytes and is incorrect.

Durable settlement processing#

After successful verification, use lossless decimal parsing and decimal storage for monetary fields. Deduplicate atomically using serial_number in the body. Validate ownership, currency and ordering with your own durable wallet records, then acknowledge only after durable acceptance.

Ordinary JSON.parse can lose precision for monetary numbers with up to 20 integer and 10 fractional digits. Signature checking alone does not prevent replay.

Receiver guide#

See settlements for authoritative credit_amount semantics, delivery limits and recovery rules. The callback lab uses illustrative local fixtures, not production financial execution.

Was this page helpful?