PoolByte

Reliable webhooks: Authentication, retries and event matching

· PoolByte Technology

Reliable webhooks: Authentication, retries and event matching

Webhook integration allows an event occurring in one system to be notified to another application via an HTTP request. It can be used in events such as payment result, order update or warehouse movement. For a reliable integration, it is not enough for the request to arrive: the source must be verified, the event must be mapped to the correct record, and repeat notifications must not duplicate the same action.

Separate server notification from browser return

The customer can return to your site or close the tab from the payment screen. The browser arriving at a success address is not the same as the payment provider's trustworthy server notification. Transaction status must be evaluated according to the provider's documented verification method. The user return screen is designed to show the current status to the user clearly.

This distinction also applies to other integrations. The "sent" screen of the warehouse panel and the notification reaching the stock software are different stages. The application should record each stage separately; The text in the UI should not make the transaction appear to be completed if it has not yet been verified. A clear match must be established between the registration IDs of the two systems.

Verify the source of the notification with the provider's method

Not every provider uses the same signature scheme. Details such as signature header, raw request body, and time control should be implemented according to the official document. Do not copy the algorithm of a sample system to another service. Access keys should not be written into logs or customer-facing error messages.

GitHub webhook best practices describes the secure connection and authentication approach. Stripe webhook document documents its notification signature and delivery behavior. These resources are sample providers; The payment or ordering service to be used should be based on its own rules.

Consider it a normal scenario for the same event to occur again.

An event can be submitted more than once. If the recipient responds late, the sender may resend the request if it is not considered successful. The application must recognize the same event ID or job key and securely handle the previously completed transaction. This is called idempotent process design; Not opening service for the second time when it comes back is an example of this.

Errors may occur between event recording and job completion. Therefore, simply recording "the incident has been seen before" may not be sufficient; Consistent management of statuses such as processing, completed, or received an error is required. Database transactions, unique posting rules, and queue design must be addressed together by the developer. It should also be tested if the same notification arrives with two concurrent requests.

Don't base matching on guessed customer information

The email address may be used for customer communication, but should not be considered a reliable payment matching key on its own. Fields such as order ID, provider transaction ID, amount and currency are checked according to the integration's contract. The same customer can place two orders on the same day; Orders of the same consistency can also be found.

If there is a return, partial transaction, or subsequent status change, these may be separate event types. Do not apply the same order status to every notification that shows the word "Successful". Define the application's own state transitions. An unprocessed event should turn into a controlled error record that the authorized team can review, rather than disappearing silently.

Measure delivery and processing separately

If the endpoint accepting the notification performs unnecessarily long work, a timeout may occur. In some architectures, the event is verified and recorded reliably, while the actual work is executed in the queue. It should be clear which stage submitting a success response represents. The response code and response time the provider expects should be verified from its documentation.

Records can include the event ID, delivery time, matching local record, and job result. Impulsively storing the entire request body can unnecessarily duplicate sensitive information. Plan logging, access control, and retention time limited to fields required for diagnosis. Monitoring the number of delays and failed events can signal earlier than waiting for the customer to report an error.

Things to test before release

  • Case study based on valid and correct record.
  • Invalid signature or missing required field.
  • Repeat and simultaneous delivery of the same event.
  • Inconsistent amount, currency or order ID.
  • Unexpected events.
  • Interrupt and controlled retry during processing.

Testing must be performed in the provider's trial environment or authorized testing environment. Manually marking the actual order as paid does not prove that the integration is working. For missing events, separately evaluate the query and reconciliation method supported by the provider.

You can send your integration needs to PoolByte along with the service and event types used . You can refer to the cron automation guide for periodic reconciliation jobs, and the staging guide for controlled trials.