2.How to complete an order in medusa

Question

How can I finish (or complete) an order? I already run Capture an Order -> Create a Fulfillment -> Create a Shipment successfully, but the order status is “pending” in DB. (in Ubuntu / medusa version v1.7.12)

Answer

You can create a simple subscriber, that listens for order completion events:

1
2
3
4
5
6
7
8
9
10
11
12
class OrderSubscriber {
constructor({ orderService, eventBusService }) {
this.orderService_ = orderService;
eventBusService.subscribe("order.placed", this.handleOrderPlaced);
}

handleOrderPlaced = async (data) => {
return await this.orderService_.update(data.id, { status: "completed" })
};
}

export default OrderSubscriber;

![](2.How to complete an order in medusa/1.png)