Verify signed callbacks, read payment analytics, and retry callback delivery.
Callback verificationCallback verification
x-solknife-event: payment.confirmed | subscription_plan.confirmed | subscription_plan.updated_onchain | subscription.subscribe | subscription.collect | subscription.cancel | subscription.resume | subscription.past_due | subscription.expired | gateway.test
x-solknife-delivery-id: 5f0c2a8e-3b1d-4c6f-9a7e-2d4b8c1e6f30
x-solknife-timestamp: 1800000000
x-solknife-signature: hex(hmac_sha256(webhook_secret, timestamp + "." + raw_body))
{
"eventType": "payment.confirmed",
"customerTelegramChatId": "123456789",
"merchantAmountRaw": "250000000",
"gatewayFeeLamports": "1200000",
"gatewayFeeChargedLamports": "1200000",
"status": "CONFIRMED"
}
Subscription callbacks use eventType subscription_plan.confirmed, subscription_plan.updated_onchain, subscription.subscribe, subscription.collect, subscription.cancel, subscription.resume, subscription.past_due, or subscription.expired and include the customer reference, plan id, billing period, status, configured gateway fee, and gateway fee charged for that action.
Verify every callback before you act on it:
1. Compute the hex HMAC-SHA256 of "<x-solknife-timestamp>.<raw body>" with your webhook secret and compare it to x-solknife-signature in constant time.
2. Reject the callback when x-solknife-timestamp is more than 5 minutes (300 seconds) away from your clock.
3. Store each x-solknife-delivery-id you accept for at least 10 minutes and drop any callback whose delivery id you already processed. A manual retry from the dashboard is a new delivery with a new delivery id, so also make your handler idempotent on the payment or subscription id.
Node.js verifier:
import { createHmac, timingSafeEqual } from "node:crypto";
const TOLERANCE_SECONDS = 300;
export const verifySolknifeCallback = (secret, rawBody, headers, nowSeconds = Math.floor(Date.now() / 1000)) => {
const timestamp = headers["x-solknife-timestamp"] ?? "";
const signature = headers["x-solknife-signature"] ?? "";
if (!/^\d+$/.test(timestamp)) return false;
if (Math.abs(nowSeconds - Number(timestamp)) > TOLERANCE_SECONDS) return false;
const expected = Buffer.from(createHmac("sha256", secret).update(`${timestamp}.${rawBody}`).digest("hex"), "hex");
const received = Buffer.from(signature, "hex");
return received.length === expected.length && timingSafeEqual(received, expected);
};
GET /api/analytics/summary
x-gateway-key: sk_live_...
Returns payment counts, confirmed gateway fee lamports including subscription collect fees, callback health, and indexed token count.
Callback delivery historyCallback delivery history
GET /api/webhooks
x-gateway-key: sk_live_...
Returns the latest callback attempts with event type, status, HTTP code, and target URL.
Retry callback deliveryRetry callback delivery
POST /api/webhooks/{deliveryId}/retry
x-gateway-key: sk_live_...
Creates a fresh callback delivery attempt for payment.confirmed and stored subscription callback events.
Retries and test callbacks share a limit of 10 per minute per merchant; over the limit the API returns 429 WEBHOOK_RATE_LIMITED.