On this pageEndpointRequest BodyRequest HeadersExample RequestExample ResponseCancellation RulesError Codes

Cancel 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/api

Request Body ​

FieldTypeRequiredDescription
accessKeyIdstringYesYour merchant Access Key ID
payOrderIdstringYesHashNut order ID
merchantOrderIdstringYesYour unique order identifier

Request Headers ​

See Authentication for the required HMAC signing headers:

  • hashnut-request-uuid
  • hashnut-request-timestamp
  • hashnut-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 ​

CodeDescription
0Success
1001Invalid parameters
1002Authentication failed
2001Order not found
2002Order is not in INIT state (cannot cancel)