查询单笔退款(通过商户退款单号)
更新时间:2025.01.16提交退款申请后,推荐每间隔1分钟调用该接口查询一次退款状态,若超过5分钟仍是退款处理中状态,建议开始逐步衰减查询频率(比如之后间隔5分钟、10分钟、20分钟、30分钟……查询一次)。
退款有一定延时,零钱支付的订单退款一般5分钟内到账,银行卡支付的订单退款一般1-3个工作日到账。
同一服务商商户号查询退款频率限制为300qps,如返回FREQUENCY_LIMITED频率限制报错可间隔1分钟再重试查询。
接口说明
支持商户:【普通服务商】
请求方式:【GET】/v3/refund/domestic/refunds/{out_refund_no}
请求域名:【主域名】https://api.mch.weixin.qq.com 使用该域名将访问就近的接入点
【备域名】https://api2.mch.weixin.qq.com 使用该域名将访问异地的接入点 ,指引点击查看
请求参数
Header HTTP头参数
Authorization 必填 string
请参考签名认证生成认证信息
Accept 必填 string
请设置为application/json
path 路径参数
out_refund_no 必填 string(64)
【商户退款单号】 服务商申请退款时传入的商户系统内部退款单号。
query 查询参数
sub_mchid 必填 string(32)
【子商户号(也叫特约商户号)】 服务商下单时传入的子商户号sub_mchid。
请求示例
GET
1curl -X GET \ 2 https://api.mch.weixin.qq.com/v3/refund/domestic/refunds/1217752501201407033233368018?sub_mchid=1900000109 \ 3 -H "Authorization: WECHATPAY2-SHA256-RSA2048 mchid=\"1900000001\",..." \ 4 -H "Accept: application/json" 5
需配合微信支付工具库 WXPayUtility 使用,请参考Java
1package com.java.demo; 2 3import com.java.utils.WXPayUtility; // 引用微信支付工具库,参考:https://pay.weixin.qq.com/doc/v3/partner/4014985777 4 5import com.google.gson.annotations.SerializedName; 6import com.google.gson.annotations.Expose; 7import okhttp3.MediaType; 8import okhttp3.OkHttpClient; 9import okhttp3.Request; 10import okhttp3.RequestBody; 11import okhttp3.Response; 12 13import java.io.IOException; 14import java.io.UncheckedIOException; 15import java.security.PrivateKey; 16import java.security.PublicKey; 17import java.util.ArrayList; 18import java.util.HashMap; 19import java.util.List; 20import java.util.Map; 21 22/** 23 * 查询单笔退款(通过商户退款单号) 24 */ 25public class QueryByOutRefundNo { 26 private static String HOST = "https://api.mch.weixin.qq.com"; 27 private static String METHOD = "GET"; 28 private static String PATH = "/v3/refund/domestic/refunds/{out_refund_no}"; 29 30 public static void main(String[] args) { 31 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340 32 QueryByOutRefundNo client = new QueryByOutRefundNo( 33 "19xxxxxxxx", // 商户号,是由微信支付系统生成并分配给每个商户的唯一标识符,商户号获取方式参考 https://pay.weixin.qq.com/doc/v3/partner/4013080340 34 "1DDE55AD98Exxxxxxxxxx", // 商户API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/v3/partner/4013058924 35 "/path/to/apiclient_key.pem", // 商户API证书私钥文件路径,本地文件路径 36 "PUB_KEY_ID_xxxxxxxxxxxxx", // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/v3/partner/4013038589 37 "/path/to/wxp_pub.pem" // 微信支付公钥文件路径,本地文件路径 38 ); 39 40 QueryByOutRefundNoRequest request = new QueryByOutRefundNoRequest(); 41 request.outRefundNo = "1217752501201407033233368018"; 42 request.subMchid = "1900000109"; 43 try { 44 Refund response = client.run(request); 45 // TODO: 请求成功,继续业务逻辑 46 System.out.println(response); 47 } catch (WXPayUtility.ApiException e) { 48 // TODO: 请求失败,根据状态码执行不同的逻辑 49 e.printStackTrace(); 50 } 51 } 52 53 public Refund run(QueryByOutRefundNoRequest request) { 54 String uri = PATH; 55 uri = uri.replace("{out_refund_no}", WXPayUtility.urlEncode(request.outRefundNo)); 56 Map<String, Object> args = new HashMap<>(); 57 args.put("sub_mchid", request.subMchid); 58 String queryString = WXPayUtility.urlEncode(args); 59 if (!queryString.isEmpty()) { 60 uri = uri + "?" + queryString; 61 } 62 63 Request.Builder reqBuilder = new Request.Builder().url(HOST + uri); 64 reqBuilder.addHeader("Accept", "application/json"); 65 reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId); 66 reqBuilder.addHeader("Authorization", WXPayUtility.buildAuthorization(mchid, certificateSerialNo, privateKey, METHOD, uri, null)); 67 reqBuilder.method(METHOD, null); 68 Request httpRequest = reqBuilder.build(); 69 70 // 发送HTTP请求 71 OkHttpClient client = new OkHttpClient.Builder().build(); 72 try (Response httpResponse = client.newCall(httpRequest).execute()) { 73 String respBody = WXPayUtility.extractBody(httpResponse); 74 if (httpResponse.code() >= 200 && httpResponse.code() < 300) { 75 // 2XX 成功,验证应答签名 76 WXPayUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey, 77 httpResponse.headers(), respBody); 78 79 // 从HTTP应答报文构建返回数据 80 return WXPayUtility.fromJson(respBody, Refund.class); 81 } else { 82 throw new WXPayUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers()); 83 } 84 } catch (IOException e) { 85 throw new UncheckedIOException("Sending request to " + uri + " failed.", e); 86 } 87 } 88 89 private final String mchid; 90 private final String certificateSerialNo; 91 private final PrivateKey privateKey; 92 private final String wechatPayPublicKeyId; 93 private final PublicKey wechatPayPublicKey; 94 95 public QueryByOutRefundNo(String mchid, String certificateSerialNo, String privateKeyFilePath, String wechatPayPublicKeyId, String wechatPayPublicKeyFilePath) { 96 this.mchid = mchid; 97 this.certificateSerialNo = certificateSerialNo; 98 this.privateKey = WXPayUtility.loadPrivateKeyFromPath(privateKeyFilePath); 99 this.wechatPayPublicKeyId = wechatPayPublicKeyId; 100 this.wechatPayPublicKey = WXPayUtility.loadPublicKeyFromPath(wechatPayPublicKeyFilePath); 101 } 102 103 public static class QueryByOutRefundNoRequest { 104 @SerializedName("out_refund_no") 105 @Expose(serialize = false) 106 public String outRefundNo; 107 108 @SerializedName("sub_mchid") 109 @Expose(serialize = false) 110 public String subMchid; 111 } 112 113 public static class Refund { 114 @SerializedName("refund_id") 115 public String refundId; 116 117 @SerializedName("out_refund_no") 118 public String outRefundNo; 119 120 @SerializedName("transaction_id") 121 public String transactionId; 122 123 @SerializedName("out_trade_no") 124 public String outTradeNo; 125 126 @SerializedName("channel") 127 public Channel channel; 128 129 @SerializedName("user_received_account") 130 public String userReceivedAccount; 131 132 @SerializedName("success_time") 133 public String successTime; 134 135 @SerializedName("create_time") 136 public String createTime; 137 138 @SerializedName("status") 139 public Status status; 140 141 @SerializedName("funds_account") 142 public FundsAccount fundsAccount; 143 144 @SerializedName("amount") 145 public Amount amount; 146 147 @SerializedName("promotion_detail") 148 public List<Promotion> promotionDetail; 149 150 @SerializedName("refund_account") 151 public RefundAccount refundAccount; 152 } 153 154 public enum Channel { 155 @SerializedName("ORIGINAL") 156 ORIGINAL, 157 @SerializedName("BALANCE") 158 BALANCE, 159 @SerializedName("OTHER_BALANCE") 160 OTHER_BALANCE, 161 @SerializedName("OTHER_BANKCARD") 162 OTHER_BANKCARD 163 } 164 165 public enum Status { 166 @SerializedName("SUCCESS") 167 SUCCESS, 168 @SerializedName("CLOSED") 169 CLOSED, 170 @SerializedName("PROCESSING") 171 PROCESSING, 172 @SerializedName("ABNORMAL") 173 ABNORMAL 174 } 175 176 public enum FundsAccount { 177 @SerializedName("UNSETTLED") 178 UNSETTLED, 179 @SerializedName("AVAILABLE") 180 AVAILABLE, 181 @SerializedName("UNAVAILABLE") 182 UNAVAILABLE, 183 @SerializedName("OPERATION") 184 OPERATION, 185 @SerializedName("BASIC") 186 BASIC, 187 @SerializedName("ECNY_BASIC") 188 ECNY_BASIC 189 } 190 191 public static class Amount { 192 @SerializedName("total") 193 public Long total; 194 195 @SerializedName("refund") 196 public Long refund; 197 198 @SerializedName("from") 199 public List<FundsFromItem> from; 200 201 @SerializedName("payer_total") 202 public Long payerTotal; 203 204 @SerializedName("payer_refund") 205 public Long payerRefund; 206 207 @SerializedName("settlement_refund") 208 public Long settlementRefund; 209 210 @SerializedName("settlement_total") 211 public Long settlementTotal; 212 213 @SerializedName("discount_refund") 214 public Long discountRefund; 215 216 @SerializedName("currency") 217 public String currency; 218 219 @SerializedName("refund_fee") 220 public Long refundFee; 221 222 @SerializedName("advance") 223 public Long advance; 224 } 225 226 public static class Promotion { 227 @SerializedName("promotion_id") 228 public String promotionId; 229 230 @SerializedName("scope") 231 public PromotionScope scope; 232 233 @SerializedName("type") 234 public PromotionType type; 235 236 @SerializedName("amount") 237 public Long amount; 238 239 @SerializedName("refund_amount") 240 public Long refundAmount; 241 242 @SerializedName("goods_detail") 243 public List<GoodsDetail> goodsDetail; 244 } 245 246 public enum RefundAccount { 247 @SerializedName("REFUND_SOURCE_PARTNER_ADVANCE") 248 REFUND_SOURCE_PARTNER_ADVANCE, 249 @SerializedName("REFUND_SOURCE_SUB_MERCHANT") 250 REFUND_SOURCE_SUB_MERCHANT, 251 @SerializedName("REFUND_SOURCE_SUB_MERCHANT_ADVANCE") 252 REFUND_SOURCE_SUB_MERCHANT_ADVANCE 253 } 254 255 public static class FundsFromItem { 256 @SerializedName("account") 257 public Account account; 258 259 @SerializedName("amount") 260 public Long amount; 261 } 262 263 public enum PromotionScope { 264 @SerializedName("GLOBAL") 265 GLOBAL, 266 @SerializedName("SINGLE") 267 SINGLE 268 } 269 270 public enum PromotionType { 271 @SerializedName("COUPON") 272 COUPON, 273 @SerializedName("DISCOUNT") 274 DISCOUNT 275 } 276 277 public static class GoodsDetail { 278 @SerializedName("merchant_goods_id") 279 public String merchantGoodsId; 280 281 @SerializedName("wechatpay_goods_id") 282 public String wechatpayGoodsId; 283 284 @SerializedName("goods_name") 285 public String goodsName; 286 287 @SerializedName("unit_price") 288 public Long unitPrice; 289 290 @SerializedName("refund_amount") 291 public Long refundAmount; 292 293 @SerializedName("refund_quantity") 294 public Long refundQuantity; 295 } 296 297 public enum Account { 298 @SerializedName("AVAILABLE") 299 AVAILABLE, 300 @SerializedName("UNAVAILABLE") 301 UNAVAILABLE 302 } 303 304} 305
需配合微信支付工具库 wxpay_utility 使用,请参考Go
1package main 2 3import ( 4 "demo/wxpay_utility" // 引用微信支付工具库,参考 https://pay.weixin.qq.com/doc/v3/partner/4015119446 5 "encoding/json" 6 "fmt" 7 "net/http" 8 "net/url" 9 "strings" 10 "time" 11) 12 13func main() { 14 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340 15 config, err := wxpay_utility.CreateMchConfig( 16 "19xxxxxxxx", // 商户号,是由微信支付系统生成并分配给每个商户的唯一标识符,商户号获取方式参考 https://pay.weixin.qq.com/doc/v3/partner/4013080340 17 "1DDE55AD98Exxxxxxxxxx", // 商户API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/v3/partner/4013058924 18 "/path/to/apiclient_key.pem", // 商户API证书私钥文件路径,本地文件路径 19 "PUB_KEY_ID_xxxxxxxxxxxxx", // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/v3/partner/4013038589 20 "/path/to/wxp_pub.pem", // 微信支付公钥文件路径,本地文件路径 21 ) 22 if err != nil { 23 fmt.Println(err) 24 return 25 } 26 27 request := &QueryByOutRefundNoRequest{ 28 OutRefundNo: wxpay_utility.String("1217752501201407033233368018"), 29 SubMchid: wxpay_utility.String("1900000109"), 30 } 31 32 response, err := QueryByOutRefundNo(config, request) 33 if err != nil { 34 fmt.Printf("请求失败: %+v\n", err) 35 // TODO: 请求失败,根据状态码执行不同的处理 36 return 37 } 38 39 // TODO: 请求成功,继续业务逻辑 40 fmt.Printf("请求成功: %+v\n", response) 41} 42 43func QueryByOutRefundNo(config *wxpay_utility.MchConfig, request *QueryByOutRefundNoRequest) (response *Refund, err error) { 44 const ( 45 host = "https://api.mch.weixin.qq.com" 46 method = "GET" 47 path = "/v3/refund/domestic/refunds/{out_refund_no}" 48 ) 49 50 reqUrl, err := url.Parse(fmt.Sprintf("%s%s", host, path)) 51 if err != nil { 52 return nil, err 53 } 54 reqUrl.Path = strings.Replace(reqUrl.Path, "{out_refund_no}", url.PathEscape(*request.OutRefundNo), -1) 55 query := reqUrl.Query() 56 if request.SubMchid != nil { 57 query.Add("sub_mchid", *request.SubMchid) 58 } 59 reqUrl.RawQuery = query.Encode() 60 httpRequest, err := http.NewRequest(method, reqUrl.String(), nil) 61 if err != nil { 62 return nil, err 63 } 64 httpRequest.Header.Set("Accept", "application/json") 65 httpRequest.Header.Set("Wechatpay-Serial", config.WechatPayPublicKeyId()) 66 authorization, err := wxpay_utility.BuildAuthorization(config.MchId(), config.CertificateSerialNo(), config.PrivateKey(), method, reqUrl.RequestURI(), nil) 67 if err != nil { 68 return nil, err 69 } 70 httpRequest.Header.Set("Authorization", authorization) 71 72 client := &http.Client{} 73 httpResponse, err := client.Do(httpRequest) 74 if err != nil { 75 return nil, err 76 } 77 respBody, err := wxpay_utility.ExtractResponseBody(httpResponse) 78 if err != nil { 79 return nil, err 80 } 81 if httpResponse.StatusCode >= 200 && httpResponse.StatusCode < 300 { 82 // 2XX 成功,验证应答签名 83 err = wxpay_utility.ValidateResponse( 84 config.WechatPayPublicKeyId(), 85 config.WechatPayPublicKey(), 86 &httpResponse.Header, 87 respBody, 88 ) 89 if err != nil { 90 return nil, err 91 } 92 response := &Refund{} 93 if err := json.Unmarshal(respBody, response); err != nil { 94 return nil, err 95 } 96 97 return response, nil 98 } else { 99 return nil, wxpay_utility.NewApiException( 100 httpResponse.StatusCode, 101 httpResponse.Header, 102 respBody, 103 ) 104 } 105} 106 107type QueryByOutRefundNoRequest struct { 108 OutRefundNo *string `json:"out_refund_no,omitempty"` 109 SubMchid *string `json:"sub_mchid,omitempty"` 110} 111 112func (o *QueryByOutRefundNoRequest) MarshalJSON() ([]byte, error) { 113 type Alias QueryByOutRefundNoRequest 114 a := &struct { 115 OutRefundNo *string `json:"out_refund_no,omitempty"` 116 SubMchid *string `json:"sub_mchid,omitempty"` 117 *Alias 118 }{ 119 // 序列化时移除非 Body 字段 120 OutRefundNo: nil, 121 SubMchid: nil, 122 Alias: (*Alias)(o), 123 } 124 return json.Marshal(a) 125} 126 127type Refund struct { 128 RefundId *string `json:"refund_id,omitempty"` 129 OutRefundNo *string `json:"out_refund_no,omitempty"` 130 TransactionId *string `json:"transaction_id,omitempty"` 131 OutTradeNo *string `json:"out_trade_no,omitempty"` 132 Channel *Channel `json:"channel,omitempty"` 133 UserReceivedAccount *string `json:"user_received_account,omitempty"` 134 SuccessTime *time.Time `json:"success_time,omitempty"` 135 CreateTime *time.Time `json:"create_time,omitempty"` 136 Status *Status `json:"status,omitempty"` 137 FundsAccount *FundsAccount `json:"funds_account,omitempty"` 138 Amount *Amount `json:"amount,omitempty"` 139 PromotionDetail []Promotion `json:"promotion_detail,omitempty"` 140 RefundAccount *RefundAccount `json:"refund_account,omitempty"` 141} 142 143type Channel string 144 145func (e Channel) Ptr() *Channel { 146 return &e 147} 148 149const ( 150 CHANNEL_ORIGINAL Channel = "ORIGINAL" 151 CHANNEL_BALANCE Channel = "BALANCE" 152 CHANNEL_OTHER_BALANCE Channel = "OTHER_BALANCE" 153 CHANNEL_OTHER_BANKCARD Channel = "OTHER_BANKCARD" 154) 155 156type Status string 157 158func (e Status) Ptr() *Status { 159 return &e 160} 161 162const ( 163 STATUS_SUCCESS Status = "SUCCESS" 164 STATUS_CLOSED Status = "CLOSED" 165 STATUS_PROCESSING Status = "PROCESSING" 166 STATUS_ABNORMAL Status = "ABNORMAL" 167) 168 169type FundsAccount string 170 171func (e FundsAccount) Ptr() *FundsAccount { 172 return &e 173} 174 175const ( 176 FUNDSACCOUNT_UNSETTLED FundsAccount = "UNSETTLED" 177 FUNDSACCOUNT_AVAILABLE FundsAccount = "AVAILABLE" 178 FUNDSACCOUNT_UNAVAILABLE FundsAccount = "UNAVAILABLE" 179 FUNDSACCOUNT_OPERATION FundsAccount = "OPERATION" 180 FUNDSACCOUNT_BASIC FundsAccount = "BASIC" 181 FUNDSACCOUNT_ECNY_BASIC FundsAccount = "ECNY_BASIC" 182) 183 184type Amount struct { 185 Total *int64 `json:"total,omitempty"` 186 Refund *int64 `json:"refund,omitempty"` 187 From []FundsFromItem `json:"from,omitempty"` 188 PayerTotal *int64 `json:"payer_total,omitempty"` 189 PayerRefund *int64 `json:"payer_refund,omitempty"` 190 SettlementRefund *int64 `json:"settlement_refund,omitempty"` 191 SettlementTotal *int64 `json:"settlement_total,omitempty"` 192 DiscountRefund *int64 `json:"discount_refund,omitempty"` 193 Currency *string `json:"currency,omitempty"` 194 RefundFee *int64 `json:"refund_fee,omitempty"` 195 Advance *int64 `json:"advance,omitempty"` 196} 197 198type Promotion struct { 199 PromotionId *string `json:"promotion_id,omitempty"` 200 Scope *PromotionScope `json:"scope,omitempty"` 201 Type *PromotionType `json:"type,omitempty"` 202 Amount *int64 `json:"amount,omitempty"` 203 RefundAmount *int64 `json:"refund_amount,omitempty"` 204 GoodsDetail []GoodsDetail `json:"goods_detail,omitempty"` 205} 206 207type RefundAccount string 208 209func (e RefundAccount) Ptr() *RefundAccount { 210 return &e 211} 212 213const ( 214 REFUNDACCOUNT_REFUND_SOURCE_PARTNER_ADVANCE RefundAccount = "REFUND_SOURCE_PARTNER_ADVANCE" 215 REFUNDACCOUNT_REFUND_SOURCE_SUB_MERCHANT RefundAccount = "REFUND_SOURCE_SUB_MERCHANT" 216 REFUNDACCOUNT_REFUND_SOURCE_SUB_MERCHANT_ADVANCE RefundAccount = "REFUND_SOURCE_SUB_MERCHANT_ADVANCE" 217) 218 219type FundsFromItem struct { 220 Account *Account `json:"account,omitempty"` 221 Amount *int64 `json:"amount,omitempty"` 222} 223 224type PromotionScope string 225 226func (e PromotionScope) Ptr() *PromotionScope { 227 return &e 228} 229 230const ( 231 PROMOTIONSCOPE_GLOBAL PromotionScope = "GLOBAL" 232 PROMOTIONSCOPE_SINGLE PromotionScope = "SINGLE" 233) 234 235type PromotionType string 236 237func (e PromotionType) Ptr() *PromotionType { 238 return &e 239} 240 241const ( 242 PROMOTIONTYPE_COUPON PromotionType = "COUPON" 243 PROMOTIONTYPE_DISCOUNT PromotionType = "DISCOUNT" 244) 245 246type GoodsDetail struct { 247 MerchantGoodsId *string `json:"merchant_goods_id,omitempty"` 248 WechatpayGoodsId *string `json:"wechatpay_goods_id,omitempty"` 249 GoodsName *string `json:"goods_name,omitempty"` 250 UnitPrice *int64 `json:"unit_price,omitempty"` 251 RefundAmount *int64 `json:"refund_amount,omitempty"` 252 RefundQuantity *int64 `json:"refund_quantity,omitempty"` 253} 254 255type Account string 256 257func (e Account) Ptr() *Account { 258 return &e 259} 260 261const ( 262 ACCOUNT_AVAILABLE Account = "AVAILABLE" 263 ACCOUNT_UNAVAILABLE Account = "UNAVAILABLE" 264) 265
应答参数
|
refund_id 必填 string(32)
【微信支付退款单号】申请退款受理成功时,该笔退款单在微信支付侧生成的唯一标识。
out_refund_no 必填 string(64)
【商户退款单号】 服务商申请退款时传入的商户系统内部退款单号。
transaction_id 必填 string(32)
【微信支付订单号】微信支付侧订单的唯一标识。
out_trade_no 必填 string(32)
【商户订单号】 服务商下单时传入的服务商系统内部订单号。
channel 必填 string
【退款渠道】 订单退款渠道
以下枚举:
ORIGINAL
: 原路退款BALANCE
: 退回到余额OTHER_BALANCE
: 原账户异常退到其他余额账户OTHER_BANKCARD
: 原银行卡异常退到其他银行卡(发起异常退款成功后返回)
user_received_account 必填 string(64)
【退款入账账户】 取当前退款单的退款入账方,有以下几种情况:
1)退回银行卡:{银行名称}{卡类型}{卡尾号}
2)退回支付用户零钱:支付用户零钱
3)退还商户:商户基本账户商户结算银行账户
4)退回支付用户零钱通:支付用户零钱通
5)退回支付用户银行电子账户:支付用户银行电子账户
6)退回支付用户零花钱:支付用户零花钱
7)退回用户经营账户:用户经营账户
8)退回支付用户来华零钱包:支付用户来华零钱包
9)退回企业支付商户:企业支付商户
10)退回支付用户小金罐:支付用户小金罐
success_time 选填 string(64)
【退款成功时间】
1、定义:退款成功的时间,该字段在退款状态status为SUCCESS(退款成功)时返回。
2、格式:遵循rfc3339标准格式:yyyy-MM-DDTHH:mm:ss+TIMEZONE
。yyyy-MM-DD
表示年月日;T
字符用于分隔日期和时间部分;HH:mm:ss
表示具体的时分秒;TIMEZONE
表示时区(例如,+08:00
对应东八区时间,即北京时间)。
示例:2015-05-20T13:29:35+08:00
表示北京时间2015年5月20日13点29分35秒。
create_time 必填 string(64)
【退款创建时间】
1、定义:提交退款申请成功,微信受理退款申请单的时间。
2、格式:遵循rfc3339标准格式:yyyy-MM-DDTHH:mm:ss+TIMEZONE
。yyyy-MM-DD
表示年月日;T
字符用于分隔日期和时间部分;HH:mm:ss
表示具体的时分秒;TIMEZONE
表示时区(例如,+08:00
对应东八区时间,即北京时间)。
示例:2015-05-20T13:29:35+08:00
表示北京时间2015年5月20日13点29分35秒。
status 必填 string
【退款状态】退款单的退款处理状态。
SUCCESS
: 退款成功CLOSED
: 退款关闭PROCESSING
: 退款处理中ABNORMAL
: 退款异常,退款到银行发现用户的卡作废或者冻结了,导致原路退款银行卡失败,可前往服务商平台-交易中心,手动处理此笔退款,可参考: 退款异常的处理,或者通过发起异常退款接口进行处理。
注:状态流转说明请参考状态流转图
funds_account 必填 string
【资金账户】 退款所使用资金对应的资金账户类型
UNSETTLED
: 未结算资金AVAILABLE
: 可用余额UNAVAILABLE
: 不可用余额OPERATION
: 运营账户BASIC
: 基本账户(含可用余额和不可用余额)ECNY_BASIC
: 数字人民币基本账户
amount 必填 object
【金额信息】订单退款金额信息
属性 | |||||
total 必填 integer 【订单金额】 订单总金额,单位为分 refund 必填 integer 【退款金额】退款金额,单位为分,只能为整数,可以做部分退款,不能超过原订单支付金额。 from 选填 array[object] 【退款出资账户及金额】 退款出资的账户类型及金额信息,若此接口请求时未传该参数,则不会返回。
payer_total 必填 integer 【用户实际支付金额】用户现金支付金额,整型,单位为分,例如10元订单用户使用了2元全场代金券,则该金额为用户实际支付的8元。 payer_refund 必填 integer 【用户退款金额】 指用户实际收到的现金退款金额,数据类型为整型,单位为分。例如在一个10元的订单中,用户使用了2元的全场代金券,若商户申请退款5元,则用户将收到4元的现金退款(即该字段所示金额)和1元的代金券退款。 settlement_refund 必填 integer 【应结退款金额】 去掉免充值代金券退款金额后的退款金额,整型,单位为分,例如10元订单用户使用了2元全场代金券(一张免充值1元 + 一张预充值1元),商户申请退款5元,则该金额为 退款金额5元 - 0.5元免充值代金券退款金额 = 4.5元。 settlement_total 必填 integer 【应结订单金额】去除免充值代金券金额后的订单金额,整型,单位为分,例如10元订单用户使用了2元全场代金券(一张免充值1元 + 一张预充值1元),则该金额为 订单金额10元 - 免充值代金券金额1元 = 9元。 discount_refund 必填 integer 【优惠退款金额】 申请退款后用户收到的代金券退款金额,整型,单位为分,例如10元订单用户使用了2元全场代金券,商户申请退款5元,用户收到的是4元现金 + 1元代金券退款金额(该字段) 。 currency 必填 string(16) 【退款币种】 固定返回:CNY,代表人民币。 refund_fee 选填 integer 【手续费退款金额】 订单退款时退还的手续费金额,整型,单位为分,例如一笔100元的订单收了0.6元手续费,商户申请退款50元,该金额为等比退还的0.3元手续费。 |
promotion_detail 选填 array[object]
【优惠退款详情】 订单各个代金券的退款详情,订单使用了代金券且代金券发生退款时返回。
属性 | |||||
promotion_id 必填 string(32) 【券ID】代金券id,单张代金券的编号 scope 必填 string 【优惠范围】优惠活动中代金券的适用范围,分为两种类型: type 必填 string 【优惠类型】代金券资金类型,优惠活动中代金券的结算资金类型,分为两种类型: amount 必填 integer 【优惠券面额】 代金券优惠的金额 refund_amount 必填 integer 【优惠退款金额】 代金券退款的金额 goods_detail 选填 array[object] 【退款商品】 指定商品退款时传的退款商品信息。
|
应答示例
200 OK
1{ 2 "refund_id" : "50000000382019052709732678859", 3 "out_refund_no" : "1217752501201407033233368018", 4 "transaction_id" : "1217752501201407033233368018", 5 "out_trade_no" : "1217752501201407033233368018", 6 "channel" : "ORIGINAL", 7 "user_received_account" : "招商银行信用卡0403", 8 "success_time" : "2020-12-01T16:18:12+08:00", 9 "create_time" : "2020-12-01T16:18:12+08:00", 10 "status" : "SUCCESS", 11 "funds_account" : "UNSETTLED", 12 "amount" : { 13 "total" : 100, 14 "refund" : 100, 15 "from" : [ 16 { 17 "account" : "AVAILABLE", 18 "amount" : 444 19 } 20 ], 21 "payer_total" : 90, 22 "payer_refund" : 90, 23 "settlement_refund" : 100, 24 "settlement_total" : 100, 25 "discount_refund" : 10, 26 "currency" : "CNY", 27 "refund_fee" : 100, 28 "advance" : 888 29 }, 30 "promotion_detail" : [ 31 { 32 "promotion_id" : "109519", 33 "scope" : "SINGLE", 34 "type" : "DISCOUNT", 35 "amount" : 5, 36 "refund_amount" : 100, 37 "goods_detail" : [ 38 { 39 "merchant_goods_id" : "1217752501201407033233368018", 40 "wechatpay_goods_id" : "1001", 41 "goods_name" : "iPhone6s 16G", 42 "unit_price" : 528800, 43 "refund_amount" : 528800, 44 "refund_quantity" : 1 45 } 46 ] 47 } 48 ], 49 "refund_account" : "REFUND_SOURCE_SUB_MERCHANT" 50} 51
错误码
公共错误码
状态码 | 错误码 | 描述 | 解决方案 |
---|---|---|---|
400 | PARAM_ERROR | 参数错误 | 请根据错误提示正确传入参数 |
400 | INVALID_REQUEST | HTTP 请求不符合微信支付 APIv3 接口规则 | 请参阅 接口规则 |
401 | SIGN_ERROR | 验证不通过 | 请参阅 签名常见问题 |
500 | SYSTEM_ERROR | 系统异常,请稍后重试 | 请稍后重试 |
业务错误码
状态码 | 错误码 | 描述 | 解决方案 |
---|---|---|---|
401 | SIGN_ERROR | 签名错误 | 请检查签名参数和方法是否都符合签名算法要求,参考:如何生成签名 |
404 | MCH_NOT_EXISTS | MCHID不存在 | 请检查商户号是否正确,商户号获取方式请参考服务商模式开发必要参数说明 |
404 | RESOURCE_NOT_EXISTS | 退款单不存在 | 请检查商户退款单号是否有误以及订单状态是否正确,如:未支付 |
500 | SYSTEM_ERROR | 系统超时 | 请不要更换商户退款单号,请使用相同参数再次调用API。 |