Refund Notification
Update Time:2025.03.21After completing refund, the WeChat payment system will send the refund result to the Merchant.
|
1. API intro
Applicable object: Common mode Institutional mode
Request URL: The URL is set by the parameter notify_url submitted in [Submit Refund API] and the https protocol is required. If the URL cannot be accessed, the merchant will not receive any WeChat notifications. The URL must be directly accessible without any parameters. For example: notify_url: http://pay.weixin.qq.com/wxpay/123456789
2. Notification Rules
After the refund status changes, WeChat will send the refund results to the merchant.
When notifying the interaction to the backend, if the response received by WeChat is unsuccessful or timeout, WeChat considers it as a notification failure and will send it again by following certain strategies to maximize the success rate, but WeChat does not guarantee a successful notification. (Notification frequency:15s/15s/30s/3m/10m/20m/30m/30m/30m/60m/3h/3h/3h/6h/6h - in total 24h4m).
3. Notification Message
For refund result notifications, access the notification URL set up by the merchant with the `POST` method, and the notification data is transmitted through the request body (BODY) in the `JSON` format. The notification data contains the details of the encrypted refund result.
The procedure of how to decrypt the notification data is described as follows.
Obtain the merchant's notification key from the merchant platform, and record it as `key`.
Obtain the corresponding parameters `nonce` and `associated_data` for the algorithm described in `resource.algorithm` (which is `AEAD_AES_256_GCM`).
Decrypt the ciphertext `resource.ciphertext` with `key`, `nonce`, and `associated_data`, to obtain the resource objects in the Json format.
|
4. Request Parameters
Name | Variable Name | Type | Required | Description | |||
---|---|---|---|---|---|---|---|
Notification ID | id | string[1,36] | Yes | The unique notification ID Example: f7c34059-0f2d-5b32-ba33-a42dks0597c5 | |||
Notification creation time | create_time | string[1,64] | Yes | Notification creation time, in RFC3339 format Example: 2018-06-08T10:34:56+08:00 | |||
Notification type | event_type | string[1,32] | Yes | Notification type: Example: REFUND.SUCCESS | |||
Brief description of notice | summary | string[1,16] | Yes | Brief description of notice Example value: refund succeeded | |||
Notification data type | resource_type | string[1,32] | Yes | The type of the notification resource data. The type of resource data for the refund notification is encrypt-resource.Example: encrypt-resource | |||
Notification data | resource | object | Yes | Resource data of a notification | |||
|
5. Notification Signature
Encryption does not guarantee that the notification request comes from wechat pay. Wechat pay will sign the notification sent to the merchant and put the signature value in the Wechatpay-Signature of Notification's HTTP header. The merchant should verify the signature to confirm that the request is from wechat pay, not other third parties. For the algorithm of signature verification, please refer to《Wechat Pay API V3 Signature Scheme》。
6. Notification example
Payment Success Result Notification
List of decrypted resource objects:
7. List of decrypted resource objects
Name | Variable Name | Type | Required | Description | |||
---|---|---|---|---|---|---|---|
Merchant ID | mchid | string[1,32] | Yes | Merchant ID assigned by WeChat Pay | |||
Institution's Merchant ID | sp_mchid | string[1,32] | Yes | Institution's Merchant ID assigned by WeChat Pay Note: Only for Institutional mode | |||
Sub-merchant ID | sub_mchid | string[1,32] | Yes | Merchant ID assigned to sub-merchants by WeChat Pay Note: Only for Institutional mode | |||
Merchant order No. | out_trade_no | string[1,32] | Yes | Returned merchant's order No. Example: 1217752501201407033233368018 | |||
WeChat Pay order No. | transaction_id | string[1,32] | Yes | WeChat Pay order No. Example: 1217752501201407033233368018 | |||
Merchant refund No. | out_refund_no | string[1,64] | Yes | Merchant refund No. Example: 1217752501201407033233368018 | |||
WeChat refund No. | refund_id | string[1,32] | Yes | WeChat refund No. Example: 1217752501201407033233368018 | |||
Refund status | refund_status | string[1,16] | Yes | Refund status: Example: SUCCESS | |||
Refund completion time | success_time | string[1,64] | No | Refund completion time, which is returned when the refund status is successful in RFC3339 format.Example: 2018-06-08T10:34:56+08:00 | |||
Refund receiving account | recv_account | string[1,64] | Yes | Refund receiving party of the current refund order Example: China Merchants Bank Credit Card 0403 | |||
Refund source | fund_source | string[1,30] | No | REFUND_SOURCE_UNSETTLED_FUNDS: Refund with unsettled funds (default) Example: REFUND_SOURCE_UNSETTLED_FUNDS | |||
Amount information | amount | object | Yes | Information on the amount. For more information, see the description below. | |||
|
8. Response Result
After the merchant's backend has properly processed the notification, HTTP status code 200 or 204 needs to be returned. No specific content is required for 204.For other HTTP status codes, WeChat Pay will deem the notification as a failure, and will send the notification regularly by following the aforesaid policies.
|
Name | Variable Name | Type | Required | Description |
---|---|---|---|---|
Returned status code | code | string[1,32] | Yes | For more information, see the returned status code description below.Example: SUCCESS |
Returned message | message | string[1,256] | No | Returned message, which presents the cause of the error. Example: System error |