State transitions
The states of an order (e.g. confirmed, processing, completed etc.) is managed by the tate transitions system. This section introduces various states configured in Litium and how they are connected to each other.
A normal e-commerce transaction, where goods are sold, can be viewed as having two basic flows.
- The flow of money from the customer to the merchant.
- The flow of goods from the merchant to the customer.
The above two flows fulfills a business transaction, which we commonly call an "order". An order starts when the customer places some goods in the shopping cart and confirms it. Then the customer pays for the order and the merchant delivers the goods, making the order "complete".
In managing the business, it is important to know:
- the status of the order, whether it is confirmed, processing or completed
- the status of the delivery, whether it is delivered, returned or cancelled
- the status of the payment, whether it is paid or failed.
Some of the actions the merchant would take depends on these statuses. For example, a merchant may not start deliveries until the cusomer confirms the order. So, to start deliveries, there should be a confirmed order. And, the merchant may collect the payment only when the delivery is completed.
As you can see above, the entire process of order fulfilment is managed as a set of states and their transitions.
In Litium, this is done by the state transition system. It consists of three main state machines.