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

更新时间:2025.07.25

商户单号查询赔付记录。

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

接口说明

支持商户:【平台商户】

请求方式:【GET】/v3/platsolution/ecommerce/mch-transfer/compensate-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)

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

请求示例

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 CompensationBillGetByOutNo {
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/compensate-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    CompensationBillGetByOutNo client = new CompensationBillGetByOutNo(
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    CompensationBillGetByOutNoRequest request = new CompensationBillGetByOutNoRequest();
41    request.outBillNo = "plfk2020042013";
42    try {
43      MchTransferBillEntity response = client.run(request);
44
45      // TODO: 请求成功,继续业务逻辑
46      System.out.println(response);
47    } catch (WXPayUtility.ApiException e) {
48      // TODO: 请求失败,根据状态码执行不同的逻辑
49      e.printStackTrace();
50    }
51  }
52
53  public MchTransferBillEntity run(CompensationBillGetByOutNoRequest request) {
54    String uri = PATH;
55    uri = uri.replace("{out_bill_no}", WXPayUtility.urlEncode(request.outBillNo));
56
57    Request.Builder reqBuilder = new Request.Builder().url(HOST + uri);
58    reqBuilder.addHeader("Accept", "application/json");
59    reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId);
60    reqBuilder.addHeader("Authorization", WXPayUtility.buildAuthorization(mchid, certificateSerialNo, privateKey, METHOD, uri, null));
61    reqBuilder.method(METHOD, null);
62    Request httpRequest = reqBuilder.build();
63
64    // 发送HTTP请求
65    OkHttpClient client = new OkHttpClient.Builder().build();
66    try (Response httpResponse = client.newCall(httpRequest).execute()) {
67      String respBody = WXPayUtility.extractBody(httpResponse);
68      if (httpResponse.code() >= 200 && httpResponse.code() < 300) {
69        // 2XX 成功,验证应答签名
70        WXPayUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey,
71            httpResponse.headers(), respBody);
72
73        // 从HTTP应答报文构建返回数据
74        return WXPayUtility.fromJson(respBody, MchTransferBillEntity.class);
75      } else {
76        throw new WXPayUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers());
77      }
78    } catch (IOException e) {
79      throw new UncheckedIOException("Sending request to " + uri + " failed.", e);
80    }
81  }
82
83  private final String mchid;
84  private final String certificateSerialNo;
85  private final PrivateKey privateKey;
86  private final String wechatPayPublicKeyId;
87  private final PublicKey wechatPayPublicKey;
88
89  public CompensationBillGetByOutNo(String mchid, String certificateSerialNo, String privateKeyFilePath, String wechatPayPublicKeyId, String wechatPayPublicKeyFilePath) {
90    this.mchid = mchid;
91    this.certificateSerialNo = certificateSerialNo;
92    this.privateKey = WXPayUtility.loadPrivateKeyFromPath(privateKeyFilePath);
93    this.wechatPayPublicKeyId = wechatPayPublicKeyId;
94    this.wechatPayPublicKey = WXPayUtility.loadPublicKeyFromPath(wechatPayPublicKeyFilePath);
95  }
96
97  public static class CompensationBillGetByOutNoRequest {
98    @SerializedName("out_bill_no")
99    @Expose(serialize = false)
100    public String outBillNo;
101  
102    @SerializedName("business_type")
103    @Expose(serialize = false)
104    public BusinsssType businessType;
105  }
106  
107  public static class MchTransferBillEntity {
108    @SerializedName("sp_mchid")
109    public String spMchid;
110  
111    @SerializedName("receiver_detail")
112    public ReceiverDetailInfo receiverDetail;
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("bill_id")
124    public String billId;
125  
126    @SerializedName("state")
127    public TransferStatus state;
128  
129    @SerializedName("accept_time")
130    public String acceptTime;
131  
132    @SerializedName("success_time")
133    public String successTime;
134  
135    @SerializedName("close_info")
136    public TransferCloseInfo closeInfo;
137  
138    @SerializedName("sponsor_mchid")
139    public String sponsorMchid;
140  }
141  
142  public enum BusinsssType {
143    @SerializedName("DEPOSIT_COMPENSATION")
144    DEPOSIT_COMPENSATION,
145    @SerializedName("PLATFORM_AFTER_SALES_COMPENSATION")
146    PLATFORM_AFTER_SALES_COMPENSATION,
147    @SerializedName("INSURANCE_CLAIM")
148    INSURANCE_CLAIM,
149    @SerializedName("DEPOSIT_AFTER_SALES_COMPENSATION")
150    DEPOSIT_AFTER_SALES_COMPENSATION
151  }
152  
153  public static class ReceiverDetailInfo {
154    @SerializedName("receiver")
155    public ReceiverEntity receiver;
156  }
157  
158  public enum TransferStatus {
159    @SerializedName("ACCEPTED")
160    ACCEPTED,
161    @SerializedName("SUCCESS")
162    SUCCESS,
163    @SerializedName("CLOSED")
164    CLOSED,
165    @SerializedName("WAIT_USER_CONFIRM")
166    WAIT_USER_CONFIRM,
167    @SerializedName("CANCELING")
168    CANCELING,
169    @SerializedName("CANCELLED")
170    CANCELLED
171  }
172  
173  public static class TransferCloseInfo {
174    @SerializedName("close_time")
175    public String closeTime;
176  
177    @SerializedName("close_reason")
178    public String closeReason;
179  }
180  
181  public static class ReceiverEntity {
182    @SerializedName("type")
183    public ReceiverType type;
184  
185    @SerializedName("transaction_info")
186    public TransactionInfo transactionInfo;
187  }
188  
189  public enum ReceiverType {
190    @SerializedName("TRANSACTION_USER")
191    TRANSACTION_USER
192  }
193  
194  public static class TransactionInfo {
195    @SerializedName("transaction_id")
196    public String transactionId;
197  
198    @SerializedName("type")
199    public TransactionType type;
200  }
201  
202  public enum TransactionType {
203    @SerializedName("WXPAY")
204    WXPAY,
205    @SerializedName("WXVALUE")
206    WXVALUE
207  }
208  
209}
210

应答参数

200 OK

 sp_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  "receiver_detail" : {
4    "receiver" : {
5      "type" : "TRANSACTION_USER",
6      "transaction_info" : {
7        "transaction_id" : "1217752501201407033233368018",
8        "type" : "WXPAY"
9      }
10    }
11  },
12  "out_bill_no" : "plfk2020042013",
13  "amount" : 10000,
14  "transfer_remark" : "直播违规扣罚",
15  "bill_id" : "1330000071100999991182020050700019480001",
16  "state" : "SUCCESS",
17  "accept_time" : "2015-05-20T13:29:35+08:00",
18  "success_time" : "2015-05-20T13:29:35+08:00",
19  "close_info" : {
20    "close_time" : "2015-05-20T13:29:35+08:00",
21    "close_reason" : "NOT_ENOUGH"
22  },
23  "sponsor_mchid" : "1900001109"
24}
25

 

错误码

公共错误码

状态码

错误码

描述

解决方案

400

PARAM_ERROR

参数错误

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

400

INVALID_REQUEST

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

请参阅 接口规则

401

SIGN_ERROR

验证不通过

请参阅 签名常见问题

500

SYSTEM_ERROR

系统异常,请稍后重试

请稍后重试

 

 

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