Developers
Handling payment webhooks without surprises
2 min read · Exchangeme Business team
Notifications can arrive twice, late or out of order. A few habits make an integration dependable.
Treat every event as a hint
A webhook tells you something changed. Before acting on it, verify its signature and, for anything that moves money, fetch the payment from the API to confirm its current state.
Expect repeats
Networks fail and senders retry, so the same event may arrive more than once. Store the event's identifier and ignore one you have already handled. Make your own requests safe to repeat as well, by sending an idempotency key with each one.
Answer fast, work later
Acknowledge the notification straight away and do the real work in a queue. A slow handler looks like a failed delivery to the sender, which leads to more retries and more duplicates.