Cancel an order
Cancels an order before it is completed. If the customer has paid, TapPay refunds the full amount.
Changes in 2026-09-27This operation is not available in this version.
POST /api/v1/commerce/orders/{order_id}/cancelSince 2026-09-27
Authentication
Secret key (Bearer)
Headers
| Name | Type | Required | Values | Description |
|---|---|---|---|---|
TapPay-Version | string | no | ||
TapPay-Timestamp | string | no | ||
TapPay-Nonce | string | no | ||
TapPay-Signature | string | no | ||
Idempotency-Key | string | yes |
Path parameters
| Name | Type | Required | Values | Description |
|---|---|---|---|---|
order_id | string (uuid) | yes |
Request body
| Name | Type | Required | Values | Description |
|---|---|---|---|---|
reason_code | string | yes | ||
message | string | no |
Response 200
| Name | Type | Required | Values | Description |
|---|---|---|---|---|
success | boolean | yes | true | |
data | object | yes | ||
data.order_id | string (uuid) | yes | ||
data.order_no | string | yes | ||
data.channel | string | yes | ||
data.status | string | yes | CREATED, ACCEPTED, AWAITING_PAYMENT, CONFIRMED, IN_PROGRESS, READY, COMPLETED, CANCELLED, REJECTED, EXPIRED, FAILED | |
data.version | integer | yes | ||
data.merchant | object | yes | ||
data.merchant.merchant_code | string | yes | ||
data.merchant.name | string | yes | ||
data.location_id | string (uuid) | yes | ||
data.fulfillment | object | yes | ||
data.fulfillment.mode | string | yes | ||
data.fulfillment.label | string | yes | ||
data.fulfillment.address | object | null | yes | ||
data.fulfillment.address.label | string | null | yes | ||
data.fulfillment.address.text | string | yes | ||
data.fulfillment.address.entrance | string | null | no | ||
data.fulfillment.address.floor | string | null | no | ||
data.fulfillment.address.door | string | null | no | ||
data.fulfillment.address.note | string | null | no | ||
data.fulfillment.address.location | object | null | yes | ||
data.fulfillment.address.location.lat | number | yes | ||
data.fulfillment.address.location.lng | number | yes | ||
data.fulfillment.address.district | string | null | no | ||
data.fulfillment.address.khoroo | string | null | no | ||
data.fulfillment.scheduled_at | string | null | yes | ||
data.fulfillment.ends_at | string | null | yes | ||
data.lines | array<object> | yes | ||
data.lines[].line_id | string | yes | ||
data.lines[].offering_id | string | yes | ||
data.lines[].name | string | yes | ||
data.lines[].quantity | integer | yes | ||
data.lines[].variant_id | string | null | yes | ||
data.lines[].option_ids | array<string> | yes | ||
data.lines[].inputs | object | yes | ||
data.lines[].amount | number | yes | ||
data.lines[].status | string | yes | ||
data.lines[].final_amount | number | null | yes | ||
data.breakup | array<object> | yes | ||
data.breakup[].kind | string | yes | ||
data.breakup[].label | string | yes | ||
data.breakup[].amount | number | yes | ||
data.breakup[].ref | string | null | no | ||
data.total | number | yes | ||
data.fees | array<object> | yes | ||
data.fees[].kind | string | yes | ||
data.fees[].label | string | yes | ||
data.fees[].amount | number | yes | ||
data.fees[].estimated | boolean | yes | ||
data.payable_total | number | yes | ||
data.authorization_type | string | yes | ||
data.authorization_amount | number | null | yes | ||
data.accepted_total | number | null | yes | ||
data.final_amount | number | null | yes | ||
data.stage | object | null | yes | ||
data.stage.code | string | yes | ||
data.stage.label | string | yes | ||
data.stage.description | string | null | no | ||
data.timeline | array<object> | yes | ||
data.timeline[].at | string | yes | ||
data.timeline[].label | string | yes | ||
data.timeline[].status | string | null | no | ||
data.eta_at | string | null | yes | ||
data.tracking | object | null | yes | ||
data.tracking.agent | object | null | yes | ||
data.tracking.agent.name | string | yes | ||
data.tracking.agent.phone_masked | string | null | yes | ||
data.tracking.agent.photo_url | string | null | yes | ||
data.tracking.agent.provider_label | string | null | yes | ||
data.tracking.location | object | null | yes | ||
data.tracking.location.lat | number | yes | ||
data.tracking.location.lng | number | yes | ||
data.tracking.location.at | string | yes | ||
data.tracking.eta_at | string | null | yes | ||
data.tracking.tracking_url | string | null | yes | ||
data.tracking.static_map_url | string | null | yes | ||
data.artifacts | array<object> | yes | ||
data.artifacts[].artifact_id | string | yes | ||
data.artifacts[].kind | string | yes | ||
data.artifacts[].label | string | yes | ||
data.artifacts[].value | string | null | no | ||
data.artifacts[].url | string | null | no | ||
data.artifacts[].valid_from | string | null | no | ||
data.artifacts[].valid_to | string | null | no | ||
data.artifacts[].fallback_url | string | yes | ||
data.actions | array<object> | yes | ||
data.actions[].kind | string | yes | ||
data.actions[].allowed | boolean | yes | ||
data.actions[].deadline | string | no | ||
data.actions[].label | string | yes | ||
data.actions[].url | string | no | ||
data.next_action | object | null | yes | ||
data.next_action.type | string | yes | ||
data.next_action.intent_id | string | no | ||
data.next_action.diff | object | no | ||
data.next_action.diff.lines | array<object> | yes | ||
data.next_action.diff.lines[].offering_id | string | yes | ||
data.next_action.diff.lines[].before | object | null | yes | ||
data.next_action.diff.lines[].before.quantity | integer | yes | ||
data.next_action.diff.lines[].before.amount | number | yes | ||
data.next_action.diff.lines[].after | object | null | yes | ||
data.next_action.diff.lines[].after.quantity | integer | yes | ||
data.next_action.diff.lines[].after.amount | number | yes | ||
data.next_action.diff.total_before | number | yes | ||
data.next_action.diff.total_after | number | yes | ||
data.next_action.diff.schedule | object | no | ||
data.next_action.diff.schedule.before | object | yes | ||
data.next_action.diff.schedule.before.scheduled_at | string | null | yes | ||
data.next_action.diff.schedule.before.ends_at | string | null | no | ||
data.next_action.diff.schedule.after | object | yes | ||
data.next_action.diff.schedule.after.scheduled_at | string | null | yes | ||
data.next_action.diff.schedule.after.ends_at | string | null | no | ||
data.next_action.url | string | no | ||
data.next_action.until | string | no | ||
data.web_url | string | yes | ||
data.payment_id | string | null | yes | ||
data.cancelled_by | string | null | yes | ||
data.reason_code | string | null | yes | ||
data.created_at | string | yes | ||
data.updated_at | string | yes | ||
data.promotions | array<object> | no | ||
data.promotions[].promotion_id | string (uuid) | yes | ||
data.promotions[].kind | string | yes | ||
data.promotions[].amount | number | yes | ||
data.customer | object | yes | ||
data.customer.contact_name | string | null | yes | ||
data.customer.contact_phone | string | null | yes | ||
data.note | string | null | yes | ||
data.accept_due_at | string | null | yes | ||
data.pending_reschedule | object | null | yes | ||
data.pending_reschedule.scheduled_at | string | yes | ||
data.pending_reschedule.ends_at | string | null | yes | ||
data.handler_system | string | yes | ||
data.payment_due_at | string | null | yes | ||
data.source | object | yes | ||
data.source.channel | string | yes | ||
data.source.partner_name | string | null | yes | ||
data.source.sticker | object | null | yes | ||
data.source.sticker.name | string | null | yes |
Errors
| Code | Status | Message |
|---|---|---|
AUTH-001 | 401 | The API key is missing, invalid or revoked. |
EVT-206 | 401 | Production keys are not accepted in the sandbox. Use a sandbox key (sk_test_/pk_test_). |
EVT-207 | 401 | Sandbox keys are not accepted in production. Use a production key (sk_live_/pk_live_). |
AUTH-018 | 403 | The request came from an IP address that is not on the key's allowlist. |
AUTH-058 | 403 | The API key does not have the scope this operation requires. |
SIG-002 | 401 | The request timestamp is outside the allowed time window. |
SIG-003 | 401 | The request signature is missing or does not match. |
SIG-005 | 409 | This request nonce was already used. |
VAL-014 | 400 | The TapPay-Version header is not a known API version. |
BIZ-004 | 403 | The terminal is not active. |
BIZ-005 | 403 | The merchant account is not in a state that allows this request. |
VAL-002 | 400 | A required field or header is missing. |
VAL-010 | 409 | This Idempotency-Key was already used with a different request body. |
VAL-013 | 409 | A request with this Idempotency-Key is still being processed. |
ORD-001 | 409 | The order is not in a state that allows this action. |
ORD-010 | 403 | This order is handled by another system. |
ORD-014 | 404 | Order not found. |
ORD-012 | 409 | A payment is in progress. Wait for it to finish. |
curl -sS -X POST "https://api.tappay.mn/api/v1/commerce/orders/ORDER_ID/cancel" \
-H "Authorization: Bearer sk_test_YOUR_SECRET_KEY" \
-H "TapPay-Version: 2026-09-27" \
-H "Idempotency-Key: $(openssl rand -hex 16)" \
-H "Content-Type: application/json" \
-d '{"reason_code":"OUT_OF_STOCK","message":"Milk ran out"}'import { TapPay } from '@tappay-mn/node';
const tappay = new TapPay({ apiKey: 'sk_test_YOUR_SECRET_KEY' });
const result = await tappay.commerce.cancel({ order_id: 'ORDER_ID', body: { reason_code: 'OUT_OF_STOCK', message: 'Milk ran out' } });
console.log(JSON.stringify(result));<?php
require 'vendor/autoload.php';
use TapPay\TapPay;
$tappay = new TapPay(['apiKey' => 'sk_test_YOUR_SECRET_KEY']);
$result = $tappay->commerce->cancel([
'order_id' => 'ORDER_ID',
'body' => [
'reason_code' => 'OUT_OF_STOCK',
'message' => 'Milk ran out',
],
]);
echo json_encode($result);import json
import tappay
client = tappay.TapPay("sk_test_YOUR_SECRET_KEY")
result = client.commerce.cancel({"order_id": "ORDER_ID", "body": {"reason_code": "OUT_OF_STOCK", "message": "Milk ran out"}})
print(json.dumps(result)){
"success": true,
"data": {
"order_id": "0192f8a4-1b2c-7d3e-8f40-5a6b7c8d9f02",
"order_no": "A-1001",
"channel": "WALLET",
"status": "CANCELLED",
"version": 5,
"merchant": {
"merchant_code": "M-SANDBOX-01",
"name": "Sandbox Cafe"
},
"location_id": "0192f8a4-1b2c-7d3e-8f40-5a6b7c8d9f01",
"fulfillment": {
"mode": "PICKUP",
"label": "Pickup",
"address": null,
"scheduled_at": null,
"ends_at": null
},
"lines": [
{
"line_id": "l1",
"offering_id": "0192f8a4-1b2c-7d3e-8f40-5a6b7c8d9f03",
"name": "Latte (M)",
"quantity": 2,
"variant_id": null,
"option_ids": [],
"inputs": {},
"amount": 18000,
"status": "ACTIVE",
"final_amount": null
}
],
"breakup": [
{
"kind": "ITEM",
"label": "Latte (M) x 2",
"amount": 18000,
"ref": "0192f8a4-1b2c-7d3e-8f40-5a6b7c8d9f03"
}
],
"total": 18000,
"fees": [],
"payable_total": 18000,
"authorization_type": "FINAL",
"authorization_amount": null,
"accepted_total": 18000,
"final_amount": null,
"stage": null,
"timeline": [
{
"at": "2026-10-03T08:15:00.000Z",
"label": "Order created",
"status": "CREATED"
},
{
"at": "2026-10-03T08:20:00.000Z",
"label": "Order accepted",
"status": "ACCEPTED"
},
{
"at": "2026-10-03T08:20:00.000Z",
"label": "Paid",
"status": "CONFIRMED"
},
{
"at": "2026-10-03T08:35:00.000Z",
"label": "Cancelled by the merchant",
"status": "CANCELLED"
}
],
"eta_at": null,
"tracking": null,
"artifacts": [],
"actions": [],
"next_action": null,
"web_url": "https://pay.tappay.mn/o/ord_7f3k2m9q",
"payment_id": "0192f8a4-1b2c-7d3e-8f40-5a6b7c8d9f04",
"cancelled_by": "MERCHANT",
"reason_code": "OUT_OF_STOCK",
"created_at": "2026-10-03T08:15:00.000Z",
"updated_at": "2026-10-03T08:35:00.000Z",
"promotions": [],
"customer": {
"contact_name": "Bat",
"contact_phone": "+97699000000"
},
"note": null,
"accept_due_at": null,
"pending_reschedule": null,
"handler_system": "MERCHANT_SYSTEM",
"payment_due_at": null,
"source": {
"channel": "WALLET",
"partner_name": "Sandbox Bank",
"sticker": null
}
}
}
For the full flow, read the orders guide.