Close Order

Update Time:2025.01.07

The Close Order API should be called when a new order No. needs to be generated to initiate the payment again if the merchant order payment failed, to avoid duplicate payments. This API is also required when the order has been placed by the system but the user failed to pay in time, and the system exited automatically to stop the transaction.

Tips:

  • The Close Order API cannot be called immediately after the order is generated. The minimum call interval is 5 minutes.


1. API intro

Applicable object: Common mode Institutional mode

Request URL: https://apihk.mch.weixin.qq.com/v3/global/transactions/id/{transaction_id}/close
          OR
          https://apihk.mch.weixin.qq.com/v3/global/transactions/out-trade-no/{out_trade_no}/close

Request method: POST

 

Path parameter is a path parameter.

Query parameter needs to be passed in the request URL.

Body parameter needs to be passed in the request JSON.

2. Request Parameters

Name

Variable Name

Type

Required

Description

WeChat Pay order No.

transaction_id

string(32)

Choose one

Path WeChat order No. corresponding to the original payment transaction
Example: 1217752501201407033233368018

Merchant order No.

out_trade_no

string(32)

Path Order No. corresponding to the original payment transaction
Example: 1217752501201407033233368018

Merchant ID

mchid

string(32)

Yes

Body Merchant ID assigned by WeChat Pay
Note: Only for Common mode
Example: 1900000109

Sub-merchant ID

sub_mchid

string(32)

Yes

Body Merchant ID assigned to sub-merchants by WeChat Pay
Note: Only for Institutional mode
Example: 1900000109

Institution's Merchant ID

sp_mchid

string(32)

Yes

Body Institution's Merchant ID assigned by WeChat Pay
Note: Only for Institutional mode
Example: 1900000100

Request Example

JSON

1{
2    "sp_mchid": "10000100",
3    "sub_mchid": "20000100"
4}  

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.

Detailed error description

Response Example:

SUCCESS

1No data (HTTP status code is 204)

ERROR

1{
2	"code": "INVALID_REQUEST",
3	"message": "Parameter format verification error",
4	"detail": {
5		"field": "#/properties/payer",
6		"value": "1346177081915535577",
7		"issue": "Not in line with ALLOF schema",
8		"location": "body"
9	}
10}

 

4. Error Codes

Error Message

Description

Solution

ORDERPAID

Order paid

The order is paid and cannot be closed. Handle it as a normal paid transaction.

SYSTEM_ERROR

System error

System error. Call this API again.

ORDER_CLOSED

Order closed

The order is closed and this API cannot be called.

REQUIRE_POST_METHOD

Use post method.

Check whether the request parameter is submitted via post method.

 

 

About  WeChat  Pay

Powered By Tencent & Tenpay Copyright©

2005-2025 Tenpay All Rights Reserved.

Contact Us
Wechat Pay Global

WeChat Pay Global

Contact Us

Customer Service Tel

+86 571 95017

9:00-18:00 Monday-Friday GMT+8

Business Development

wxpayglobal@tencent.com

Developer Support

wepayTS@tencent.com

Wechat Pay Global

About Tenpay
Powered By Tencent & Tenpay Copyright© 2005-2025 Tenpay All Rights Reserved.