Skip to content

Emit order completed event after status update#258

Open
PremSharma-Intelegencia wants to merge 1 commit into
fleetbase:mainfrom
blockalicious-io:fix/order-completed-webhook-timing
Open

Emit order completed event after status update#258
PremSharma-Intelegencia wants to merge 1 commit into
fleetbase:mainfrom
blockalicious-io:fix/order-completed-webhook-timing

Conversation

@PremSharma-Intelegencia
Copy link
Copy Markdown

@PremSharma-Intelegencia PremSharma-Intelegencia commented Jun 2, 2026

Summary

This PR updates Order::complete() so the order.completed lifecycle event is emitted only after the order has been updated to the completed state.

Previously, notifyCompleted() was called before the completed activity/status was applied. As a result, lifecycle event consumers could receive an order.completed event while the order still exposed its previous status.

Background

Downstream listeners build lifecycle payloads from the order state at the time the completion event is emitted.

The previous order of operations was:

  1. Emit the order completed event
  2. Apply the completed activity/status

This could cause stale order data to be captured by event listeners and included in webhook payloads.

Changes

  • Move notifyCompleted() after the completed activity update in Order::complete()
  • Keep notifyCompleted() outside the completed-activity guard so callers that already applied the completed activity still emit the completion event
  • Update the method docblock to reflect the actual order of operations

Related PRs

Move Order::complete() so it applies the completed activity before firing the completion event. This keeps lifecycle event consumers from seeing stale order state while preserving the existing behavior that complete() emits the order completed event even when the completed activity was already applied by the caller.
@PremSharma-Intelegencia PremSharma-Intelegencia changed the title Fix order.completed event timing after status update Emit order completed event after status update Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants