A payment webhook is an incoming message about an event. It is not automatically a command to change a wallet balance. Between receipt and business processing, the application needs to establish authenticity, preserve the message, decide whether it has already been handled and apply the correct transition. A durable inbox makes those responsibilities visible instead of hiding them inside one fragile HTTP request.
Verify before accepting business meaning
Validate the provider's documented signature using the required request representation and the correct environment secret. Keep live and test destinations separate. A payload that looks plausible is not sufficient evidence of origin, and a successful transport connection alone does not establish that an event belongs to the expected provider account.
Reject invalid messages without copying secrets or full sensitive payloads into ordinary logs. Preserve enough diagnostic context to investigate configuration problems. Rotate verification secrets through a planned overlap where the provider supports it, and test the deployment sequence so a routine credential change does not interrupt every payment update.
Store first, process through a worker
Write the accepted event to an inbox with its provider identifier, receipt time, event type and processing state. Acknowledge receipt only after the message is durably accepted under the chosen design. Keep expensive downstream work out of the request path so a slow reporting system does not trigger repeated delivery of otherwise valid events.
Give workers a safe claiming mechanism and a bounded retry policy. A worker crash should leave a recoverable record, not an invisible half-finished task. Record the processing attempt separately from the original message so support can distinguish repeated delivery from repeated execution.
Handle duplicates and unexpected order
Deduplicate using the provider's documented event identity and the business operation being affected. Two distinct events can describe the same underlying object at different moments. Do not discard them merely because they share a payment reference, and do not apply the same financial transition twice because the delivery identifiers differ.
Check whether a transition is valid from the last confirmed state. When events arrive out of order, retrieve authoritative status if the provider supports that approach. Preserve the older event for explanation while preventing it from rolling a completed operation backward without a legitimate corrective event.
Give operations a controlled replay tool
Expose failed messages in a queue with a reason, owner and safe replay action. Reprocessing should run the same business safeguards as normal delivery. Avoid a privileged replay path that bypasses idempotency because staff are under pressure to clear a backlog.
Exercise the inbox with duplicate deliveries, delayed messages, invalid signatures and crashes between each persistence step. Monitor the age of unprocessed events and the number of unresolved financial operations. Receiving messages quickly is useful; proving that each relevant event reached a correct, explainable outcome is the operational objective.
The key decisions.
- Authenticate and durably record incoming events before expensive processing.
- Separate delivery identity, processing attempts and business transitions.
- Make replay observable and subject to the same safeguards as normal work.
Sources & further reading
Primary references for the concepts discussed. Check the applicable documentation when planning implementation.







