|
1 |
| -### Order flow |
| 1 | +Inventory transactions refer to the various actions that take place to adjust stock levels, such as receiving, storing, or shipping goods. Inventory transactions are tied to orders as each step of an order triggers changes in inventory levels. |
2 | 2 |
|
3 |
| -There are three mandatory steps to complete an order in relation to inventory: |
| 3 | +When processing an order, there are three mandatory inventory-related steps that must be completed. |
4 | 4 |
|
5 |
| -1. Added to a cart |
6 |
| -2. Checked out |
7 |
| -3. Paid |
8 |
| -4. Shipped (optional) |
9 |
| - |
10 |
| -#### Unpaid order flow |
11 |
| - |
12 |
| -The following flowchart depicts the process of an unpaid order. |
13 |
| - |
14 |
| - |
15 |
| - |
16 |
| -#### Payment flow |
17 |
| - |
18 |
| -The following flowchart depicts the process of paying for an order. |
19 |
| - |
20 |
| - |
21 |
| - |
22 |
| -### How stock is managed |
23 |
| - |
24 |
| -Stock is managed as follows: |
25 |
| - |
26 |
| -1. When a customer attempts to add products to a cart, the inventory service checks if there is enough available stock. If there is not enough stock available, you receive a 400 HTTP response with a warning. The response does not describe what products cannot be added, nor does it return how many products are in stock. |
27 |
| -2. If a customer successfully adds products to a cart, the customer can checkout to create an unpaid order. |
28 |
| -3. A final check on the available stock is performed. |
29 |
| -4. After creating the unpaid order, the payment for an order can be taken. When a customer attempts to pay for an order, the inventory service reserves the stock before the payment is processed internally. At any time before the point of payment, a customer might lose their order, if the customer is slower than everyone else. |
30 |
| - |
31 |
| -If the payment fails, the temporary stock allocation is removed, and the stock becomes available again for anyone to buy. |
32 |
| - |
33 |
| -If the payment succeeds, that stock is still allocated, and the items belong to the customer, unless for any reason they are reallocated before shipment. For example, if the customer cancels, or you realize the order is fraudulent, then you can reallocate the inventory. |
34 |
| -5. Finally, when the order is marked as shipped, that stock is fully decremented. This means the allocation number is reduced, and therefore the total, and the products are no longer in the warehouse. |
35 |
| - |
36 |
| -During split payments, stocks are allocated only if the first transaction for an order is complete. If the transaction fails, the stocks are deallocated. Once the first transaction is complete, the stocks are not allocated for the subsequent transactions as they are already reserved for the order. The stocks are deallocated and return to available when the the order is canceled. |
| 5 | +1. Adding a product to a cart. |
| 6 | +1. (*Optional*) Choosing a location |
| 7 | +1. Checking out a cart. |
| 8 | +1. Paying for an order. |
| 9 | +1. (*Optional*) Shipping an order. |
0 commit comments