Skip to main content

Webhooks

The IXOPAY Payment Agent notifies a merchant endpoint of payment events with signed HTTPS POST requests.

Webhook setup

Register a fixed public HTTPS receiver with your integration manager. The gateway can use its configured default destination, or accepts a server-supplied webhookUrl. Keep destination selection in trusted configuration. A signed event reports a gateway record. Confirm the processor result separately before fulfilling or confirming a refund.

Events​

eventTypeSent when
payment.settledA payment reached settlement handover.
refund.settledThe gateway recorded a refund in its ledger.

Other event types may be added in later releases. Respond 200 to any event you don't handle, and don't treat an unknown eventType as an error.

Request​

POST https://shop.example.org/api/ixopay-webhook
Content-Type: application/json
X-Ixopay-Signature: t=1792093568,v1=3c5e…c91a
X-Ixopay-Event-Type: payment.settled
X-Ixopay-Event-Id: evt_8f1c…
{
"eventId": "evt_8f1c…",
"eventType": "payment.settled",
"transactionId": "tx_ap4m_1792093568383",
"merchantId": "your-merchant-id",
"amount": 4200,
"currency": "USD",
"invoiceHash": "e53d7b6a…a627",
"paymentRail": "AP4M",
"authorizationCode": "AUTH_…",
"vaultReference": "utt_tokenex_…",
"timestamp": "2026-10-15T19:46:08.383Z"
}

authorizationCode and vaultReference are optional. amount is in minor units.

Verifying the signature​

The X-Ixopay-Signature header has two parts: t (Unix seconds) and v1 (hex HMAC-SHA256).

  1. Read the raw request body exactly as received. Do not parse and re-serialize it.
  2. Build the string "<t>.<raw body>".
  3. Compute HMAC-SHA256 of it using your webhook signing secret. Hex-encode.
  4. Compare with v1 using a constant-time comparison.
  5. Reject if t is more than 300 seconds away from your clock (replay protection).

A complete tested Express handler is in examples/verify-webhook.js. The core of it:

function verifyIxopaySignature(rawBody, header, secret) {
const parts = Object.fromEntries(header.split(",").map((p) => p.split("=")));
const t = parseInt(parts.t, 10);
if (!t || !parts.v1) return false;
if (Math.abs(Date.now() / 1000 - t) > 300) return false;
const expected = crypto.createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex");
const a = Buffer.from(parts.v1),
b = Buffer.from(expected);
return a.length === b.length && crypto.timingSafeEqual(a, b);
}

With Express, capture the raw body with express.raw({ type: 'application/json' }) on this route; express.json() would hand you a parsed object.

Responding and retrying​

  • Persist the event and respond within three seconds. Process it asynchronously after acknowledgment.
  • Any HTTP 2xx response acknowledges delivery. For a request-supplied or default URL, a timeout, connection error or other status triggers retries, up to three attempts in total.
  • Delivery is best effort. When neither a request URL nor a default URL is set, the gateway queues deliveries to registered tenant destinations. Request-supplied and default URLs use in-process retries. Confirm queue persistence and retry arrangements for your environment. Deduplicate accepted events by eventId in durable storage, and reconcile missing events against your gateway and processor records.
  • Don't depend on ordering. Use transactionId and timestamp to reconcile.

Secrets​

IXOPAY gives you a webhook signing secret for your merchant account. Your receiver must use that value. Treat it like a password; to rotate it, agree a cut-over time with your IXOPAY integration manager.

Testing locally​

  1. Run your receiver on a local port.
  2. Compute a signature the same way the Payment Agent does and send a test event:
BODY='{"eventId":"evt_test","eventType":"payment.settled","transactionId":"tx_test","merchantId":"m","amount":4200,"currency":"USD","invoiceHash":"h","paymentRail":"AP4M","timestamp":"2026-10-15T00:00:00Z"}'
T=$(date +%s)
SIG=$(printf '%s.%s' "$T" "$BODY" | openssl dgst -sha256 -hmac "$IXOPAY_WEBHOOK_SECRET" -hex | sed 's/^.* //')
curl -X POST http://localhost:4000/api/ixopay-webhook \
-H "Content-Type: application/json" -H "X-Ixopay-Signature: t=$T,v1=$SIG" -d "$BODY"
  1. Alter one character of $BODY after signing; the receiver must return 401.