On this page
The order in which a worker sees messages is not a safe definition of the order’s business history. Queues, retries and parallel processing can make an older snapshot reach a decision point after a newer state is already known. A reward integration needs an explicit rule for resolving that conflict.
Consider a hypothetical purchase that is created with two eligible items and later changed to one. The integration processes the newer state first, then receives an older event describing two items. If the worker simply overwrites its record with the latest arrival, it can restore an obsolete reward input.
Record event time and processing time separately
Shopify webhooks communicate resource events through subscribed topics and payloads. The integration should record the source metadata available under the selected contract alongside its own receipt and processing times. Shopify webhook concepts
Do not collapse all timestamps into one field named updated_at. The source resource’s update time, the event’s available timing metadata, the receiver’s intake time and the worker’s processing time answer different questions. A late worker can have the newest processing time while holding the oldest purchase facts.
For the hypothetical two-item order, an internal timeline might be:
| Time category | Earlier purchase state | Later purchase state |
|---|---|---|
| Source state established | 10:00, two eligible items | 10:05, one eligible item |
| Integration receives event | 10:07 | 10:06 |
| Worker processes event | 10:08 | 10:06 |
| Correct current interpretation | Historical evidence | Newer established purchase facts |
These times are fictional and illustrate a scheduling problem, not a claim about a particular Shopify delivery incident.
Keep the source version or revision evidence available under the actual API. A timestamp alone may not provide a complete ordering guarantee, especially when two changes share a resolution or involve different resource types. The contract should state what the service can compare and when it must fetch authoritative current data instead.
Do not use a customer’s device clock for this decision. Browser time can help display information, but the backend needs trusted source and processing evidence. The purchase’s approved business cutoff is also separate from the time the worker happened to run.
Resolve conflicts using a documented source-of-truth rule
Write the resolution rule before implementing the queue consumer. One possible design treats a valid event as a signal to refresh the required current order facts through authorized access. Another uses a supported source revision comparison for fields whose semantics are established. The right choice depends on the actual data contract and the reward rule.
For the fictional purchase, the integration can preserve both observed snapshots while maintaining one current projection based on the established source state. The older event remains useful evidence that an earlier purchase version existed. It does not automatically gain authority to replace the newer projection.
An original resolution sketch is:
record_verified_event_with_source_and_processing_metadata()
known = load_current_purchase_projection()
if incoming_state_is_demonstrably_older_than(known):
retain_as_history_without_reversing_current_state()
else if ordering_is_ambiguous:
refresh_required_facts_from_authorized_source()
resolve_or_mark_uncertainty_explicitly()
else:
apply_validated_projection_update()
reevaluate_only_the_next_action_permitted_by_current_business_state()
This pseudocode is an illustrative architecture. It does not assume a particular Shopify field provides a universal monotonic revision or that RebateCardX exposes these state names.
Separate source facts from reward workflow state. A newer order snapshot can change the information used for review, but it does not authorize arbitrary reversal of a completed provider operation. If the reward was already approved or issued, the applicable order-change process governs the next action. The event handler should not attempt to recover spent value merely because it sees a return-related fact.
Avoid simplistic status ranking. States such as paid, refunded, fulfilled and canceled do not necessarily form one universal ladder where a “higher” label always wins. Different fields represent different dimensions of the purchase. Define the relevant source-of-truth rule for each fact used by the approved evaluation.
A difficult case is a late event that contains evidence needed for a historical eligibility question. Ignoring it entirely because it is old can lose useful information. The safer design distinguishes updating the current projection from preserving historical evidence. An old event may inform a reviewed past-state question without overwriting what is currently known.
Record the reason for each conflict decision. A note such as “older source revision retained as history; current order refreshed” is more useful than a generic “event skipped.” It tells the next investigator why the system did not take the action the old payload might appear to suggest.
Test late updates against already processed order changes
Construct fixtures that intentionally arrive in the wrong processing order. A test suite that submits creation, payment and change events only in neat chronological sequence cannot establish resilience to late work.
For the hypothetical purchase, test the later one-item state first and the earlier two-item state second. The normalized current quantity must remain one under the chosen authoritative rule. The history can retain both observations, and the reward operation should remain linked to the same purchase.
| Fixture | Expected result |
|---|---|
| Older snapshot arrives after newer state | Current projection does not regress |
| Two states have ambiguous ordering evidence | Authorized refresh or explicit unresolved state |
| Duplicate old event arrives repeatedly | History and operation identity remain controlled |
| Late event follows a completed reward action | Approved change process, not automatic new issuance |
| Historical evidence arrives late | Retained for the relevant reviewed question |
| Source refresh is temporarily unavailable | No guessed overwrite of established facts |
Inspect both state and side effects. The current projection can be correct while a worker still triggers an obsolete reward operation before discovering that its event was stale. The acceptance test should confirm that the consequential action gate uses the resolved state, not the raw incoming payload.
Add a concurrent case. Two workers can each read the same current projection and then attempt conflicting updates. The storage design needs an atomic comparison, transaction or equivalent mechanism appropriate to the source revision contract. A correct sequential algorithm does not automatically remain correct under parallel execution.
For a filled decision record, retain the fictional order reference, source-state evidence, receipt time, processing time, prior current projection, resolution reason and resulting permitted action. A reviewer should be able to reconstruct why the older two-item snapshot did not restore a larger reward input.
Test the failure of the source refresh separately. If the authoritative API is unavailable, the system can preserve the last established projection and mark the new evaluation unresolved. It should not treat a failed refresh as permission to trust an ambiguous event more strongly than before.
The final result is a state-resolution policy with observable conflict tests. It lets the integration use events as timely signals while keeping the customer’s reward decision tied to established purchase facts, rather than whichever worker happened to finish last.
Review a mixed-dimension fixture as well. The newer source state may establish fulfillment while a separate field records a payment change. A single ranked status can lose one of those facts. The normalized model should retain the relevant dimensions independently and let the approved reward rule decide which combination permits the next action. In the test record, show the source evidence for each field and the resulting evaluation inputs. This makes the conflict policy reviewable when two events concern the same order but do not describe identical aspects of its state. It also prevents a seemingly newer label from erasing a fact that remains relevant to the customer’s entitlement.
Review event sequencing requirements through Rebate Card X technical access.
Source references
This guide is general information, not financial, legal, tax or regulatory advice. Eligibility, card availability, permitted use and responsibilities depend on the applicable offer and card terms.
