查询不活跃商户身份核实结果

更新时间:2025.08.08

在代特约商户发起不活跃商户身份核实后,服务商可以通过该接口,查询特定特约商户下单笔核实单的核实结果。

接口说明

支持商户:【平台商户】

请求方式:【GET】/v3/compliance/inactive-merchant-identity-verification/merchants/{sub_mchid}/verifications/{verification_id}

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

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

请求参数

Header  HTTP头参数

 Authorization  必填 string

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


 Accept  必填 string

请设置为application/json


path  路径参数

 sub_mchid  必填   string(32)

【特约商户号】 微信支付分配给特约商户的唯一标识。


 verification_id  必填   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 QueryInactiveMerchantIdentityVerification {
26  private static String HOST = "https://api.mch.weixin.qq.com";
27  private static String METHOD = "GET";
28  private static String PATH = "/v3/compliance/inactive-merchant-identity-verification/merchants/{sub_mchid}/verifications/{verification_id}";
29
30  public static void main(String[] args) {
31    // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340
32    QueryInactiveMerchantIdentityVerification client = new QueryInactiveMerchantIdentityVerification(
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    QueryInactiveMerchantIdentityVerificationRequest request = new QueryInactiveMerchantIdentityVerificationRequest();
41    request.subMchid = "1900000000";
42    request.verificationId = "28011678863778000000123124312";
43    try {
44      VerificationRecord 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 VerificationRecord run(QueryInactiveMerchantIdentityVerificationRequest request) {
55    String uri = PATH;
56    uri = uri.replace("{sub_mchid}", WXPayUtility.urlEncode(request.subMchid));
57    uri = uri.replace("{verification_id}", WXPayUtility.urlEncode(request.verificationId));
58
59    Request.Builder reqBuilder = new Request.Builder().url(HOST + uri);
60    reqBuilder.addHeader("Accept", "application/json");
61    reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId);
62    reqBuilder.addHeader("Authorization", WXPayUtility.buildAuthorization(mchid, certificateSerialNo, privateKey, METHOD, uri, null));
63    reqBuilder.method(METHOD, null);
64    Request httpRequest = reqBuilder.build();
65
66    // 发送HTTP请求
67    OkHttpClient client = new OkHttpClient.Builder().build();
68    try (Response httpResponse = client.newCall(httpRequest).execute()) {
69      String respBody = WXPayUtility.extractBody(httpResponse);
70      if (httpResponse.code() >= 200 && httpResponse.code() < 300) {
71        // 2XX 成功,验证应答签名
72        WXPayUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey,
73            httpResponse.headers(), respBody);
74
75        // 从HTTP应答报文构建返回数据
76        return WXPayUtility.fromJson(respBody, VerificationRecord.class);
77      } else {
78        throw new WXPayUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers());
79      }
80    } catch (IOException e) {
81      throw new UncheckedIOException("Sending request to " + uri + " failed.", e);
82    }
83  }
84
85  private final String mchid;
86  private final String certificateSerialNo;
87  private final PrivateKey privateKey;
88  private final String wechatPayPublicKeyId;
89  private final PublicKey wechatPayPublicKey;
90
91  public QueryInactiveMerchantIdentityVerification(String mchid, String certificateSerialNo, String privateKeyFilePath, String wechatPayPublicKeyId, String wechatPayPublicKeyFilePath) {
92    this.mchid = mchid;
93    this.certificateSerialNo = certificateSerialNo;
94    this.privateKey = WXPayUtility.loadPrivateKeyFromPath(privateKeyFilePath);
95    this.wechatPayPublicKeyId = wechatPayPublicKeyId;
96    this.wechatPayPublicKey = WXPayUtility.loadPublicKeyFromPath(wechatPayPublicKeyFilePath);
97  }
98
99  public static class QueryInactiveMerchantIdentityVerificationRequest {
100    @SerializedName("sub_mchid")
101    @Expose(serialize = false)
102    public String subMchid;
103  
104    @SerializedName("verification_id")
105    @Expose(serialize = false)
106    public String verificationId;
107  }
108  
109  public static class VerificationRecord {
110    @SerializedName("sub_mchid")
111    public String subMchid;
112  
113    @SerializedName("verification_id")
114    public String verificationId;
115  
116    @SerializedName("state")
117    public State state;
118  
119    @SerializedName("fail_reason")
120    public FailReason failReason;
121  
122    @SerializedName("create_time")
123    public String createTime;
124  
125    @SerializedName("finish_time")
126    public String finishTime;
127  }
128  
129  public enum State {
130    @SerializedName("PROCESSING")
131    PROCESSING,
132    @SerializedName("SUCCESS")
133    SUCCESS,
134    @SerializedName("FAIL")
135    FAIL
136  }
137  
138  public enum FailReason {
139    @SerializedName("MATERIALS_ABNORMAL")
140    MATERIALS_ABNORMAL,
141    @SerializedName("PROCESS_TIMEOUT")
142    PROCESS_TIMEOUT
143  }
144  
145}
146

应答参数

200 OK

 sub_mchid  必填   string(32)

【特约商户号】 微信支付分配给特约商户的唯一标识。


 verification_id  必填   string(32)

【核实单号】 核实单据的唯一标识。


 state  必填   string

【核实单状态】 核实单状态。

可选取值

  • PROCESSING:  核实中

  • SUCCESS:  核实成功

  • FAIL:  核实失败


 fail_reason  选填   string

【失败原因】 核实单失败原因,当核实单状态为核实失败时返回。

可选取值

  • MATERIALS_ABNORMAL:  资料异常,核实失败

  • PROCESS_TIMEOUT:  单据处理超时,请重新发起核实


 create_time  必填   string(32)

【创建时间】 核实单创建时间。遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC8小时,即北京时间)。例如:2015-05-20T13:29:35+08:00表示,北京时间2015年5月20日 13点29分35秒。


 finish_time  选填   string(32)

【完成时间】 核实完成时间,在核实成功或核实失败后返回。遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC8小时,即北京时间)。例如:2015-05-20T13:29:35+08:00表示,北京时间2015年5月20日 13点29分35秒。

应答示例

200 OK

1{
2  "sub_mchid" : "1900000000",
3  "verification_id" : "28011678863778000000123124312",
4  "state" : "SUCCESS",
5  "fail_reason" : "MATERIALS_ABNORMAL",
6  "create_time" : "2020-01-01T00:00:00+08:00",
7  "finish_time" : "2020-01-01T00:00:00+08:00"
8}
9

 

错误码

公共错误码

状态码

错误码

描述

解决方案

400

PARAM_ERROR

参数错误

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

400

INVALID_REQUEST

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

请参阅 接口规则

401

SIGN_ERROR

验证不通过

请参阅 签名常见问题

500

SYSTEM_ERROR

系统异常,请稍后重试

请稍后重试

业务错误码

状态码

错误码

描述

解决方案

400

INVALID_REQUEST

请输入正确的子商户号

请确认输入的子商户号的业务归属

403

NO_AUTH

你暂无权限访问此接口

请确认调用方的商户类型

403

NO_AUTH

你暂无权限对该商户执行操作

请检查输入的子商户号是否有误

403

NO_AUTH

你暂无权限访问此单据

请检查输入的单据号是否有误

404

NOT_FOUND

查询不到此单据

请检查输入的单据号是否有误

429

FREQUENCY_LIMIT_EXCEED

频率过快,请稍后重试

请降低频率后重试

 

 

反馈
咨询
目录
置顶