查询保险理赔结果(按商户赔付单号)
更新时间:2025.07.25商户单号查询保险理赔记录。
注:接口频率限制为100次/s
接口说明
支持商户:【平台商户】
请求方式:【GET】/v3/platsolution/ecommerce/mch-transfer/insurance-claim-bills/out-bill-no/{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 查询参数
sub_mchid 选填 string(32)
【二级商户号】 微信支付分配的商户号,出资商户号
请求示例
需配合微信支付工具库 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 InsuranceClaimBillGetByOutNo { 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/insurance-claim-bills/out-bill-no/{out_bill_no}"; 29 30 public static void main(String[] args) { 31 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340 32 InsuranceClaimBillGetByOutNo client = new InsuranceClaimBillGetByOutNo( 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 InsuranceClaimBillGetByOutNoRequest request = new InsuranceClaimBillGetByOutNoRequest(); 41 request.outBillNo = "plfk2020042013"; 42 request.subMchid = "1900001109"; 43 try { 44 MchTransferBillEntity response = client.run(request); 45 46 // TODO: 请求成功,继续业务逻辑 47 System.out.println(response); 48 } catch (WXPayUtility.ApiException e) { 49 // TODO: 请求失败,根据状态码执行不同的逻辑 50 e.printStackTrace(); 51 } 52 } 53 54 public MchTransferBillEntity run(InsuranceClaimBillGetByOutNoRequest request) { 55 String uri = PATH; 56 uri = uri.replace("{out_bill_no}", WXPayUtility.urlEncode(request.outBillNo)); 57 Map<String, Object> args = new HashMap<>(); 58 args.put("sub_mchid", request.subMchid); 59 uri = uri + "?" + WXPayUtility.urlEncode(args); 60 61 Request.Builder reqBuilder = new Request.Builder().url(HOST + uri); 62 reqBuilder.addHeader("Accept", "application/json"); 63 reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId); 64 reqBuilder.addHeader("Authorization", WXPayUtility.buildAuthorization(mchid, certificateSerialNo, privateKey, METHOD, uri, null)); 65 reqBuilder.method(METHOD, null); 66 Request httpRequest = reqBuilder.build(); 67 68 // 发送HTTP请求 69 OkHttpClient client = new OkHttpClient.Builder().build(); 70 try (Response httpResponse = client.newCall(httpRequest).execute()) { 71 String respBody = WXPayUtility.extractBody(httpResponse); 72 if (httpResponse.code() >= 200 && httpResponse.code() < 300) { 73 // 2XX 成功,验证应答签名 74 WXPayUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey, 75 httpResponse.headers(), respBody); 76 77 // 从HTTP应答报文构建返回数据 78 return WXPayUtility.fromJson(respBody, MchTransferBillEntity.class); 79 } else { 80 throw new WXPayUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers()); 81 } 82 } catch (IOException e) { 83 throw new UncheckedIOException("Sending request to " + uri + " failed.", e); 84 } 85 } 86 87 private final String mchid; 88 private final String certificateSerialNo; 89 private final PrivateKey privateKey; 90 private final String wechatPayPublicKeyId; 91 private final PublicKey wechatPayPublicKey; 92 93 public InsuranceClaimBillGetByOutNo(String mchid, String certificateSerialNo, String privateKeyFilePath, String wechatPayPublicKeyId, String wechatPayPublicKeyFilePath) { 94 this.mchid = mchid; 95 this.certificateSerialNo = certificateSerialNo; 96 this.privateKey = WXPayUtility.loadPrivateKeyFromPath(privateKeyFilePath); 97 this.wechatPayPublicKeyId = wechatPayPublicKeyId; 98 this.wechatPayPublicKey = WXPayUtility.loadPublicKeyFromPath(wechatPayPublicKeyFilePath); 99 } 100 101 public static class InsuranceClaimBillGetByOutNoRequest { 102 @SerializedName("sub_mchid") 103 @Expose(serialize = false) 104 public String subMchid; 105 106 @SerializedName("out_bill_no") 107 @Expose(serialize = false) 108 public String outBillNo; 109 110 @SerializedName("business_type") 111 @Expose(serialize = false) 112 public BusinsssType businessType; 113 } 114 115 public static class MchTransferBillEntity { 116 @SerializedName("sp_mchid") 117 public String spMchid; 118 119 @SerializedName("sub_mchid") 120 public String subMchid; 121 122 @SerializedName("receiver_detail") 123 public ReceiverDetailInfo receiverDetail; 124 125 @SerializedName("out_bill_no") 126 public String outBillNo; 127 128 @SerializedName("amount") 129 public Long amount; 130 131 @SerializedName("transfer_remark") 132 public String transferRemark; 133 134 @SerializedName("bill_id") 135 public String billId; 136 137 @SerializedName("state") 138 public TransferStatus state; 139 140 @SerializedName("accept_time") 141 public String acceptTime; 142 143 @SerializedName("success_time") 144 public String successTime; 145 146 @SerializedName("close_info") 147 public TransferCloseInfo closeInfo; 148 149 @SerializedName("sponsor_mchid") 150 public String sponsorMchid; 151 } 152 153 public enum BusinsssType { 154 @SerializedName("DEPOSIT_COMPENSATION") 155 DEPOSIT_COMPENSATION, 156 @SerializedName("PLATFORM_AFTER_SALES_COMPENSATION") 157 PLATFORM_AFTER_SALES_COMPENSATION, 158 @SerializedName("INSURANCE_CLAIM") 159 INSURANCE_CLAIM, 160 @SerializedName("DEPOSIT_AFTER_SALES_COMPENSATION") 161 DEPOSIT_AFTER_SALES_COMPENSATION 162 } 163 164 public static class ReceiverDetailInfo { 165 @SerializedName("receiver") 166 public ReceiverEntity receiver; 167 } 168 169 public enum TransferStatus { 170 @SerializedName("ACCEPTED") 171 ACCEPTED, 172 @SerializedName("SUCCESS") 173 SUCCESS, 174 @SerializedName("CLOSED") 175 CLOSED, 176 @SerializedName("WAIT_USER_CONFIRM") 177 WAIT_USER_CONFIRM, 178 @SerializedName("CANCELING") 179 CANCELING, 180 @SerializedName("CANCELLED") 181 CANCELLED 182 } 183 184 public static class TransferCloseInfo { 185 @SerializedName("close_time") 186 public String closeTime; 187 188 @SerializedName("close_reason") 189 public String closeReason; 190 } 191 192 public static class ReceiverEntity { 193 @SerializedName("type") 194 public ReceiverType type; 195 196 @SerializedName("transaction_info") 197 public TransactionInfo transactionInfo; 198 } 199 200 public enum ReceiverType { 201 @SerializedName("MERCHANT") 202 MERCHANT, 203 @SerializedName("TRANSACTION_USER") 204 TRANSACTION_USER 205 } 206 207 public static class TransactionInfo { 208 @SerializedName("transaction_id") 209 public String transactionId; 210 211 @SerializedName("type") 212 public TransactionType type; 213 } 214 215 public enum TransactionType { 216 @SerializedName("WXPAY") 217 WXPAY, 218 @SerializedName("WXVALUE") 219 WXVALUE 220 } 221 222} 223
需配合微信支付工具库 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 := &InsuranceClaimBillGetByOutNoRequest{ 28 SubMchid: wxpay_utility.String("1900001109"), 29 OutBillNo: wxpay_utility.String("plfk2020042013"), 30 } 31 32 response, err := InsuranceClaimBillGetByOutNo(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 InsuranceClaimBillGetByOutNo(config *wxpay_utility.MchConfig, request *InsuranceClaimBillGetByOutNoRequest) (response *MchTransferBillEntity, err error) { 44 const ( 45 host = "https://api.mch.weixin.qq.com" 46 method = "GET" 47 path = "/v3/platsolution/ecommerce/mch-transfer/insurance-claim-bills/out-bill-no/{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 query.Add("sub_mchid", *request.SubMchid) 57 reqUrl.RawQuery = query.Encode() 58 httpRequest, err := http.NewRequest(method, reqUrl.String(), nil) 59 if err != nil { 60 return nil, err 61 } 62 httpRequest.Header.Set("Accept", "application/json") 63 httpRequest.Header.Set("Wechatpay-Serial", config.WechatPayPublicKeyId()) 64 authorization, err := wxpay_utility.BuildAuthorization(config.MchId(), config.CertificateSerialNo(), config.PrivateKey(), method, reqUrl.RequestURI(), nil) 65 if err != nil { 66 return nil, err 67 } 68 httpRequest.Header.Set("Authorization", authorization) 69 70 client := &http.Client{} 71 httpResponse, err := client.Do(httpRequest) 72 if err != nil { 73 return nil, err 74 } 75 76 respBody, err := wxpay_utility.ExtractResponseBody(httpResponse) 77 if err != nil { 78 return nil, err 79 } 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 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 InsuranceClaimBillGetByOutNoRequest struct { 108 SubMchid *string `json:"sub_mchid,omitempty"` 109 OutBillNo *string `json:"out_bill_no,omitempty"` 110 BusinessType *BusinsssType `json:"business_type,omitempty"` 111} 112 113func (o *InsuranceClaimBillGetByOutNoRequest) MarshalJSON() ([]byte, error) { 114 type Alias InsuranceClaimBillGetByOutNoRequest 115 a := &struct { 116 SubMchid *string `json:"sub_mchid,omitempty"` 117 OutBillNo *string `json:"out_bill_no,omitempty"` 118 BusinessType *BusinsssType `json:"business_type,omitempty"` 119 *Alias 120 }{ 121 // 序列化时移除非 Body 字段 122 SubMchid: nil, 123 OutBillNo: 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 SubMchid *string `json:"sub_mchid,omitempty"` 133 ReceiverDetail *ReceiverDetailInfo `json:"receiver_detail,omitempty"` 134 OutBillNo *string `json:"out_bill_no,omitempty"` 135 Amount *int64 `json:"amount,omitempty"` 136 TransferRemark *string `json:"transfer_remark,omitempty"` 137 BillId *string `json:"bill_id,omitempty"` 138 State *TransferStatus `json:"state,omitempty"` 139 AcceptTime *time.Time `json:"accept_time,omitempty"` 140 SuccessTime *time.Time `json:"success_time,omitempty"` 141 CloseInfo *TransferCloseInfo `json:"close_info,omitempty"` 142 SponsorMchid *string `json:"sponsor_mchid,omitempty"` 143} 144 145type BusinsssType string 146 147func (e BusinsssType) Ptr() *BusinsssType { 148 return &e 149} 150 151const ( 152 BUSINSSSTYPE_DEPOSIT_COMPENSATION BusinsssType = "DEPOSIT_COMPENSATION" 153 BUSINSSSTYPE_PLATFORM_AFTER_SALES_COMPENSATION BusinsssType = "PLATFORM_AFTER_SALES_COMPENSATION" 154 BUSINSSSTYPE_INSURANCE_CLAIM BusinsssType = "INSURANCE_CLAIM" 155 BUSINSSSTYPE_DEPOSIT_AFTER_SALES_COMPENSATION BusinsssType = "DEPOSIT_AFTER_SALES_COMPENSATION" 156) 157 158type ReceiverDetailInfo struct { 159 Receiver *ReceiverEntity `json:"receiver,omitempty"` 160} 161 162type TransferStatus string 163 164func (e TransferStatus) Ptr() *TransferStatus { 165 return &e 166} 167 168const ( 169 TRANSFERSTATUS_ACCEPTED TransferStatus = "ACCEPTED" 170 TRANSFERSTATUS_SUCCESS TransferStatus = "SUCCESS" 171 TRANSFERSTATUS_CLOSED TransferStatus = "CLOSED" 172 TRANSFERSTATUS_WAIT_USER_CONFIRM TransferStatus = "WAIT_USER_CONFIRM" 173 TRANSFERSTATUS_CANCELING TransferStatus = "CANCELING" 174 TRANSFERSTATUS_CANCELLED TransferStatus = "CANCELLED" 175) 176 177type TransferCloseInfo struct { 178 CloseTime *time.Time `json:"close_time,omitempty"` 179 CloseReason *string `json:"close_reason,omitempty"` 180} 181 182type ReceiverEntity struct { 183 Type *ReceiverType `json:"type,omitempty"` 184 TransactionInfo *TransactionInfo `json:"transaction_info,omitempty"` 185} 186 187type ReceiverType string 188 189func (e ReceiverType) Ptr() *ReceiverType { 190 return &e 191} 192 193const ( 194 RECEIVERTYPE_MERCHANT ReceiverType = "MERCHANT" 195 RECEIVERTYPE_TRANSACTION_USER ReceiverType = "TRANSACTION_USER" 196) 197 198type TransactionInfo struct { 199 TransactionId *string `json:"transaction_id,omitempty"` 200 Type *TransactionType `json:"type,omitempty"` 201} 202 203type TransactionType string 204 205func (e TransactionType) Ptr() *TransactionType { 206 return &e 207} 208 209const ( 210 TRANSACTIONTYPE_WXPAY TransactionType = "WXPAY" 211 TRANSACTIONTYPE_WXVALUE TransactionType = "WXVALUE" 212) 213
GET
1curl -X GET \ 2 https://api.mch.weixin.qq.com/v3/platsolution/ecommerce/mch-transfer/insurance-claim-bills/out-bill-no/plfk2020042013?sub_mchid=1900001109 \ 3 -H "Authorization: WECHATPAY2-SHA256-RSA2048 mchid=\"1900000001\",..." \ 4 -H "Accept: application/json" 5
应答参数
200 OK
sp_mchid 必填 string(32)
【服务商商户号】 微信支付分配的商户号
sub_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
: 系统关闭(余额不足、转账失败等原因)。WAIT_USER_CONFIRM
: 预下单成功,等待用户确认CANCELING
: 商户撤销请求受理成功,该笔付款正在撤销中CANCELLED
: 付款撤销完成
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 "sub_mchid" : "1900001109", 4 "receiver_detail" : { 5 "receiver" : { 6 "type" : "TRANSACTION_USER", 7 "transaction_info" : { 8 "transaction_id" : "1217752501201407033233368018", 9 "type" : "WXPAY" 10 } 11 } 12 }, 13 "out_bill_no" : "plfk2020042013", 14 "amount" : 10000, 15 "transfer_remark" : "直播违规扣罚", 16 "bill_id" : "1330000071100999991182020050700019480001", 17 "state" : "SUCCESS", 18 "accept_time" : "2015-05-20T13:29:35+08:00", 19 "success_time" : "2015-05-20T13:29:35+08:00", 20 "close_info" : { 21 "close_time" : "2015-05-20T13:29:35+08:00", 22 "close_reason" : "NOT_ENOUGH" 23 }, 24 "sponsor_mchid" : "1900001109" 25} 26
错误码
公共错误码
状态码 | 错误码 | 描述 | 解决方案 |
---|---|---|---|
400 | PARAM_ERROR | 参数错误 | 请根据错误提示正确传入参数 |
400 | INVALID_REQUEST | HTTP 请求不符合微信支付 APIv3 接口规则 | 请参阅 接口规则 |
401 | SIGN_ERROR | 验证不通过 | 请参阅 签名常见问题 |
500 | SYSTEM_ERROR | 系统异常,请稍后重试 | 请稍后重试 |