查询赔付商家的结果
更新时间:2025.12.04查询赔付商家的结果。
注:接口频率限制为100次/s
接口说明
支持商户:【平台商户】
请求方式:【GET】/v3/platsolution/ecommerce/mch-transfer/sub-mch-compensation-bills/{out_bill_no}
请求域名:【主域名】https://api.mch.weixin.qq.com 使用该域名将访问就近的接入点
【备域名】https://api2.mch.weixin.qq.com 使用该域名将访问异地的接入点 ,指引点击查看
请求参数
Header HTTP头参数
Authorization 必填 string
请参考签名认证生成认证信息
Accept 必填 string
请设置为application/json
path 路径参数
out_bill_no 必填 string(32)
【商户单号】 商户系统内部的单号,只能由数字、大小写字母组成,在服务商系统内部唯一
query 查询参数
sponsor_mchid 选填 string(32)
【出资商户号】 出资商户号
请求示例
GET
1curl -X GET \ 2 https://api.mch.weixin.qq.com/v3/platsolution/ecommerce/mch-transfer/sub-mch-compensation-bills/plfk2020042013?sponsor_mchid=1900001109 \ 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 SubMchCompensationBillGetByOutNo { 26 private static String HOST = "https://api.mch.weixin.qq.com"; 27 private static String METHOD = "GET"; 28 private static String PATH = "/v3/platsolution/ecommerce/mch-transfer/sub-mch-compensation-bills/{out_bill_no}"; 29 30 public static void main(String[] args) { 31 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340 32 SubMchCompensationBillGetByOutNo client = new SubMchCompensationBillGetByOutNo( 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 SubMchCompensationBillGetByOutNoRequest request = new SubMchCompensationBillGetByOutNoRequest(); 41 request.outBillNo = "plfk2020042013"; 42 request.sponsorMchid = "1900001109"; 43 try { 44 MchTransferBillEntity 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 MchTransferBillEntity run(SubMchCompensationBillGetByOutNoRequest request) { 54 String uri = PATH; 55 uri = uri.replace("{out_bill_no}", WXPayUtility.urlEncode(request.outBillNo)); 56 Map<String, Object> args = new HashMap<>(); 57 args.put("sponsor_mchid", request.sponsorMchid); 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, MchTransferBillEntity.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 SubMchCompensationBillGetByOutNo(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 SubMchCompensationBillGetByOutNoRequest { 104 @SerializedName("out_bill_no") 105 @Expose(serialize = false) 106 public String outBillNo; 107 108 @SerializedName("sponsor_mchid") 109 @Expose(serialize = false) 110 public String sponsorMchid; 111 112 @SerializedName("business_type") 113 @Expose(serialize = false) 114 public BusinsssType businessType; 115 } 116 117 public static class MchTransferBillEntity { 118 @SerializedName("sp_mchid") 119 public String spMchid; 120 121 @SerializedName("receiver_detail") 122 public ReceiverDetailInfo receiverDetail; 123 124 @SerializedName("out_bill_no") 125 public String outBillNo; 126 127 @SerializedName("amount") 128 public Long amount; 129 130 @SerializedName("transfer_remark") 131 public String transferRemark; 132 133 @SerializedName("bill_id") 134 public String billId; 135 136 @SerializedName("state") 137 public TransferStatus state; 138 139 @SerializedName("accept_time") 140 public String acceptTime; 141 142 @SerializedName("success_time") 143 public String successTime; 144 145 @SerializedName("close_info") 146 public TransferCloseInfo closeInfo; 147 148 @SerializedName("sponsor_mchid") 149 public String sponsorMchid; 150 } 151 152 public enum BusinsssType { 153 @SerializedName("DEPOSIT_COMPENSATION") 154 DEPOSIT_COMPENSATION, 155 @SerializedName("PLATFORM_AFTER_SALES_COMPENSATION") 156 PLATFORM_AFTER_SALES_COMPENSATION, 157 @SerializedName("INSURANCE_CLAIM") 158 INSURANCE_CLAIM, 159 @SerializedName("DEPOSIT_AFTER_SALES_COMPENSATION") 160 DEPOSIT_AFTER_SALES_COMPENSATION 161 } 162 163 public static class ReceiverDetailInfo { 164 @SerializedName("receiver") 165 public ReceiverEntity receiver; 166 } 167 168 public enum TransferStatus { 169 @SerializedName("ACCEPTED") 170 ACCEPTED, 171 @SerializedName("SUCCESS") 172 SUCCESS, 173 @SerializedName("CLOSED") 174 CLOSED 175 } 176 177 public static class TransferCloseInfo { 178 @SerializedName("close_time") 179 public String closeTime; 180 181 @SerializedName("close_reason") 182 public String closeReason; 183 } 184 185 public static class ReceiverEntity { 186 @SerializedName("type") 187 public ReceiverType type; 188 189 @SerializedName("mch_info") 190 public MerchantInfo mchInfo; 191 } 192 193 public enum ReceiverType { 194 @SerializedName("MERCHANT") 195 MERCHANT 196 } 197 198 public static class MerchantInfo { 199 @SerializedName("mchid") 200 public String mchid; 201 } 202 203} 204
需配合微信支付工具库 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 := &SubMchCompensationBillGetByOutNoRequest{ 28 OutBillNo: wxpay_utility.String("plfk2020042013"), 29 SponsorMchid: wxpay_utility.String("1900001109"), 30 } 31 32 response, err := SubMchCompensationBillGetByOutNo(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 SubMchCompensationBillGetByOutNo(config *wxpay_utility.MchConfig, request *SubMchCompensationBillGetByOutNoRequest) (response *MchTransferBillEntity, err error) { 44 const ( 45 host = "https://api.mch.weixin.qq.com" 46 method = "GET" 47 path = "/v3/platsolution/ecommerce/mch-transfer/sub-mch-compensation-bills/{out_bill_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_bill_no}", url.PathEscape(*request.OutBillNo), -1) 55 query := reqUrl.Query() 56 if request.SponsorMchid != nil { 57 query.Add("sponsor_mchid", *request.SponsorMchid) 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 := &MchTransferBillEntity{} 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 SubMchCompensationBillGetByOutNoRequest struct { 108 OutBillNo *string `json:"out_bill_no,omitempty"` 109 SponsorMchid *string `json:"sponsor_mchid,omitempty"` 110 BusinessType *BusinsssType `json:"business_type,omitempty"` 111} 112 113func (o *SubMchCompensationBillGetByOutNoRequest) MarshalJSON() ([]byte, error) { 114 type Alias SubMchCompensationBillGetByOutNoRequest 115 a := &struct { 116 OutBillNo *string `json:"out_bill_no,omitempty"` 117 SponsorMchid *string `json:"sponsor_mchid,omitempty"` 118 BusinessType *BusinsssType `json:"business_type,omitempty"` 119 *Alias 120 }{ 121 // 序列化时移除非 Body 字段 122 OutBillNo: nil, 123 SponsorMchid: nil, 124 BusinessType: nil, 125 Alias: (*Alias)(o), 126 } 127 return json.Marshal(a) 128} 129 130type MchTransferBillEntity struct { 131 SpMchid *string `json:"sp_mchid,omitempty"` 132 ReceiverDetail *ReceiverDetailInfo `json:"receiver_detail,omitempty"` 133 OutBillNo *string `json:"out_bill_no,omitempty"` 134 Amount *int64 `json:"amount,omitempty"` 135 TransferRemark *string `json:"transfer_remark,omitempty"` 136 BillId *string `json:"bill_id,omitempty"` 137 State *TransferStatus `json:"state,omitempty"` 138 AcceptTime *time.Time `json:"accept_time,omitempty"` 139 SuccessTime *time.Time `json:"success_time,omitempty"` 140 CloseInfo *TransferCloseInfo `json:"close_info,omitempty"` 141 SponsorMchid *string `json:"sponsor_mchid,omitempty"` 142} 143 144type BusinsssType string 145 146func (e BusinsssType) Ptr() *BusinsssType { 147 return &e 148} 149 150const ( 151 BUSINSSSTYPE_DEPOSIT_COMPENSATION BusinsssType = "DEPOSIT_COMPENSATION" 152 BUSINSSSTYPE_PLATFORM_AFTER_SALES_COMPENSATION BusinsssType = "PLATFORM_AFTER_SALES_COMPENSATION" 153 BUSINSSSTYPE_INSURANCE_CLAIM BusinsssType = "INSURANCE_CLAIM" 154 BUSINSSSTYPE_DEPOSIT_AFTER_SALES_COMPENSATION BusinsssType = "DEPOSIT_AFTER_SALES_COMPENSATION" 155) 156 157type ReceiverDetailInfo struct { 158 Receiver *ReceiverEntity `json:"receiver,omitempty"` 159} 160 161type TransferStatus string 162 163func (e TransferStatus) Ptr() *TransferStatus { 164 return &e 165} 166 167const ( 168 TRANSFERSTATUS_ACCEPTED TransferStatus = "ACCEPTED" 169 TRANSFERSTATUS_SUCCESS TransferStatus = "SUCCESS" 170 TRANSFERSTATUS_CLOSED TransferStatus = "CLOSED" 171) 172 173type TransferCloseInfo struct { 174 CloseTime *time.Time `json:"close_time,omitempty"` 175 CloseReason *string `json:"close_reason,omitempty"` 176} 177 178type ReceiverEntity struct { 179 Type *ReceiverType `json:"type,omitempty"` 180 MchInfo *MerchantInfo `json:"mch_info,omitempty"` 181} 182 183type ReceiverType string 184 185func (e ReceiverType) Ptr() *ReceiverType { 186 return &e 187} 188 189const ( 190 RECEIVERTYPE_MERCHANT ReceiverType = "MERCHANT" 191) 192 193type MerchantInfo struct { 194 Mchid *string `json:"mchid,omitempty"` 195} 196
应答参数
折叠全部参数
200 OK
sp_mchid 必填 string(32)
【服务商商户号】 微信支付分配的商户号
receiver_detail 必填 object
【赔付接收方信息】 赔付接收方信息
| 属性 | |||||||||
receiver 必填 object 【赔付接收者信息】 赔付接收者信息
|
out_bill_no 必填 string(32)
【商户单号】 商户系统内部的单号,只能由数字、大小写字母组成,在服务商系统内部唯一
amount 必填 integer
【赔付金额】 金额,单位为“分”
transfer_remark 必填 string(32)
【赔付备注】 备注,在资金账单中展示
bill_id 必填 string(64)
【微信支付赔付单号】 微信支付赔付单号
state 必填 string
【赔付状态】 赔付状态
可选取值
ACCEPTED: 已受理SUCCESS: 已成功CLOSED: 系统关闭(余额不足、转账失败等原因)。
accept_time 必填 string(32)
【受理时间】 受理成功时会返回,按照使用rfc3339所定义的格式,格式为yyyy-MM-DDThh:mm:ss+TIMEZONE
success_time 选填 string(32)
【成功时间】 赔付成功时会返回,按照使用rfc3339所定义的格式,格式为yyyy-MM-DDThh:mm:ss+TIMEZONE
close_info 选填 object
【关单信息】 当状态为已关闭时返回,赔付的关闭信息,如关闭原因等
| 属性 | |
close_time 选填 string(32) 【关单时间】 单据关闭时会返回,按照使用rfc3339所定义的格式,格式为yyyy-MM-DDThh:mm:ss+TIMEZONE close_reason 选填 string(64) 【关单原因】 当状态为已关闭时返回,关闭信息,如关闭原因等 |
sponsor_mchid 选填 string(32)
【出资商户号】 微信支付分配的商户号
应答示例
200 OK
1{ 2 "sp_mchid" : "1900001108", 3 "receiver_detail" : { 4 "receiver" : { 5 "type" : "MERCHANT", 6 "mch_info" : { 7 "mchid" : "1900001108" 8 } 9 } 10 }, 11 "out_bill_no" : "plfk2020042013", 12 "amount" : 10000, 13 "transfer_remark" : "赔付金发放", 14 "bill_id" : "1330000071100999991182020050700019480001", 15 "state" : "SUCCESS", 16 "accept_time" : "2015-05-20T13:29:35+08:00", 17 "success_time" : "2015-05-20T13:29:35+08:00", 18 "close_info" : { 19 "close_time" : "2015-05-20T13:29:35+08:00", 20 "close_reason" : "NOT_ENOUGH" 21 }, 22 "sponsor_mchid" : "1900001109" 23} 24
错误码
以下是本接口返回的错误码列表。详细错误码规则,请参考微信支付接口规则-错误码和错误提示

