On this page
EndpointRequest BodyRequest HeadersExample RequestExample ResponseCancellation RulesError CodesCancel Order
Cancel a payment order that has not yet been paid. This endpoint uses header-based HMAC signing.
Endpoint
POST /v4.0.0/pay/orders/cancel/apiRequest Body
| Field | Type | Required | Description |
|---|---|---|---|
accessKeyId | string | Yes | Your merchant Access Key ID |
payOrderId | string | Yes | HashNut order ID |
merchantOrderId | string | Yes | Your unique order identifier |
Request Headers
See Authentication for the required HMAC signing headers:
hashnut-request-uuidhashnut-request-timestamphashnut-request-sign
Example Request
json
{
"accessKeyId": "ak_test_abc123",
"payOrderId": "PO202606210001",
"merchantOrderId": "ORDER-20260621-001"
}Example Response
json
{
"code": 0,
"msg": "success",
"data": {
"payOrderId": "PO202606210001",
"state": -3
}
}Cancellation Rules
- Only orders in the
INIT(0) state can be canceled. - Orders that have already received a payment (
PAID,CONFIRMING,SUCCESS, etc.) cannot be canceled. - Canceled orders transition to the
CANCELED(-3) state. - Cancellation is irreversible.
WARNING
When an order is canceled, its assigned receipt address is released back to the address pool. If the customer sends funds to that address after cancellation, the payment may be attributed to a different order or go undetected. Ensure your frontend removes the payment address from display immediately upon cancellation.
Error Codes
| Code | Description |
|---|---|
0 | Success |
1001 | Invalid parameters |
1002 | Authentication failed |
2001 | Order not found |
2002 | Order is not in INIT state (cannot cancel) |
