Financial Technology

Designing payment webhooks you can reconcile

Idempotency, retries, signature checks and audit trails for payout and collection flows.

By Lyftsoft EditorialPublished 2 min read

Payment providers tell your systems what happened through webhooks: a collection succeeded, a payout failed, a refund settled. Webhooks are delivered over the open internet, can arrive late, out of order or more than once, and sometimes not at all. A design that assumes each event arrives exactly once will eventually double-count money or lose it.

Verify every webhook

Treat each webhook as untrusted until verified. Most providers sign the payload; check the signature with the provider’s shared secret or public key, reject stale timestamps to limit replay, and only then parse the body. Never act on a webhook that fails verification, and log the rejection.

Make processing idempotent

Providers retry when your endpoint is slow or returns an error, so the same event will arrive more than once. Store each provider event ID before acting on it, and skip events you have already processed. Apply the same idea to your outgoing requests: send an idempotency key with every payment or payout so a retried request cannot create a second transaction.

Acknowledge quickly, process separately

Return a success response as soon as the webhook is verified and stored, then process it from a queue. Slow downstream systems should not cause the provider to retry, and a failed processing step can be retried by you without asking the provider to resend.

Expect events out of order

A “payout completed” event can arrive before “payout created”. Model each transaction as a state machine, accept only valid transitions, and fetch the current state from the provider’s API when an event does not fit.

Reconcile continuously

Webhooks are notifications, not the source of truth. Run reconciliation against the provider’s reports or API on a schedule:

  1. Match every provider transaction to a ledger entry by reference.
  2. Flag amounts, currencies or states that differ.
  3. Raise transactions that exist on only one side.
  4. Route exceptions to an owner with the evidence attached.

Keep an audit trail

Record the raw verified payload, when it arrived, how it was processed and which ledger entries it changed. When a customer or auditor asks what happened to a payment, you should be able to answer from your own records.

Checklist

  • Signatures and timestamps are verified before processing.
  • Event IDs and idempotency keys prevent duplicates.
  • Webhooks are acknowledged quickly and processed from a queue.
  • Transactions follow explicit state transitions.
  • Reconciliation runs automatically and exceptions have owners.
  • Every change to the ledger can be traced to its source event.

Topics

  • payments
  • apis

Working on this problem?

Tell us about the systems involved. An engineer will reply to arrange a discovery call.