Cancel Payment Order
Cancel an open payment order from your backend using your merchant credentials.
The main use case is clearing the pending-order 409 returned by
/payment-flex/create: only one open FLEX order is allowed per customer
account at a time, so a second create returns
{
"success": false,
"code": 409,
"error": "you have a pending payment order. complete or cancel it first.",
"data": { "pending_order_id": "THBP20260613123300zBuseUwN" }
}
Call /payment/cancel with that pending_order_id to cancel the stuck order, then retry the create.
The customer can also cancel from the hosted payment page itself. This endpoint is the server-to-server equivalent for your backend.
URL : /payment/cancel
Method : POST
Request
{
"merchant_id" : "[Merchant id]",
"token" : "[Auth Token]",
"time" : "[Time Stamp]",
"platform_order_id" : "[platform order id to cancel]"
}
| param name | description | example |
|---|---|---|
| platform_order_id | The payment gateway order id to cancel. Use the pending_order_id from the FLEX 409, or the platform_order_id from create. | THBP20260613123300zBuseUwN |
Data example
{
"merchant_id": "AA12345678",
"token": "testtokentesttokentesttokentesttokentesttoken",
"time": 1656272222,
"platform_order_id": "THBP20260613123300zBuseUwN"
}
When can an order be cancelled?
A cancel succeeds only when all of the following hold:
- The order belongs to your merchant account.
- The order status is
open(not yet paid, expired, or already cancelled). - No payment slip has been uploaded for the order yet.
On a successful cancel the system also:
- releases the pending-order guard — so you can immediately create a new order for the same customer account,
- sends a
CANCELLEDpayment callback to yournotify_url(see Payment Callback).
⚠️ A cancel is not always final: in some cases the order may still be paid afterwards, in which case a subsequent
PAIDcallback follows for the sameplatform_order_id— always treatPAIDas authoritative.
Success Response
Code : 200 OK
{
"success": 200,
"data": {
"platform_order_id": "THBP20260613123300zBuseUwN",
"merchant_order_id": "ORDER0123456789789445566",
"status": "cancelled"
}
}
A retry of a cancel on an already-cancelled order also returns 200 (with "already_cancelled": true)
— the call is idempotent.
Error Responses
Condition : Invalid merchant id, token, or signature
Code : 403
{ "error": { "code": 403, "message": "authentication failed" } }
Condition : Order not found (or not owned by you), or an invalid platform_order_id
Code : 500
{ "error": { "code": 500, "message": "platform order id not found" } }
Condition : Order exists but cannot be cancelled — not open, or a slip was already uploaded.
Code : 409
{ "success": false, "code": 409, "error": "order not open" }