# logistics.cancelOrder
Call this API at the server side. For more information, see Server API.
This API supports Cloud Calls. The WeChat DevTools version must be
1.02.1904090or later (download the latest stable version here), and thewx-server-sdkversion must be0.4.0or later.
Cancels a waybill.
Calling methods:
# HTTPS Call
# Request Address
POST https://api.weixin.qq.com/cgi-bin/express/business/order/cancel?access_token=ACCESS_TOKEN
# Request Parameters
| Attribute | Type | Default | Required | Description |
|---|---|---|---|---|
| access_token | string | Yes | Credentials to call API | |
| order_id | string | Yes | The ID of the order. It must be globally unique. | |
| openid | string | Yes | The OpenID of the user. | |
| delivery_id | string | Yes | The ID of the express company. See getAllDelivery. | |
| waybill_id | string | Yes | The ID of the waybill. |
# Return Value
# Object
| Property | Type | Description |
|---|---|---|
| errcode | number | Error code |
| errmsg | string | Error message |
Valid values of errcode
| Value | Description | Minimum Version |
|---|---|---|
| 0 | Succeeded | |
| -1 | System failure | |
| 40199 | The waybill ID does not exist. | |
| 9300506 | Cannot be canceled, because traces for the waybill ID are generated. |
# Request Example
{
"order_id": "01234567890123456789",
"openid": "oABC123456",
"delivery_id": "SF",
"waybill_id": "123456789"
}
# Response Example
{
"errcode": 0,
"errmsg": "ok"
}
# Cloud Call
Cloud call is a capability provided by Mini Program·Cloud Base that allows you to call WeChat APIs in a cloud function. It must be used via
wx-server-sdkin the cloud function.
# API Calling Method
openapi.logistics.cancelOrder
You need to configure the permissions for the
logistics.cancelOrderAPI viaconfig.json. Details
# Request Parameters
| Attribute | Type | Default | Required | Description |
|---|---|---|---|---|
| orderId | string | Yes | The ID of the order. It must be globally unique. | |
| openid | string | Yes | The OpenID of the user. | |
| deliveryId | string | Yes | The ID of the express company. See getAllDelivery. | |
| waybillId | string | Yes | The ID of the waybill. |
# Return Value
# Object
| Property | Type | Description |
|---|---|---|
| errCode | number | Error code |
| errMsg | string | Error message |
Valid values of errCode
| Value | Description | Minimum Version |
|---|---|---|
| 0 | Succeeded |
# Exceptions
# Object
Thrown Exceptions
| Property | Type | Description |
|---|---|---|
| errCode | number | Error code |
| errMsg | string | Error message |
Valid values of errCode
| Value | Description | Minimum Version |
|---|---|---|
| -1 | System failure | |
| 40199 | The waybill ID does not exist. | |
| 9300506 | Cannot be canceled, because traces for the waybill ID are generated. |
# Request Example
const cloud = require('wx-server-sdk')
cloud.init()
exports.main = async (event, context) => {
try {
const result = await cloud.openapi.logistics.cancelOrder({
openid: 'oABC123456',
orderId: '01234567890123456789',
deliveryId: 'SF',
waybillId: '123456789'
})
console.log(result)
return result
} catch (err) {
console.log(err)
return err
}
}
# Response Example
{
"errCode": 0,
"errMsg": "openapi.logistics.cancelOrder:ok"
}