Webhooks
Events
payment.confirming— seen on networkpayment.succeeded— expected amount received (enginepayment.paid)payment.underpaid/payment.overpaid— amount mismatch (top-up allowed while underpaid)payment.expired— quote/rate lock expired (late chain payments may still be accepted)payment.blocked/ failed,payment.canceledrefund.created/refund.completed
Payload fields
Webhook data includes amount/currency, description, customerEmail, orderNumber, metadata, returnUrl, cancelUrl, webhookUrl, rateLockExpiresAt, acceptedLate / late, and topUp when applicable. When CXCash merchant wallet conversion is active, payloads also include payerExtraUsdCents, merchantExtraUsdCents, feeUsdCents, gasUsdCents, payerAsset, and optional payerLineItems for checkout conversion/bridge surcharges. See Costs.
Delivery
Deliveries are signed, retried up to 5 times with exponential backoff (2s base), then marked dead_letter. Replay a delivery with POST /api/v1/webhook-endpoints/deliveries/:deliveryId/replay.
Signature
Header cxpay-signature: t=<unix>,v1=<hex>. HMAC-SHA256 of t.rawBody with your endpoint secret. Use a constant-time compare and a ~5 minute skew window.
Node
import crypto from 'node:crypto';
export function verifyCxpaySignature(rawBody, header, secret, toleranceSec = 300) {
const parts = Object.fromEntries(header.split(',').map((p) => p.trim().split('=')));
const t = Number(parts.t);
const v1 = parts.v1;
if (!t || !v1) return false;
if (Math.abs(Date.now() / 1000 - t) > toleranceSec) return false;
const expected = crypto.createHmac('sha256', secret).update(`${t}.${rawBody}`).digest('hex');
try {
return crypto.timingSafeEqual(Buffer.from(v1, 'hex'), Buffer.from(expected, 'hex'));
} catch {
return false;
}
}PHP
function verify_cxpay_signature(string $rawBody, string $header, string $secret, int $tolerance = 300): bool {
$parts = [];
foreach (explode(',', $header) as $piece) {
[$k, $v] = array_map('trim', explode('=', $piece, 2) + [null, null]);
if ($k !== null) $parts[$k] = $v;
}
$t = intval($parts['t'] ?? 0);
$v1 = $parts['v1'] ?? '';
if (!$t || $v1 === '') return false;
if (abs(time() - $t) > $tolerance) return false;
$expected = hash_hmac('sha256', $t . '.' . $rawBody, $secret);
return hash_equals($expected, $v1);
}Python
import hmac, hashlib, time
def verify_cxpay_signature(raw_body: bytes, header: str, secret: str, tolerance: int = 300) -> bool:
parts = dict(p.strip().split("=", 1) for p in header.split(",") if "=" in p)
try:
t = int(parts["t"])
v1 = parts["v1"]
except (KeyError, ValueError):
return False
if abs(time.time() - t) > tolerance:
return False
expected = hmac.new(secret.encode(), f"{t}.".encode() + raw_body, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, v1)