How to keep duplicate webhooks from creating duplicate orders

An order leaves your storefront and reaches the warehouse. A few seconds later the storefront sends the same event again because it never received a response. The warehouse system sees a fresh request and creates a second pick ticket. This is a common shape for an integration failure. Two services each completed a step that looked reasonable from their own side, and nobody decided who would recognize a second delivery as part of the same business action.

Write down what a delivery is allowed to do

List each event you accept and the business change it is allowed to trigger. For a paid order, fulfillment might create a shipment request when the order is eligible to ship. For a refund, accounting might post an adjustment against an existing transaction. Include the provider event identifier, the business record identifier, and which system owns the current status. If the provider can emit two event types for the same transition, decide whether both are needed and where to recognize that they describe the same change.

Confirm how the provider retries, signs, and identifies events before writing the receiver. A provider can retry after a timeout, and a manual resend may also happen while automated retries are still active. Some providers deliver events out of order. Build the receiver around those conditions and document how it decides whether the business record has already moved past the incoming event. Stripe webhook delivery documentation

Save the delivery before you acknowledge it

A practical receiver verifies the sender’s signature, checks basic request requirements, and writes the delivery to a durable inbox or queue. It returns a successful response once that handoff has succeeded. Then a worker can read the delivery and make business changes in the background. Set an explicit retry policy for worker failures and give stalled deliveries an operator-visible state.

Use a unique database constraint on the provider and delivery identifier when those fields can identify a retry. A database constraint protects against two copies booking the same slot at the same time. Keep a second record of consequential actions keyed by a stable business identifier. For example, a fulfillment system might allow a single initial shipment request for each order and use a separate key for each legitimate split shipment. Keep the event payload and retention period proportionate to support needs and privacy requirements. GitHub webhook best practices

Decide how to recover from a partial success

In the warehouse example, the fulfillment API might create the shipment request while its response gets lost. Retrying the same action is safer if the downstream system accepts an idempotency key, a stable identifier for the intended effect. Store that value and use it again on retry. Make sure the downstream system scopes and retains the key long enough for your retry window.

Accelerate Your Engineering Velocity

Looking to scale your infrastructure, implement enterprise AI automation, or secure critical cloud dependencies? Partner with MyNew Technologies LLC to engineer robust technical systems built for enterprise efficiency.

Request Technical Consultation

When a downstream system has no equivalent, look up the external record using a stable reference before retrying. Where the result is uncertain and duplication is expensive, surface that case for investigation. A request ID and the last known state give an operator a concrete place to begin. Also decide how to handle a key reused with different input. Two requests may need manual review if they have the same key and disagree about a shipment address or quantity. AWS guidance on safe retries with idempotent APIs

Test a day when the connection misbehaves

In staging, deliver the same event twice. Then submit two copies together, deliver older and newer events out of order, and stop the worker after a downstream action succeeds. Check the warehouse or accounting records after each test. Confirm that operators can find stuck deliveries and replay one without accidentally creating a second charge, confirmation, or shipment. Test a failed signature as well and confirm that it produces no business action.

Give someone ownership of reconciliation. Compare order or fulfillment records at an interval that fits the time you can tolerate missing a delivery. A list of outstanding orders with their event status is often enough to let operations spot a gap before the warehouse closes for the day. A reliable release demonstrates that a delivery can fail, be retried, and arrive at the intended business outcome with a clear audit trail.

Need help? If your store, warehouse, or accounting system disagrees about which orders were processed, a systems integration consultation can help map the event flow, identify duplicated actions, and set recovery priorities.

Advertisement

Related

How to keep secrets out of application logs

Define safe event fields, test every telemetry destination, and verify redaction without losing the evidence needed to investigate a failure.

How to test Magento refunds before issuing customer credits

Rehearse partial refunds, payment settlement, shipping adjustments, and stock returns with evidence that connects the credit memo to the money movement.

How to prepare a database change for a rolling release

Plan compatible schema changes, resumable backfills, and explicit rollback checks while old and new application versions overlap.

How to test Magento promotions before customers use them

Build representative carts to verify promotion boundaries, competing rules, tax, shipping, and the amounts recorded on a Magento order.

How to test a SaaS data export before renewal

Check that a software export preserves the records, attachments, relationships, and history your team needs before the next subscription renewal.