Due to the payment gateway issue, the payment result will be sent from payment gateway to us via a notification service. So we need to create the order first and not start process the order before we receive the payment result. Also some payment need a manually review, we need to hold the order before we make the decision.
We need 2 additional order status: WaitingForPayment and ManuallyReview
WaitingForPayment will be our initial order status instead of Pending. There is a GlobalOrderPolicy section in environment policy file (PlugIn.Habitat.CommerceAuthoring-1.0.0.json), change the value of CreatedOrderStatus from Pending to WaitingForPayment.
We also create a new list(WaitingForPaymentOrders) to store these orders. By default the order will add to PendingOrders list after created. If the order in the PendingOrders list not in Pending status, these order will be moved to Problem list which we don't want that. To fix this we need to create a new block add to ICreateOrderPipeline after CreateOrderBlock. The code looks like below:
Now we need to get out WaitingForPaymentOrders list working. We need to create a mapping between table name and list. Open the policy file - PlugIn.SQL.Sharding.PolicySet-1.0.0.json, we can add our new list to the exists section or create a new one.
You will be able to filter out the order by using new status.
We also need a new API that save the payment message to order entity and a minion that process the payment message move the order to next step.