The final phase in the order lifecycle is order completion. This occurs once payment has been successful and the delivery phase is finished.
The order.phase property will be set to completed once all line items have reached a final state — whether each item individually succeeded or failed.
For reference on all statuses (quote, payment, delivery), see the Status Codes page.
order.phase === "completed" does not mean every line item succeeded. The phase reaches completed once all
line items have reached a final state — whether completed or failed. This applies to both single-item and multi-item orders.
You must always check each line item’s delivery.status individually.
Checking Line Item Delivery Status
Once order.phase reaches completed, fetch the order via the GET order API and loop through the lineItems array to determine the outcome of each item. Each line item’s delivery.status can be one of: awaiting-payment, in-progress, completed, or failed.
const apiUrl = "https://staging.crossmint.com/api/2022-06-09";
const res = await fetch(`${apiUrl}/orders/${orderId}`, {
method: "GET",
headers: {
"Content-Type": "application/json",
"x-api-key": process.env.NEXT_PUBLIC_CROSSMINT_API_KEY,
authorization: clientSecret,
},
});
const order = await res.json();
if (order.phase === "completed") {
for (const item of order.lineItems) {
if (item.delivery.status === "failed") {
// Handle item failure
} else if (item.delivery.status === "completed") {
// Handle successful delivery
}
}
}
Recommendations
Think through and implement the call to action that makes sense for your buyers.
Where can they access the purchased item?
If the token was minted to their Crossmint wallet you can provide a direct link and/or render a representation of it.
Even if they minted directly to an existing wallet you can provide a link to display the token in Crossmint. Use the following URL format to display NFTs within Crossmint:
https://www.crossmint.com/user/collection/<chain>:<contractAddress>:<tokenId>
For info on the values to use for <chain> refer to the supported chains page.
What are the next steps?
Can they stake, trade, or utilize the purchase in some way? Tell them how!
Handling Order Failure
If there were any issues with delivery explain what happened and ensure they know that refunds are automatic. Anyone who purchases through Crossmint and has an issue with delivery can contact our support team for assistance.