This article describes in detail how the order state machine in the accelerators are implemented.
The order state machine in the accelerator is shown below. All the transitions are done automatically based on delivery state and payment state transitions except from the Attention state to ClosedByAdmin state.
That is, when the delivery state and payment state change, the order state is automatically changed (according to the restrictions shown in the diagram).

Waiting confirmation
All orders in both B2B and B2C accelerators enter the WaitingConfirmation state. In the B2C state machine orders automatically pass through the WaitingConfirmation state straight to Confirmed state when the payment is done. In the B2B state machine, the order will remain in the WaitingConfirmation state until an order approver approves the order. If the order is being placed by an approver, it will be automatically confirmed (if the payment is Paid, Reserved or Pending)
Order confirmation
Order confirmation is automatically performed when the payment goes to either Paid, Reserved or Pending state in B2C, and when an administrator with an Approver role approve an order in B2B.
The Confirmed state can only be reached from the WaitingConfirmation state, it cannot be reached from any other state. Therefore an order can only be confirmed once and when an order is getting confirmed, its payment is guaranteed to be either Paid, Reserved or Pending.
When the Confirmed state is reached, the following actions are performed:
- The stock balance is reduced based on order quantity values.
- The campaign calculator is notified (to deactivate any voucher codes used).
- An order confirmation email is sent to the customer.

Order processing
An order is set to Processing automatically when at least one delivery has started, i.e. moved away from the Init state.
Order completion
The order is automatically set to Completed when its payment is Paid and all deliveries Delivered.
Order cancellation
The order is set to Cancelled automatically when all deliveries are cancelled (or none of the deliveries are started, i.e. in Init state) and all payments are either cancelled or returned back to the end customer.

Attention state
The order is set to Attention when administrative attention is needed. The following two scenarios are considered needing administrator attention:
- The order was in the Completed state, all deliveries were returned, but the payment was not returned or cancelled.
- The order was in the Processing state, and at least one delivery was cancelled, but the payment was not cancelled or returned.
From the Attention state, the administrator can choose the ClosedByAdmin order state in back office to close the order irrespective of its delivery and payment states. Or the administrator has the option to perform actions that will make the delivery and payment states appropriate for the order to be set automatically to Completed, Returned or Cancelled.

Returned state
Order is set automatically to Returned state when all deliveries are returned, and the payment is returned or cancelled.