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:2020.04.30 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.

Notes:

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

2. Billing compression: To compress the bill, set the request as gzip via the HTTP header Accept-Encoding.


API Intro

Request URL:

https://api.mch.weixin.qq.com/hk/v3/statements?date=parameter value1&mchid=parameter value2

Request method: GET

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
Bill date date string(8) Yes path Bill date in the format of 20180103
Example:20180130
Merchant ID mchid string(32) No path Merchant ID assigned by WeChat Pay
Example:1900000109

For example:


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

    
{
JAVA示例代码
}
    

Returned Result

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.
Example:INVALID_REQUEST
Returned information message string(256) Yes Returned message. It indicates the reason for the error if not empty.
Example:Parameter format verification error
+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
Location of the 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.
Example:#/properties/payer
Value of the incorrect parameter value string(256) Yes Value of the incorrect parameter
Example:1346177081915535577
Cause of error issue string(256) Yes Cause of error
It is different from ALLOF schema
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
Example:body

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.


For example:

{
      "code" : " NO_STATEMENT_EXIST",
      "message" : "The bill does not exist."
    }

{
{
      "code" : " NO_STATEMENT_EXIST",
      "message" : "The bill does not exist."
    }

Response Signature Verification Description

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

Note:the sha1 value in red is specially processed in JSON format for signature.

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/Asl93jo
TW39FX6i07lXhnbPknezAlwmvPdnQuI01HZsZF9V1i6ggZjBiAd5lG8bZtTxZOJ87ub2i9GuJ3Nr/NUc9VeY=,Decode the field value of Wechatpay-Signature with Base64 to get the response signature.

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.


Note: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".

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.

Error Codes

Error Codes 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_BILL_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.


Release notes

close
V1.0
2020.04.30
1.Download Statement API released online

About  WeChat  Pay

Powered By Tencent & Tenpay Copyright©

2005-2019 Tenpay All Rights Reserved.

Contact Us
Wechat Pay Global

Wechat Pay Global

ICP证

粤B1.B2-20090295