Celmir

Insights · 6 min read

Payment webhooks: how to build them so you never miss an event

Webhooks tell your system that a payment succeeded, failed or was refunded. A few simple rules make the integration reliable.

Most payment events don't happen at the moment your server sends a request. A bank transfer settles hours later, a 3-D Secure check finishes in another window, a refund completes the next day. Webhooks are how the payment platform tells your system that something changed.

Five rules for reliable webhooks

  1. Verify the signature. Check that every webhook was signed by your payment provider before you act on it.
  2. Respond fast, process later. Return a success response as soon as you have stored the event, then process it in the background.
  3. Expect duplicates. Providers retry when they don't get a response. Use the event ID to make processing idempotent, so the same event never ships an order twice.
  4. Don't rely on order. Events can arrive out of sequence. Read the current state of the payment from the API when the order matters.
  5. Reconcile regularly. Once a day, compare your records with the provider's list of transactions to catch anything that slipped through.

Events you should always handle

  • Payment succeeded and payment failed
  • Refund completed
  • Dispute opened and dispute closed
  • Payout sent and payout failed

Test before you go live

Trigger every event type in a sandbox, including retries and failures. Most production incidents with payments come from an event type nobody tested.

Celmir's API sends signed, retried webhooks for every status change, with a sandbox to test them. Get sandbox access.