Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

WeChat small program cloud development SDK documents WeChat payment and request a refund


May 20, 2021 WeChat Mini Program Development Document


Table of contents


CloudPay.refund()

Support: Cloud function 2.0.2

Request a refund

Description

When a refund is required for the buyer's or seller's reasons for a period of time after the transaction occurs, the seller may return the payment to the buyer through the refund interface, and WeChat Payment will return the payment to the buyer's account in accordance with the refund rules after receiving the refund request and verifying success.

Attention:

1. Orders with a transaction time of more than one year cannot be submitted for refund; 2. WeChat payment refund support single transaction is divided into multiple refunds, multiple refunds need to be submitted to the original payment order merchant order number and set a different refund order number. T he total amount requested for a refund cannot exceed the order amount. I f a refund fails and resubmitted, please do not change the refund slip number, please use the original merchant refund slip number. 3 , request frequency limit: 150qps, that is, the normal number of requests per second for refund does not exceed 150 times. Error or invalid request frequency limit: 6qps, i.e. no more than 6 unusual or incorrect refund requests per second 4, no more than 50 partial refunds per paid order

Description of the parameters

The field name The name of the variable Required Type The sample value Describe
Sub-merchant number sub_mch_id Is String(32) 1900000109 WeChat pays for the assigned sub-merchant number
Random string nonce_str Is String(32) 5K8264ILTKCH16CQ2502SI8ZNMTM67VS Random string, not longer than 32 bits. A random number generation algorithm is recommended
WeChat order number transaction_id no String(32) 1217752501201407033233368018 WeChat order number.Fill in one by two ordered order number.
Merchant order number out_trade_no no String(32) 1217752501201407033233368018 The order number of the merchant system is required to require 32 characters, which can only be numbers, uppercase letters _-
Merchant refund number out_refund_no Yes String(64) 1.21775E+27 The refund number inside the merchant system is unique, the merchant system is only a number, uppercase letters _-
order amount total_fee Yes Int 100 The total amount of orders, the unit is divided, can only be an integer, see the payment amount for details.
Apply for a refund amount refund_fee Yes Int 100 The total amount of refund, the unit is divided, only for integers, can be partially refunded.See the payment amount for details
Currency species refund_fee_type no String(8) CNY The currency type, the three alphabetic code of the ISO 4217 standard, the default RMB: CNY, other values list see the currency type
The reason for the refund refund_desc Whether String(80) The goods are sold out If the merchant comes in, the reason for the refund will be reflected in the refund message sent to the user
Note: If the order refund amount is ≤1 yuan and is a partial refund, the reason for the refund will not be reflected in the refund message
Refund the source of the funds refund_account Whether String(30) REFUND_SOURCE_RECHARGE_FUNDS Used only for older money flow merchants
REFUND_SOURCE_UNSETTLED_FUNDS--- of outstanding funds (refund by default using unsolt funds)
REFUND_SOURCE_RECHARGE_FUNDS--- refund of the available balance

Returns a description of the value

The field name The name of the variable Required Type The sample value Describe
Return the status code returnCode Is String(16) SUCCESS SUCCESS/FAIL
Return information returnMsg Whether String(128) The signature failed The information returned, if not empty, is the cause of the error. Such as a failed signature, parameter format check error

The following fields are returned when the returnCode is SUCCESS

The field name The name of the variable Required Type The sample value Describe
Business results result_code Is String(16) SUCCESS SUCCESS/FAIL
THE SUCCESS refund request was received successfully and the result is queried through the refund inquiry interface
FAIL submission business failed
The error code err_code Whether String(32) SYSTEMERROR The list is detailed in the error code list
The error code description err_code_des Whether String(128) The system timed out Description of the result information
The service provider's APPID appid Is String(32) wxd678efh567hg6787 The APPID of the service merchant
Merchant number mch_id Is String(32) 1230000109 WeChat pays for the assigned merchant number
APPID for small programs sub_appid Is String(32) wx8888888888888888 WeChat assigned small program ID
Sub-merchant number sub_mch_id Is String(32) 1900000109 WeChat pays for the assigned sub-merchant number
Random string nonce_str Is String(32) 5K8264ILTKCH16CQ2502SI8ZNMTM67VS Random string, not longer than 32 bits
Signature sign Is String(32) 5K8264ILTKCH16CQ2502SI8ZNMTM67VS Signatures, see signature algorithms for details
WeChat order number transaction_id Is String(32) 1217752501201407033233368018 WeChat order number
Merchant order number out_trade_no Is String(32) 1217752501201407033233368018 Merchant system internal order number, required within 32 characters, can only be numbers, case letters -
Merchant refund slip number out_refund_no Is String(64) 1217752501201407033233368018 Refund order number inside the merchant system, unique inside the merchant system, can only be numbers, case letters
WeChat refund slip number refund_id Is String(32) 1217752501201407033233368018 WeChat refund slip number
Request a refund amount refund_fee Is Int 100 The total amount of the refund, in points, can be partially refunded
Refund amount settlement_refund_fee Whether Int 100 After removing the refund amount of the non-recharge voucher, the refund amount is the amount requested for the refund - the refund amount of the non-rechargeable voucher, and the amount of the refund is the amount of the refund requested
The order amount total_fee Is Int 100 The total amount of the order, in units, can only be integers, as detailed in the amount paid
The amount of the order to be closed settlement_total_fee Whether Int 100 The amount of the order payable - the amount of the order - the amount of the voucher free of charge, the amount of the order that should be closed , the amount of the order.
The type of currency fee_type Whether String(8) CNY Order amount currency type, is a three-letter code that complies with ISO 4217, default RMB: CNY, and a list of other values can be found in the currency type
The amount paid in cash cash_fee Is Int 100 Cash payment amount, in units, can only be integer, see payment amount
The amount of the cash refund cash_refund_fee Whether Int 100 The amount of the cash refund, in points, can only be an integer, see the payment amount
The total amount of the voucher refund coupon_refund_fee Whether Int 100 Voucher Refund Amount - Refund Amount, Refund Amount - Voucher or Discount Refund Amount is cash, please see Voucher or Credit
Refund voucher usage quantity coupon_refund_count Whether Int 1 Refund voucher usage quantity
The type of voucher coupon_type_$n Whether String(8) CASH CASH -- Recharge voucher
NO_CASH--- a non-recharge voucher
The order is returned when the voucher is used (value: CASH, NO_CASH). $n is the undersem, numbered from 0, for example coupon_type_0

Error code

Name Describe Reason Solution
SYSTEMERROR The interface returned an error The system timed out Please do not change the merchant refund slip number, please call the API again using the same parameters.
BIZERR_NEED_RETRY Refund business process errors that require merchants to trigger a retry to resolve In the case of the same time, the business is rejected and the merchant tries again to resolve it Please do not change the merchant refund slip number, please call the API again using the same parameters.
TRADE_OVERDUE The order has exceeded the refund period The order has exceeded the maximum refundable period (refundable within one year of payment) Please choose a different way to refund yourself
ERROR Business error There was an error requesting a refund The error returns a specific cause of the error, so please handle it accordingly based on the actual return.
USER_ACCOUNT_ABNORMAL The refund request failed Sign out of the user account This status represents a failure of the refund request and the merchant can process the refund on its own.
INVALID_REQ_TOO_MUCH Too many invalid requests Too many consecutive error requests are briefly blocked by the system Please check that the business is working properly and try again after 1 minute
NOTENOUGH The balance is insufficient The merchant's available refund balance is insufficient This status represents the failure of the refund request and the merchant can handle the specific error prompt accordingly.
INVALID_TRANSACTIONID The transaction_id The request parameters were not filled in in accordance with the guidelines The request parameter is incorrect, checking for the existence of the original transaction number or initiating a payment transaction interface to return the failure
PARAM_ERROR The argument is wrong The request parameters were not filled in in accordance with the guidelines The request parameter is incorrect, please re-check and call the refund request
APPID_NOT_EXIST The APPID does not exist The APPID is missing from the parameter Please check that the APPID is correct
MCHID_NOT_EXIST MCHID does not exist MCHID is missing from the parameter Please check that the MCHID is correct
REQUIRE_POST_METHOD Please use the post method The post pass parameter is not used Please check that the request parameters are submitted via the post method
SIGNERROR The signature is wrong The parameter signature result is incorrect Check that both the signature parameters and methods meet the requirements of the signature algorithm
XML_FORMAT_ERROR The XML is in the wrong format The XML is in the wrong format Check that the XML parameters are in the correct format
FREQUENCY_LIMITED Frequency limit There is a limit to the frequency with which orders can be requested for refunds up to 2 months ago This refund is not accepted, please reduce the frequency and try again
NOAUTH Abnormal IP requests are not accepted Request an ip exception If it is dynamic ip, please log in to the merchant platform background to turn off ip security configuration;
If it is static ip, confirm that the request ip configured by the merchant platform is not in the matching ip list