Revoke Order API
When a failure is returned from the payment transaction or the payment system times out, call the API to cancel the transaction. If the user of an order fails to pay, the WeChat Pay system will close the order. If the user pays successfully, the WeChat Pay system will refund the order amount to the user.
Tips:
• This API can be called to cancel transaction orders within 7 days. For other normal paid orders, call the API for refund requests. After submitting payment transactions, call the [Order Query API]. Call the [Cancel Order API] if no payment result is shown.
• Do not call the Cancel Order API immediately after calling the Payment API. It is recommended to call the Cancel Order API at least 15 seconds after payment.
1. API Intro
Applicable object: Common mode Institutional mode
Request URL:https://apihk.mch.weixin.qq.com/v3/global/micropay/transactions/id/{transaction_id}/reverse
Or
https://apihk.mch.weixin.qq.com/v3/global/micropay/transactions/out-trade-no/{out_trade_no}/reverse
Request method:POST
Pathparameter is a path parameter.
Queryparameter needs to be passed in the request URL.
Bodyparameter needs to be passed in the request JSON.
3. Response Parameters
Response for successful request:
No data (HTTP status code is 204)
Response for failed request:
Name |
Variable Name |
Type |
Required |
Description |
Returned status code |
code |
string[1,32] |
Yes |
Error code. See the error code list for the enumerated values. |
Returned information |
message |
string[1,256] |
Yes |
Returned message. It indicates the reason for the error if not empty. |
Detailed error description |
detail |
object |
No |
It is returned when code is PARAM_ERROR. Details will be described below. |
Name |
Variable Name |
Type |
Required |
Description |
The location of incorrect parameter |
field |
string[1,256] |
Yes |
If the incorrect parameter is in the JSON for request body, it is populated with the JSON Pointer pointing to this parameter. If the incorrect parameter is in the request URL or querystring, it is populated with the variable name of this parameter. |
Value of the incorrect parameter |
value |
string[1,256] |
Yes |
Value of the incorrect parameter |
Cause of error |
issue |
string[1,256] |
Yes |
Cause of error |
Location of the incorrect parameter |
location |
string[1,256] |
No |
body: The incorrect parameter is in the JSON for request body
url: The incorrect parameter is in the request URL
query: The incorrect parameter is in the querystring of the request |
|
Response Example:
No data (HTTP status code is 204)
{
"code": "INVALID_REQUEST",
"message": "Parameter format verification error",
"detail": {
"field": "#/properties/payer",
"value": "1346177081915535577",
"issue": "与ALLOF schema不符",
"location": "body"
}
}