
A paid event can arrive after a refund event. If the receiver treats the last notification to arrive as the latest order state, it can schedule delivery for a purchase that has already been fully refunded.
Use the current order and a monotonic revision to decide whether work is still eligible. Keep the original event as evidence of what arrived. StableIn's merchant example follows that approach, with another order check inside the fulfillment worker. This walkthrough comes from its local demo implementation and source review.
Separate event order from arrival order
Consider this synthetic sequence. The revision numbers are illustrative, not a customer incident.
| What happened | Order revision | When the merchant receives the event |
|---|---|---|
| Payment becomes eligible | 7 | Second |
| Full refund completes | 8 | First |
Processing revision 8 can make the local order fully refunded. The later arrival of revision 7 should not restore delivery eligibility. Event timestamps can help explain the timeline, but the receiver needs a rule for accepting state changes. Sorting the messages already on hand cannot prove that another delayed message will never arrive.
Stripe explicitly warns that its webhook events may arrive out of order. StableIn has its own protocol; the example here uses its order revision and current-order endpoint. Stripe event-ordering guidance.

Illustrative revisions show why arrival order cannot decide which state to keep.
Check the event against the current snapshot
StableIn's receiver locks the local order, checks whether it has already recorded the event and validates the event's order against the saved purchase. It then fetches the current platform order and checks the purchase binding again.
If the API response has a revision below the event revision, the receiver raises ORDER_SNAPSHOT_NOT_CURRENT. It cannot safely reconcile an event using a snapshot that predates that event. The transaction rolls back and the notification needs a later retry.
There is a second comparison. The local order may already contain a revision newer than the API response. The projection update skips an older response, and the fulfillment rule requires the candidate revision to be at least the local revision. These comparisons protect the local state from moving backwards through the paths described here.
A simplified decision table makes the distinction easier to review.
| Event revision | Current API revision | Saved local revision | Decision |
|---|---|---|---|
| 7 | 8, fully refunded | 8 | Record an otherwise valid event; do not queue new delivery |
| 8 | 7 | 6 | Retry later because the API snapshot predates the event |
| 7 | 7 | 8 | Keep the newer local state; do not queue delivery from the older view |
| 7 | 8, partly refunded | 7 | Apply the current state; evaluate the merchant's partial-refund policy |
The last row matters. In the current example, a partial refund can still leave an order eligible for delivery when a positive unrefunded amount remains. A business that wants every refund to stop access needs a different explicit policy. The partial-refund article explains that decision separately.
The worker has its own chance to discover the refund
A queued task can wait while the order changes. StableIn's worker fetches the current order before completing fulfillment. It then locks the local order and its leased task, checks that the lease is still valid, and rejects an API snapshot older than the locally recorded revision.
A full refund known through those checks prevents a new entitlement. Pending or leased work can be cancelled when the projection becomes ineligible. Already issued entitlements remain recorded; the example does not revoke delivered access automatically.
There is a limit to this protection. The payment system and merchant database do not share one transaction. A remote refund can race with the worker's final local commit. Reading current state narrows what the worker knows; it cannot lock the remote payment system against future changes. Your business still needs a rule for a refund discovered after delivery.
For a downloadable file, that may mean revoking future access without pretending to recall a copy already downloaded. For a license service, it may mean a separate deactivation operation with its own retry handling. These are integration choices, not capabilities established by the local entitlement table.
Make the delay observable
For support and engineering, keep the event ID alongside the order reference and the revisions involved in the decision. Record whether a task was queued, cancelled or deferred. Avoid putting secrets or customer payment details into public logs.
Download the event-order worksheet. It includes the four sequences above, an API failure and a refund racing with delivery. They are acceptance cases to run in the target environment, with blank result fields. The source inspection establishes the implemented checks; it does not turn these scenarios into a new end-to-end test report.
For a purchase discussion, ask the developer to demonstrate one delayed event and show the saved order and entitlement records afterwards. StableIn Payments gives us a concrete merchant flow for that review. The network's confirmation policy and the treatment of already delivered access need to be agreed for your product.