Skip to content

Webhooks and background updates

Zwipe POSTs an event to your HTTPS webhook URL when one of your cards reaches a final issuing state; chain accounts also get load and transaction events. Your Zwipe contact sets the URL on your partner account and hands you a signing secret over a secure channel.

Type Fires when
card.issued The card is active. On cards from POST /v1/cards, a card that was in_doubt with error_code activation_pending turns issued when a balance read (GET /v1/cards/{card_id}/balance) succeeds; the event follows it
card.failed The issuer rejected the order or could not be reached; error_code says which. The same external_ref may be ordered again
card.in_doubt The outcome is uncertain; when the issuer never answered, a few minutes after the order. See recovering an uncertain order
load.succeeded / load.failed / load.in_doubt Chain accounts: a load reached that state; data.load is the load. An in_doubt load is reconciled by Zwipe and the final event follows
transaction.created Chain accounts: the issuer reported a new money entry on the card; data.transaction is the entry

data.card is the card as it was when the event was created. It never carries issuer.wallet_url or issuer.collect_url; read GET /v1/cards/{card_id} when you need them, so they stay out of your webhook logs.

Every delivery carries Zwipe-Signature: t=<unix seconds>,v1=<hex>. Compute HMAC-SHA256 with your webhook secret over <t>.<raw request body> and compare it with v1 in constant time. Reject a t more than 5 minutes from your clock. Verify the raw bytes before any JSON parsing.

import { createHmac, timingSafeEqual } from 'node:crypto';
export function verifyZwipeSignature(rawBody, header, secret, now = Date.now()) {
const parts = Object.fromEntries(header.split(',').map((p) => p.split('=')));
const t = Number(parts.t);
if (!Number.isFinite(t) || Math.abs(now / 1000 - t) > 300) return false;
const expected = createHmac('sha256', secret).update(`${t}.${rawBody}`).digest();
const given = Buffer.from(parts.v1 ?? '', 'hex');
return given.length === expected.length && timingSafeEqual(given, expected);
}
  • Answer 2xx within 10 seconds, then process the event in a background job. Any other answer, or none, is retried with backoff for 3 days.
  • Delivery is at least once: dedupe on the event id.
  • Order is not guaranteed. Read GET /v1/cards/{card_id}, or GET /v1/loads/{load_id} for a load, for the current state instead of trusting the latest event you received.

A webhook can be missed: your endpoint was down for longer than the retries, or the URL changed. A missing webhook never means a failed payment. Keep a background job in your application:

  1. Save the order and returned card_id.
  2. Schedule a status read while the record is pending (GET /v1/loads/{load_id} for a chain load).
  3. Persist the latest status; stop on issued (succeeded for a load), failed, or, for a card from POST /v1/cards, in_doubt. A chain card or load in in_doubt is reconciled by Zwipe: keep reading it at a slow interval until it turns final.
  4. Route uncertain POST /v1/cards records into your reconciliation process, including a balance read only when the issuer card ID is present.
  5. Notify your customer through your own app after your backend confirms the outcome.

A card still pending well past a few minutes gets no event: replay the original request with the same external_ref, which requeues an unclaimed order without ordering twice.

Make the worker resumable after a restart. A missed polling job must not create another financial order. With webhooks on, the worker can run rarely, as a sweep for anything still pending.