请求保险理赔预下单

更新时间:2025.07.25

商户可调用该接口进行赔付预下单,并锁定商户资金。若赔付订单状态已经为终态(成功或关闭),接口将返回错误码。
在预下单成功后,商户需携带接口返回的跳转参数,引导用户至微信内进行确认,用户确认后执行赔付。若预下单后超过24小时没有赔付成功,系统将自动关闭订单。
订单赔付成功或者关闭时,系统将通过接口指定的商户回调地址通知赔付结果。

注:接口频率限制为100次/s

接口说明

支持商户:【平台商户】

请求方式:【POST】/v3/platsolution/ecommerce/mch-transfer/insurance-claim-bills/pre-transfer

请求域名:【主域名】https://api.mch.weixin.qq.com 使用该域名将访问就近的接入点

     【备域名】https://api2.mch.weixin.qq.com 使用该域名将访问异地的接入点 ,指引点击查看

请求参数

Header  HTTP头参数

 Authorization  必填 string

请参考签名认证生成认证信息


 Accept  必填 string

请设置为application/json


 Content-Type  必填 string

请设置为application/json


body  包体参数

 sub_mchid  选填   string(32)

【二级商户号】 微信支付分配的商户号,若指定二级商户号,则该商户为出资商户,若不指定二级商户号,必须指定出资商户号


 receiver  必填   object

【收款方信息】 收款方信息

属性

 out_bill_no  必填   string(32)

【商户单号】 商户系统内部的单号,只能由数字、大小写字母组成,在服务商系统内部唯一


 amount  必填   integer

【金额】 金额,单位为“分”


 transfer_remark  必填   string(32)

【赔付原因】 赔付原因


 notify_url  选填   string(256)

【商户回调地址】 异步接收微信支付转账结果通知的回调地址,通知URL必须为公网可访问的URL,必须为HTTPS,不能携带参数。

请求示例

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 InsuranceClaimBillPreTransfer {
26  private static String HOST = "https://api.mch.weixin.qq.com";
27  private static String METHOD = "POST";
28  private static String PATH = "/v3/platsolution/ecommerce/mch-transfer/insurance-claim-bills/pre-transfer";
29
30  public static void main(String[] args) {
31    // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340
32    InsuranceClaimBillPreTransfer client = new InsuranceClaimBillPreTransfer(
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    TransferRequest request = new TransferRequest();
41    request.subMchid = "1900001109";
42    request.receiver = new ReceiverEntity();
43    request.receiver.type = ReceiverType.MERCHANT;
44    request.receiver.mchInfo = new MerchantInfo();
45    request.receiver.mchInfo.mchid = "1900001108";
46    request.outBillNo = "plfk2020042013";
47    request.amount = 10000L;
48    request.transferRemark = "直播违规扣罚";
49    request.notifyUrl = "https://www.weixin.qq.com/wxpay/pay.php";
50    try {
51      PreTransferResponse response = client.run(request);
52
53      // TODO: 请求成功,继续业务逻辑
54      System.out.println(response);
55    } catch (WXPayUtility.ApiException e) {
56      // TODO: 请求失败,根据状态码执行不同的逻辑
57      e.printStackTrace();
58    }
59  }
60
61  public PreTransferResponse run(TransferRequest request) {
62    String uri = PATH;
63    String reqBody = WXPayUtility.toJson(request);
64
65    Request.Builder reqBuilder = new Request.Builder().url(HOST + uri);
66    reqBuilder.addHeader("Accept", "application/json");
67    reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId);
68    reqBuilder.addHeader("Authorization", WXPayUtility.buildAuthorization(mchid, certificateSerialNo,privateKey, METHOD, uri, reqBody));
69    reqBuilder.addHeader("Content-Type", "application/json");
70    RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), reqBody);
71    reqBuilder.method(METHOD, requestBody);
72    Request httpRequest = reqBuilder.build();
73
74    // 发送HTTP请求
75    OkHttpClient client = new OkHttpClient.Builder().build();
76    try (Response httpResponse = client.newCall(httpRequest).execute()) {
77      String respBody = WXPayUtility.extractBody(httpResponse);
78      if (httpResponse.code() >= 200 && httpResponse.code() < 300) {
79        // 2XX 成功,验证应答签名
80        WXPayUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey,
81            httpResponse.headers(), respBody);
82
83        // 从HTTP应答报文构建返回数据
84        return WXPayUtility.fromJson(respBody, PreTransferResponse.class);
85      } else {
86        throw new WXPayUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers());
87      }
88    } catch (IOException e) {
89      throw new UncheckedIOException("Sending request to " + uri + " failed.", e);
90    }
91  }
92
93  private final String mchid;
94  private final String certificateSerialNo;
95  private final PrivateKey privateKey;
96  private final String wechatPayPublicKeyId;
97  private final PublicKey wechatPayPublicKey;
98
99  public InsuranceClaimBillPreTransfer(String mchid, String certificateSerialNo, String privateKeyFilePath, String wechatPayPublicKeyId, String wechatPayPublicKeyFilePath) {
100    this.mchid = mchid;
101    this.certificateSerialNo = certificateSerialNo;
102    this.privateKey = WXPayUtility.loadPrivateKeyFromPath(privateKeyFilePath);
103    this.wechatPayPublicKeyId = wechatPayPublicKeyId;
104    this.wechatPayPublicKey = WXPayUtility.loadPublicKeyFromPath(wechatPayPublicKeyFilePath);
105  }
106
107  public static class TransferRequest {
108    @SerializedName("sub_mchid")
109    public String subMchid;
110  
111    @SerializedName("receiver")
112    public ReceiverEntity receiver;
113  
114    @SerializedName("out_bill_no")
115    public String outBillNo;
116  
117    @SerializedName("amount")
118    public Long amount;
119  
120    @SerializedName("transfer_remark")
121    public String transferRemark;
122  
123    @SerializedName("notify_url")
124    public String notifyUrl;
125  }
126  
127  public static class PreTransferResponse {
128    @SerializedName("sub_mchid")
129    public String subMchid;
130  
131    @SerializedName("out_bill_no")
132    public String outBillNo;
133  
134    @SerializedName("bill_id")
135    public String billId;
136  
137    @SerializedName("accept_time")
138    public String acceptTime;
139  
140    @SerializedName("package_info")
141    public String packageInfo;
142  }
143  
144  public static class ReceiverEntity {
145    @SerializedName("type")
146    public ReceiverType type;
147  
148    @SerializedName("transaction_info")
149    public TransactionInfo transactionInfo;
150  }
151  
152  public enum ReceiverType {
153    @SerializedName("MERCHANT")
154    MERCHANT,
155    @SerializedName("TRANSACTION_USER")
156    TRANSACTION_USER
157  }
158  
159  public static class TransactionInfo {
160    @SerializedName("transaction_id")
161    public String transactionId;
162  
163    @SerializedName("type")
164    public TransactionType type;
165  }
166  
167  public enum TransactionType {
168    @SerializedName("WXPAY")
169    WXPAY,
170    @SerializedName("WXVALUE")
171    WXVALUE
172  }
173  
174}
175

应答参数

200 OK

 sub_mchid  选填   string(32)

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


 out_bill_no  必填   string(32)

【商户单号】 商户系统内部的商家单号,只能由数字、大小写字母组成,在商户系统内部唯一


 bill_id  必填   string(64)

【微信支付付款单号】 微信支付付款单号


 accept_time  必填   string(32)

【受理时间】 受理成功时会返回,按照使用rfc3339所定义的格式,格式为yyyy-MM-DDThh:mm:ss+TIMEZONE


 package_info  必填   string(1024)

【跳转领取页面的package信息】 商家付款单跳转微信支付收款页的package信息,该数据在24小时内有效;只有在待用户确认中才返回

应答示例

200 OK

1{
2  "sub_mchid" : "1900001109",
3  "out_bill_no" : "plfk2020042013",
4  "bill_id" : "1330000071100999991182020050700019480001",
5  "accept_time" : "2015-05-20T13:29:35+08:00",
6  "package_info" : "affffddafdfafddffda=="
7}
8

 

错误码

公共错误码

状态码

错误码

描述

解决方案

400

PARAM_ERROR

参数错误

请根据错误提示正确传入参数

400

INVALID_REQUEST

HTTP 请求不符合微信支付 APIv3 接口规则

请参阅 接口规则

401

SIGN_ERROR

验证不通过

请参阅 签名常见问题

500

SYSTEM_ERROR

系统异常,请稍后重试

请稍后重试

 

 

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