查询保险理赔结果(按商户赔付单号)

更新时间: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)

【二级商户号】 微信支付分配的商户号,出资商户号

请求示例

Java
Go
curl

需配合微信支付工具库 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

应答参数

200 OK

 sp_mchid  必填   string(32)

【服务商商户号】 微信支付分配的商户号


 sub_mchid  选填   string(32)

【二级商户号】 微信支付分配的商户号


 receiver_detail  必填   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

【关单信息】 当状态为已关闭时返回,转账的关闭信息,如关闭原因等

属性

 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

系统异常,请稍后重试

请稍后重试

 

 

更多技术问题
技术咨询
反馈
咨询
目录
置顶