This page shows how to cancel an order, and what to do when you can’t. Your API key needs the orders:create permission.
Cancel order moves an order to the final status canceled. It also stops any fulfillment that hasn’t started yet.
Cancel an order when you have given up on it. For example:
- a
failedorder after aplayer_id_incorrectfailure, or - an
action_requiredorder that you won’t act on.
This keeps your records and Cardzone’s records the same.
Send a cancel request
curl -X POST https://cardzone.ai/api/b2b/v1/orders/1CBDzqwiovwVrtFk6nZ1Aw/cancel \
-H "Authorization: Bearer $CARDZONE_API_KEY"In the path, use the order_id or your merchant_order_ref:
- The
order_idworks for any order in your store. This includes orders from the dashboard, Salla, and other Cardzone channels. - The
merchant_order_refonly finds orders created through the API.
What you get back:
- A successful cancel returns
200with the order. Its status is nowcanceled. - If you send the same cancel again, you get
200again. - If the order became
canceledin another way (without a cancel request), you get409 order_not_cancelablewithdetails.reason_codeset toorder_already_terminal.
When an order can’t be canceled
You can cancel an order only when both of these are true:
- Its status is
processing,action_required, orfailed. - No fulfillment attempt or provider request is running, and no shipment has left. (A provider is a supplier that delivers the item.)
Otherwise you get 409 order_not_cancelable. details.reason_code tells your code why:
{
"error": {
"code": "order_not_cancelable",
"message": "This order cannot be canceled while an execution or provider request is still in progress",
"details": { "reason_code": "fulfillment_in_progress" }
}
}details.reason_code |
Meaning | What to do |
|---|---|---|
order_already_terminal |
The order is already fulfilled, canceled, or refunded. |
Read its status. There is nothing to cancel. |
fulfillment_in_progress |
A fulfillment attempt or provider request is still running. | Wait for the next status change, then decide. |
shipment_dispatched |
A physical shipment for the order has left. | There is nothing to cancel. Contact support for a return. |
order_not_cancelable |
Another rule blocked it. | Read message. Contact support if you are not sure. |
Cancel in the sandbox
The sandbox doesn’t save orders. So with a sandbox API key, cancel always returns 403 sandbox_order_cancellation_not_supported:
POST