DuevanceAPI documentation

Webhooks

Endpoints, events, payloads, signatures and retries.

Webhooks tell your server when something happens: a payment settles, a refund completes. Each event is written in the same database transaction as the change it describes, so an event is never lost and never sent for a change that didn't happen.

Endpoints

An endpoint belongs to one project and one environment: test events go only to endpoints made with a test key.

POST /v1/webhook-endpoints (scope write)

FieldRules
urlhttps (test mode also takes http), no credentials, at most 2048 characters. Every address the host resolves to must be public
descriptionAt most 255 characters
enabled_events1 to 20 event types from the list below, or ["*"] for all (default)

The answer is 201 with the endpoint and its signing secret, whsec_…. The secret is shown once, here; it never appears again.

{
  "id": "whe_0D4r…",
  "object": "webhook_endpoint",
  "environment": "test",
  "url": "https://shop.example/duevance",
  "description": null,
  "enabled_events": ["*"],
  "status": "active",
  "previous_secret_expires_at": null,
  "created_at": "2026-12-03T10:00:00Z",
  "secret": "whsec_7Hk2…"
}
RequestDoes
GET /v1/webhook-endpointsLists the endpoints (scope read)
GET /v1/webhook-endpoints/{id}One endpoint, without its secret (scope read)
PATCH /v1/webhook-endpoints/{id}Changes url, description, enabled_events or status (active, disabled)
DELETE /v1/webhook-endpoints/{id}Deletes it and its pending deliveries
POST /v1/webhook-endpoints/{id}/roll-secretA new secret, shown once in the answer. The old one keeps signing next to it for 24 hours

Events

EventWhen
payment.authorizedThe card was approved and the amount is held, waiting for a capture.
payment.succeededThe payment was captured: money moved.
payment.declinedThe acquirer, or a routing rule, declined the payment.
payment.failedThe payment provably never reached an acquirer. Nothing was charged.
payment.expiredThe payment was abandoned before any acquirer answer, or a hold lapsed.
payment.canceledAn authorization was voided.
refund.succeededA refund was confirmed by the acquirer.
refund.failedA refund was declined or could not be sent; its amount is refundable again.
checkout_session.completedA checkout session was paid.
checkout_session.expiredA checkout session expired unpaid.

processing sends nothing: an unknown outcome always resolves into one of these.

Test events

The dashboard's Send test event button delivers one webhook_endpoint.test event to that endpoint only, whatever its enabled_events, signed like every other delivery. Its data.object is { "id": "whe_…", "object": "webhook_endpoint", "url": "…", "test": true }. Nobody subscribes to it; answer it with a 2xx like any event, or ignore unknown types.

Payload

Each delivery is a POST of the event, with Content-Type: application/json:

{
  "id": "evt_0D4s…",
  "object": "event",
  "type": "payment.succeeded",
  "environment": "test",
  "created_at": "2026-12-03T10:00:00.130Z",
  "data": {
    "object": {
      "id": "pay_0D4m…",
      "object": "payment",
      "status": "succeeded",
      "amount": 1999,
      "currency": "EUR",
      "captured_amount": 1999,
      "refunded_amount": 0,
      "reference": "order-1001",
      "decline_code": null,
      "metadata": {},
      "created_at": "2026-12-03T10:00:00.004Z"
    }
  }
}

data.object is a snapshot taken when the event happened: the payment fields above; for refund.* a refund with id, object, payment, amount, currency, status, decline_code and created_at; for checkout_session.* a session with id, object, status, mode, amount, currency, reference, payment (the paying payment's id, or null), metadata, expires_at, completed_at and created_at. Fetch the object for its current state.

checkout_session.completed is sent in the same transaction as the payment.succeeded (or payment.authorized) of the payment that paid it; checkout_session.expired when an unpaid session runs out. A session whose charge is still being confirmed when it runs out waits up to an hour more before it expires, so a slow approval can still complete it.

GET /v1/events/{id} (scope read) returns an event exactly as it was sent, for events of your project and environment.

Verifying the signature

Every delivery carries:

HeaderValue
Duevance-EventThe event type
Duevance-Signaturet=<unix seconds>,v1=<hex HMAC-SHA256(secret, "<t>.<raw body>")>

During the 24 hours after a secret roll, the header carries two v1 values, one per secret. Accept the delivery when any v1 matches. To verify:

  1. Split the header on ,; read t and every v1.
  2. Compute HMAC-SHA256(secret, t + "." + raw body) over the raw bytes received, before any JSON parsing.
  3. Compare in constant time with each v1.
  4. Refuse a t more than 5 minutes old, to stop replays.
import crypto from "node:crypto";

function verify(rawBody, header, secret) {
  const parts = header.split(",").map((part) => part.split("="));
  const t = parts.find(([name]) => name === "t")?.[1];
  const expected = crypto.createHmac("sha256", secret).update(`${t}.${rawBody}`).digest();
  const fresh = Math.abs(Date.now() / 1000 - Number(t)) < 300;
  return fresh && parts
    .filter(([name]) => name === "v1")
    .some(([, value]) => {
      const given = Buffer.from(value, "hex");
      return given.length === expected.length && crypto.timingSafeEqual(given, expected);
    });
}

Delivery and retries

Answer with any 2xx within 10 seconds to acknowledge. Anything else, a timeout or a connection error, is retried on this schedule (11 attempts over about three days):

AttemptDelay after the previous oneSince the event
230 s30 s
32 min2 min
410 min12 min
530 min42 min
61 h1 h
73 h4 h
86 h10 h
912 h22 h
101 days1.9 days
111 days2.9 days

After the last attempt the delivery is marked failed. A URL that resolves to a private address, or a live endpoint without https, fails at once; a DNS failure is retried. Redirects are never followed.

A failed or delivered event can be sent again from the dashboard's webhooks page: the same event, with a fresh timestamp and signature.

Events can arrive more than once and out of order. Use the event id to ignore duplicates, and the payment's own status as the truth.