Login expired. Please log in again.

Feedback

0/300

Feedback

Submitted successfully

ok

Feedback

Network exception, please try again later

ok

Revoke Order API

Latest update time:2020.04.30 Release notes


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:

1. 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

2. [Cancel Order API] if no payment result is shown.

3. 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.


API intro

Request URL:https://api.mch.weixin.qq.com/hk/v3/transactions/id/{id}/reverse
        https://api.mch.weixin.qq.com/hk/v3/transactions/out-trade-no/{out_trade_no}/reverse

Request method: POST

Applicable object:Common modeInstitutional mode

API Rules: https://wechatpay-api.gitbook.io/wechatpay-api-v3


path This parameter needs to be set at the request URL

query This parameter needs to be set at the JSON for request body

Request Parameters

Name Variable Name Type Required Description
WeChat Pay order No. id string(32) Choose One path WeChat Pay order No.
Example:1217752501201407033233368018
Merchant order No. out_trade_no string(32) path The order No. in the merchant system with a length of not more than 32 characters, including letters. If the authorization code changes, a new merchant order No. must be used. For more information, see Merchant Order No.
Example:1217752501201407033233368018
Merchant ID mchid string(32) Yes query Merchant ID assigned by WeChat Pay
Note:Only forCommon mode
Example:1900000109
Institution's Merchant ID sp_mchid string(32) Yes query Institution's Merchant ID assigned by WeChat Pay
Note:Only forInstitutional mode
Example:1900000109
Sub-merchant ID sub_mchid string(32) Yes query Sub-merchant ID assigned by WeChat Pay
Note:Only forInstitutional mode
Example:1900000100

请求示例:

{
	"sp_mchid": "10000100",
	"sub_mchid": "20000100"
}
    
{
JAVA示例代码
}
    

Returned Result

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(32) Yes Error code. See the error code list for the enumerated values.
Returned information message string(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(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(256) Yes Value of the incorrect parameter
Cause of error issue string(256) Yes Cause of error
Location of the incorrect parameter location string(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

For 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"
   }
}

Error Codes

Name Description Solution
SYSTEMERROR Errors returned from the API Call the Result View API of the scanned order immediately to view the current order status and decide the next step according to the status.
INVALID_TRANSACTIO NID Invalid transaction_id Invalid parameter. Check again.
PARAM_ERROR Invalid parameter Please check your program according to the details returned by the API.
REVERSE_EXPIRE The order cannot be canceled. Check whether the order to be canceled is within the cancel period.
INVALID_REQUEST Invalid request Check whether the merchant permissions are unusual and whether there are repeated payment requests, invalid certificate, rate limit, etc.
TRADE_ERROR Order error Check whether the user account is unusual, under risk control and in compliance with the rules.


Release notes

close
V1.0
2020.04.30
1.Canceling Order API released online

About  WeChat  Pay

Powered By Tencent & Tenpay Copyright©

2005-2024 Tenpay All Rights Reserved.

Contact Us
Wechat Pay Global

WeChat Pay Global