请求保险理赔
更新时间:2025.07.25商户可调用该接口赔付给用户。
注:接口频率限制为100次/s
接口说明
支持商户:【平台商户】
请求方式:【POST】/v3/platsolution/ecommerce/mch-transfer/insurance-claim-bills
请求域名:【主域名】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
【收款方信息】 收款方信息
属性 | |||||
type 选填 string 【转账接收方类型】 转账接收方类型 可选取值
transaction_info 选填 object 【转账接收方订单信息】 转账接收方订单信息,当接收方类型为TRANSACTION_USER时,需要设置。
|
out_bill_no 必填 string(32)
【商户单号】 商户系统内部的单号,只能由数字、大小写字母组成,在服务商系统内部唯一
amount 必填 integer
【金额】 金额,单位为“分”
transfer_remark 必填 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 InsuranceClaimBillTransfer { 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"; 29 30 public static void main(String[] args) { 31 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340 32 InsuranceClaimBillTransfer client = new InsuranceClaimBillTransfer( 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 try { 50 MchTransferBillEntity response = client.run(request); 51 52 // TODO: 请求成功,继续业务逻辑 53 System.out.println(response); 54 } catch (WXPayUtility.ApiException e) { 55 // TODO: 请求失败,根据状态码执行不同的逻辑 56 e.printStackTrace(); 57 } 58 } 59 60 public MchTransferBillEntity run(TransferRequest request) { 61 String uri = PATH; 62 String reqBody = WXPayUtility.toJson(request); 63 64 Request.Builder reqBuilder = new Request.Builder().url(HOST + uri); 65 reqBuilder.addHeader("Accept", "application/json"); 66 reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId); 67 reqBuilder.addHeader("Authorization", WXPayUtility.buildAuthorization(mchid, certificateSerialNo,privateKey, METHOD, uri, reqBody)); 68 reqBuilder.addHeader("Content-Type", "application/json"); 69 RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), reqBody); 70 reqBuilder.method(METHOD, requestBody); 71 Request httpRequest = reqBuilder.build(); 72 73 // 发送HTTP请求 74 OkHttpClient client = new OkHttpClient.Builder().build(); 75 try (Response httpResponse = client.newCall(httpRequest).execute()) { 76 String respBody = WXPayUtility.extractBody(httpResponse); 77 if (httpResponse.code() >= 200 && httpResponse.code() < 300) { 78 // 2XX 成功,验证应答签名 79 WXPayUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey, 80 httpResponse.headers(), respBody); 81 82 // 从HTTP应答报文构建返回数据 83 return WXPayUtility.fromJson(respBody, MchTransferBillEntity.class); 84 } else { 85 throw new WXPayUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers()); 86 } 87 } catch (IOException e) { 88 throw new UncheckedIOException("Sending request to " + uri + " failed.", e); 89 } 90 } 91 92 private final String mchid; 93 private final String certificateSerialNo; 94 private final PrivateKey privateKey; 95 private final String wechatPayPublicKeyId; 96 private final PublicKey wechatPayPublicKey; 97 98 public InsuranceClaimBillTransfer(String mchid, String certificateSerialNo, String privateKeyFilePath, String wechatPayPublicKeyId, String wechatPayPublicKeyFilePath) { 99 this.mchid = mchid; 100 this.certificateSerialNo = certificateSerialNo; 101 this.privateKey = WXPayUtility.loadPrivateKeyFromPath(privateKeyFilePath); 102 this.wechatPayPublicKeyId = wechatPayPublicKeyId; 103 this.wechatPayPublicKey = WXPayUtility.loadPublicKeyFromPath(wechatPayPublicKeyFilePath); 104 } 105 106 public static class TransferRequest { 107 @SerializedName("sub_mchid") 108 public String subMchid; 109 110 @SerializedName("receiver") 111 public ReceiverEntity receiver; 112 113 @SerializedName("out_bill_no") 114 public String outBillNo; 115 116 @SerializedName("amount") 117 public Long amount; 118 119 @SerializedName("transfer_remark") 120 public String transferRemark; 121 } 122 123 public static class MchTransferBillEntity { 124 @SerializedName("sp_mchid") 125 public String spMchid; 126 127 @SerializedName("sub_mchid") 128 public String subMchid; 129 130 @SerializedName("receiver_detail") 131 public ReceiverDetailInfo receiverDetail; 132 133 @SerializedName("out_bill_no") 134 public String outBillNo; 135 136 @SerializedName("amount") 137 public Long amount; 138 139 @SerializedName("transfer_remark") 140 public String transferRemark; 141 142 @SerializedName("bill_id") 143 public String billId; 144 145 @SerializedName("state") 146 public TransferStatus state; 147 148 @SerializedName("accept_time") 149 public String acceptTime; 150 151 @SerializedName("success_time") 152 public String successTime; 153 154 @SerializedName("sponsor_mchid") 155 public String sponsorMchid; 156 } 157 158 public static class ReceiverEntity { 159 @SerializedName("type") 160 public ReceiverType type; 161 162 @SerializedName("transaction_info") 163 public TransactionInfo transactionInfo; 164 } 165 166 public static class ReceiverDetailInfo { 167 @SerializedName("receiver") 168 public ReceiverEntity receiver; 169 } 170 171 public enum TransferStatus { 172 @SerializedName("ACCEPTED") 173 ACCEPTED, 174 @SerializedName("SUCCESS") 175 SUCCESS, 176 @SerializedName("CLOSED") 177 CLOSED, 178 @SerializedName("WAIT_USER_CONFIRM") 179 WAIT_USER_CONFIRM, 180 @SerializedName("CANCELING") 181 CANCELING, 182 @SerializedName("CANCELLED") 183 CANCELLED 184 } 185 186 public enum ReceiverType { 187 @SerializedName("MERCHANT") 188 MERCHANT, 189 @SerializedName("TRANSACTION_USER") 190 TRANSACTION_USER 191 } 192 193 public static class TransactionInfo { 194 @SerializedName("transaction_id") 195 public String transactionId; 196 197 @SerializedName("type") 198 public TransactionType type; 199 } 200 201 public enum TransactionType { 202 @SerializedName("WXPAY") 203 WXPAY, 204 @SerializedName("WXVALUE") 205 WXVALUE 206 } 207 208} 209
需配合微信支付工具库 wxpay_utility 使用,请参考 Go
1package main 2 3import ( 4 "bytes" 5 "demo/wxpay_utility" // 引用微信支付工具库,参考 https://pay.weixin.qq.com/doc/v3/partner/4015119446 6 "encoding/json" 7 "fmt" 8 "net/http" 9 "net/url" 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 := &TransferRequest{ 28 SubMchid: wxpay_utility.String("1900001109"), 29 Receiver: &ReceiverEntity{ 30 Type: RECEIVERTYPE_MERCHANT.Ptr(), 31 MchInfo: &MerchantInfo{ 32 Mchid: wxpay_utility.String("1900001108"), 33 }, 34 }, 35 OutBillNo: wxpay_utility.String("plfk2020042013"), 36 Amount: wxpay_utility.Int64(10000), 37 TransferRemark: wxpay_utility.String("直播违规扣罚"), 38 } 39 40 response, err := InsuranceClaimBillTransfer(config, request) 41 if err != nil { 42 fmt.Printf("请求失败: %+v\n", err) 43 // TODO: 请求失败,根据状态码执行不同的处理 44 return 45 } 46 47 // TODO: 请求成功,继续业务逻辑 48 fmt.Printf("请求成功: %+v\n", response) 49} 50 51func InsuranceClaimBillTransfer(config *wxpay_utility.MchConfig, request *TransferRequest) (response *MchTransferBillEntity, err error) { 52 const ( 53 host = "https://api.mch.weixin.qq.com" 54 method = "POST" 55 path = "/v3/platsolution/ecommerce/mch-transfer/insurance-claim-bills" 56 ) 57 58 reqUrl, err := url.Parse(fmt.Sprintf("%s%s", host, path)) 59 if err != nil { 60 return nil, err 61 } 62 reqBody, err := json.Marshal(request) 63 if err != nil { 64 return nil, err 65 } 66 httpRequest, err := http.NewRequest(method, reqUrl.String(), bytes.NewReader(reqBody)) 67 if err != nil { 68 return nil, err 69 } 70 httpRequest.Header.Set("Accept", "application/json") 71 httpRequest.Header.Set("Wechatpay-Serial", config.WechatPayPublicKeyId()) 72 httpRequest.Header.Set("Content-Type", "application/json") 73 authorization, err := wxpay_utility.BuildAuthorization(config.MchId(), config.CertificateSerialNo(), config.PrivateKey(), method, reqUrl.RequestURI(), reqBody) 74 if err != nil { 75 return nil, err 76 } 77 httpRequest.Header.Set("Authorization", authorization) 78 79 client := &http.Client{} 80 httpResponse, err := client.Do(httpRequest) 81 if err != nil { 82 return nil, err 83 } 84 85 respBody, err := wxpay_utility.ExtractResponseBody(httpResponse) 86 if err != nil { 87 return nil, err 88 } 89 90 if httpResponse.StatusCode >= 200 && httpResponse.StatusCode < 300 { 91 // 2XX 成功,验证应答签名 92 err = wxpay_utility.ValidateResponse( 93 config.WechatPayPublicKeyId(), 94 config.WechatPayPublicKey(), 95 &httpResponse.Header, 96 respBody, 97 ) 98 if err != nil { 99 return nil, err 100 } 101 102 if err := json.Unmarshal(respBody, response); err != nil { 103 return nil, err 104 } 105 106 return response, nil 107 } else { 108 return nil, wxpay_utility.NewApiException( 109 httpResponse.StatusCode, 110 httpResponse.Header, 111 respBody, 112 ) 113 } 114} 115 116type TransferRequest struct { 117 SubMchid *string `json:"sub_mchid,omitempty"` 118 Receiver *ReceiverEntity `json:"receiver,omitempty"` 119 OutBillNo *string `json:"out_bill_no,omitempty"` 120 Amount *int64 `json:"amount,omitempty"` 121 TransferRemark *string `json:"transfer_remark,omitempty"` 122} 123 124type MchTransferBillEntity struct { 125 SpMchid *string `json:"sp_mchid,omitempty"` 126 SubMchid *string `json:"sub_mchid,omitempty"` 127 ReceiverDetail *ReceiverDetailInfo `json:"receiver_detail,omitempty"` 128 OutBillNo *string `json:"out_bill_no,omitempty"` 129 Amount *int64 `json:"amount,omitempty"` 130 TransferRemark *string `json:"transfer_remark,omitempty"` 131 BillId *string `json:"bill_id,omitempty"` 132 State *TransferStatus `json:"state,omitempty"` 133 AcceptTime *time.Time `json:"accept_time,omitempty"` 134 SuccessTime *time.Time `json:"success_time,omitempty"` 135 SponsorMchid *string `json:"sponsor_mchid,omitempty"` 136} 137 138type ReceiverEntity struct { 139 Type *ReceiverType `json:"type,omitempty"` 140 TransactionInfo *TransactionInfo `json:"transaction_info,omitempty"` 141} 142 143type ReceiverDetailInfo struct { 144 Receiver *ReceiverEntity `json:"receiver,omitempty"` 145} 146 147type TransferStatus string 148 149func (e TransferStatus) Ptr() *TransferStatus { 150 return &e 151} 152 153const ( 154 TRANSFERSTATUS_ACCEPTED TransferStatus = "ACCEPTED" 155 TRANSFERSTATUS_SUCCESS TransferStatus = "SUCCESS" 156 TRANSFERSTATUS_CLOSED TransferStatus = "CLOSED" 157 TRANSFERSTATUS_WAIT_USER_CONFIRM TransferStatus = "WAIT_USER_CONFIRM" 158 TRANSFERSTATUS_CANCELING TransferStatus = "CANCELING" 159 TRANSFERSTATUS_CANCELLED TransferStatus = "CANCELLED" 160) 161 162type ReceiverType string 163 164func (e ReceiverType) Ptr() *ReceiverType { 165 return &e 166} 167 168const ( 169 RECEIVERTYPE_MERCHANT ReceiverType = "MERCHANT" 170 RECEIVERTYPE_TRANSACTION_USER ReceiverType = "TRANSACTION_USER" 171) 172 173type TransactionInfo struct { 174 TransactionId *string `json:"transaction_id,omitempty"` 175 Type *TransactionType `json:"type,omitempty"` 176} 177 178type TransactionType string 179 180func (e TransactionType) Ptr() *TransactionType { 181 return &e 182} 183 184const ( 185 TRANSACTIONTYPE_WXPAY TransactionType = "WXPAY" 186 TRANSACTIONTYPE_WXVALUE TransactionType = "WXVALUE" 187) 188
POST
1curl -X POST \ 2 https://api.mch.weixin.qq.com/v3/platsolution/ecommerce/mch-transfer/insurance-claim-bills \ 3 -H "Authorization: WECHATPAY2-SHA256-RSA2048 mchid=\"1900000001\",..." \ 4 -H "Accept: application/json" \ 5 -H "Content-Type: application/json" \ 6 -d '{ 7 "sub_mchid" : "1900001109", 8 "receiver" : { 9 "type" : "TRANSACTION_USER", 10 "transaction_info" : { 11 "transaction_id" : "1217752501201407033233368018", 12 "type" : "WXPAY" 13 } 14 }, 15 "out_bill_no" : "plfk2020042013", 16 "amount" : 10000, 17 "transfer_remark" : "直播违规扣罚" 18 }' 19
应答参数
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
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 "sponsor_mchid" : "1900001109" 21} 22
错误码
公共错误码
状态码 | 错误码 | 描述 | 解决方案 |
---|---|---|---|
400 | PARAM_ERROR | 参数错误 | 请根据错误提示正确传入参数 |
400 | INVALID_REQUEST | HTTP 请求不符合微信支付 APIv3 接口规则 | 请参阅 接口规则 |
401 | SIGN_ERROR | 验证不通过 | 请参阅 签名常见问题 |
500 | SYSTEM_ERROR | 系统异常,请稍后重试 | 请稍后重试 |