Login expired. Please log in again.

Feedback

0/300

Feedback

Submitted successfully

ok

Feedback

Network exception, please try again later

ok

Downloading Reconciliation API

Latest update time:2023.11.7 Release notes

Merchants can download the transaction history via this API. For example, the data from the merchant side and WeChat may be inconsistent due to record missing or system error, and the payment status can be corrected after the statement check.

Tips:

• Bill integrity check: After the bill is completely downloaded and the SHA1 signature is generated, compare the bill with the Wechatpay-Statement-Sha1 value of HTTP header returned by WeChat.

• The Downloading Reconciliation API can only download bills within 180 days.

1. API intro

Applicable object:Common modeInstitutional mode

Request URL: https://apihk.mch.weixin.qq.com/v3/global/statements

Request method: GET


Pathparameter is a path parameter.
Queryparameter needs to be passed in the request URL.
Bodyparameter needs to be passed in the request JSON.

2. Request Parameters

Name Variable Name Type Required Description
Bill date date string[1,8] Yes Query Bill date in the format of 20180103
The Downloading Reconciliation API can only download bills within 180 days.
Example: 20180130
Institution's Merchant ID sp_mchid string[1,32] Yes Query Institution's Merchant ID assigned by WeChat Pay
Note:Only for Institutional mode
Example: 1900000109
Sub-merchant ID sub_mchid string[1,32] Yes Query Sub-merchant I assigned by WeChat Pay
Note:Only for Institutional mode
Example: 1900000109
Merchant ID mchid string[1,32] Yes Query Merchant ID assigned by WeChat Pay
Note:Only for Common mode
Example: 1900000109

Request Eample


https://apihk.mch.weixin.qq.com/v3/global/statements?date=20180130&mchid=1900000109
  

https://apihk.mch.weixin.qq.com/v3/global/statements?date=20180130&sp_mchid=1900000109
https://apihk.mch.weixin.qq.com/v3/global/statements?date=20180130&sp_mchid=1900000109&sub_mchid=1900000102
  

3. Response Parameters

Response for successful request:

When the request is successful, the data is returned in the form of a text table. The first row is the header and the following rows list the corresponding field content. The field content is consistent with the query order or the refund result. For specific field description, you can refer to the corresponding APIs.

1)The first row is the header. Currently it includes transaction time, Official Account ID, Vendor ID, Sub vendor ID, Device No., WeChat order No., Vendor order No., User identifier, transaction type, transaction status, payment bank, top-up voucher currency, top-up voucher amount, voucher currency, voucher amount, WeChat refund No., merchant refund No., refund type, refund status, commodity name, merchant data package, service fee, rate, priced currency, order amount (priced currency), user payment currency, user payment amount, settlement currency, order settlement amount payable, payment exchange rate, refund exchange rate, application refund amount, user refund currency, user refund amount, refund settlement currency, refund settlement amount payable, top-up voucher refund amount, and voucher refund amount.

2)Data record is provided from the second row. Parameters are separated by comma, and the symbol ` is added before the parameter, which is to the left of 1 of a standard keyboard. The field order is consistent with the header.

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:


{
	"code": "INVALID_REQUEST",
	"message": "Parameter format verification error",
	"detail": {
		"field": "#/properties/payer",
		"value": "1346177081915535577",
		"issue": "与ALLOF schema不符",
		"location": "body"
	}
}

{
	"code": "INVALID_REQUEST",
	"message": "Parameter format verification error",
	"detail": {
		"field": "#/properties/payer",
		"value": "1346177081915535577",
		"issue": "与ALLOF schema不符",
		"location": "body"
	}
}

4. Response Signature Verification Description

4.1. Construct a signature string

First, get the response random string in theHTTP header Wechatpay-Nonce, the response timestamp in Wechatpay-Timestamp, and the bill SHA1 value in Wechatpay-Statement-Sha1 from the response.

Construct a response signature string by following the rules below. \n is a line break (ASCII code is 0x0A).

    Response timestamp\n
    Response random string\n
    Bill SHA1\n
    \n

Then, the signature string is:

    1507709906
    5K8264ILTKch16CQ2502SI8ZNMTM67VS
    {"sha1" : "12345678999"}
    
Tips:
the sha1 value in red is specially processed in JSON format for signature.

4.2. Get the response signature

A WeChat Pay response signature is passed via Wechat-Signature in the HTTP header. (Note: line breaks exist in the example for typesetting, but in practice the data should be put in a single line.) Wechatpay-Signature: WcO+t3D8Kg71dTlKwN7r9PzUOXeaBJwp8/FOuSxcuSkXsoVYxBpsAidprySCjHCjmaglNcjoKJQLJ28/Asl93joTW39FX6i07lXhnbPknezAl wmvPdnQuI01HZsZF9V1i6ggZjBiAd5lG8bZtTxZOJ87ub2i9GuJ3Nr/NUc9VeY=,Decode the field value of Wechatpay-Signature with Base64 to get the response signature.

4.3. Verify the signature

The signature can be verified with signature functions in many programming languages. A merchant is recommended to call this type of function, and verify the signature string with SHA256-with-RSA signature algorithm using the WeChat Pay Platform public key.

f the programming language or library used by the merchant only supports signature verification for the digest data, follow the steps below to verify the signature:

1. Calculate the digest of the signature string with SHA256.

2. Verify the RSA signature of the digest using the WeChat Pay Platform public key (signature type is SHA256). For more information, please see RSA_verify() of OpenSSL.

Tips:
The serial number of the WeChat Pay certificate is in the HTTP header `Wechatpay-Serial`. Before verifying the signature, check that this serial number is consistent with that of the WeChat Pay certificate held by the merchant. For details on the certificate update, please see "Get WeChat Pay Platform Certificate".

4.4. Verify the bill integrity

After the bill is completely downloaded and the SHA1 signature is generated, compare the signature with the Wechatpay-Statement-Sha1 value for bill integrity check.

5. Error Codes

Error Message Description Solution
SYSTEM_ERROR WeChat Pay internal error Try again later
PARAM_ERROR Invalid parameter Check parameters based on the request parameter description of the document.
NO_STATEMENT_EXIST The bill does not exist. Check whether any funds changes occur to the WeChat account of the current Merchant ID within the specified date.
BILL_CREATING Bill in generating Check whether there are any successful transactions under the current Merchant ID within the specified date. If there is a transaction on the specified date, the bill is being generated. Download it after 10 am.


    Page Navigation

About  WeChat  Pay

Powered By Tencent & Tenpay Copyright©

2005-2024 Tenpay All Rights Reserved.

Contact Us
Wechat Pay Global

WeChat Pay Global

置顶