My app helps users manage orders. Regardless of how they are received, some of them show up in the Orders list (IE - pretty much any that aren’t created from the register, especially future orders from an app or Square Online). When they mark the order as complete in my app, I send an API call to update the fulfillment status to COMPLETED, like this:
const endpoint = `orders/${orderId}`;
const requestBody = {
"order": {
location_id: locationId,
version: orderVersion, // Required for optimistic concurrency control
fulfillments: [{
uid: fulfillmentId,
state: 'COMPLETED'
}]
}
};
When I do that, I’d expect them to show up in the Completed Orders list, but they don’t.
What do I need to use for state to get them to show up properly in the completed list?
I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:
Additional Documentation
Orders API: How It Works
Orders API
Create Orders
If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.
To ensure that orders show up in the Completed Orders list, you need to update both the fulfillment state and the order state to COMPLETED. Updating only the fulfillment state to COMPLETED is not sufficient for the order to appear in the Completed Orders list. Here’s what you need to do:
-
Update the Fulfillment State: As you are already doing, update the fulfillment state to COMPLETED.
-
Update the Order State: You also need to update the order state to COMPLETED. This is necessary because the order state determines the overall status of the order, and only orders with a COMPLETED state will appear in the Completed Orders list.
Your API call should include both updates. Ensure that you have the correct version number for the order to avoid concurrency issues. Here’s a conceptual approach:
- Update the fulfillment state to COMPLETED.
- Update the order state to COMPLETED if all fulfillments are completed.
Make sure to check that there are no pending fulfillments before setting the order state to COMPLETED. If there are multiple fulfillments, all must be completed before the order state can be set to COMPLETED.
This answer was reviewed by @Bryan-Square.