Downloading Reconciliation
Update Time:2025.01.07Merchants 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.
|
1. API intro
Applicable object: Common mode Institutional mode
Request URL: https://apihk.mch.weixin.qq.com/v3/global/statements
Request method: GET
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 |
---|---|---|---|---|
Bill date | date | string[1,8] | Yes | Query Bill date in the format of 20180103 |
Institution's Merchant ID | sp_mchid | string[1,32] | Yes | Query Institution's Merchant ID assigned by WeChat Pay |
Sub-merchant ID | sub_mchid | string[1,32] | Yes | Query Sub-merchant I assigned by WeChat Pay |
Merchant ID | mchid | string[1,32] | Yes | Query Merchant ID assigned by WeChat Pay |
Request Example
Common Mode
Institution Mode
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.
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.
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. | |||
|
Response Example:
ERROR
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).
Then, the signature string is:
|
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:
Calculate the digest of the signature string with SHA256.
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.
|
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. |