Order fullfilment process - Alternative flow

An alternative order fulfillment flow is for ERP system to pack the items for an order, and capture the money for the delivery, and then hand it over to the delivery company. This section describes this alternative flow.

This is different from Order fulfillment process main flow, where ERP system will handover the delivery package to the delivery company before it knows the payment capture has succeeded.

Fullfilling an order

When the ERP system has created the delivery package, but before handing it over to the shipping provider company, call the following endpoint first to register the shipment and capture money for it.

/Litium/api/connect/erp/orders/{orderId}/shipment

When a shipment is created, following steps are taken in Litium.

  1. Create the appropriate delivery with delivery rows (if a partial shipment Litium automatically calculates the shipment value)
  2. Litium captures the amount due from customer. (If the funds are already reserved).
    Important In Litium 7 Accelerator previous releases, the payment is captured when a delivery is set to delivered from accelerator state transitions, in the DeliveryStateBuilder.cs . This should  not be done now, since Litium Connect is managing the payment capture. The correct code should be as follows when going to Delivered state should not have any payment captures.
    var delivered = new State<DeliveryCarrier>((short)DeliveryState.Delivered,
    DeliveryState.Delivered.ToString(),
    (deliveryCarrier, currentState, token) =>
    {​​
    
    //_orderUtilities.CompletePayments(ModuleECommerce.Instance.Orders[deliveryCarrier.OrderID, token], token);
    
    }​​,
    null);

Listen to the event

Litium.Connect.Erp.Events.ReadyToShip

This event means, the delivery is ready to ship.

This webhook means the delivery is ready to ship now, and when this event is received, notify the ERP system to handover the package to the delivery company.

When the package is handed over to the delivery company, call following end point to notify Litium.

/Litium/api/connect/erp/orders/{orderId}/deliveries/{deliveryId}/notify/delivered

Litium will set the delivery status to "Delivered" when the above end-point is called.

Webhooks on payment capture and failures

You may listen additionally to following endpoints, and take appropriate action on payment failures or successful capture. (requires Litium 7.5 and above)

Litium.Connect.Erp.Events.PaymentCaptured
Litium.Connect.Erp.Events.PaymentCaptureFailed

Order fullfilment diagram : 

readyToShip.PNG