查询不活跃商户身份核实结果
更新时间: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)
【核实单号】 核实单据的唯一标识。
请求示例
GET
1curl -X GET \ 2 https://api.mch.weixin.qq.com/v3/compliance/inactive-merchant-identity-verification/merchants/1900000000/verifications/28011678863778000000123124312 \ 3 -H "Authorization: WECHATPAY2-SHA256-RSA2048 mchid=\"1900000001\",..." \ 4 -H "Accept: application/json" 5
需配合微信支付工具库 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 // TODO: 请求成功,继续业务逻辑 46 System.out.println(response); 47 } catch (WXPayUtility.ApiException e) { 48 // TODO: 请求失败,根据状态码执行不同的逻辑 49 e.printStackTrace(); 50 } 51 } 52 53 public VerificationRecord run(QueryInactiveMerchantIdentityVerificationRequest request) { 54 String uri = PATH; 55 uri = uri.replace("{sub_mchid}", WXPayUtility.urlEncode(request.subMchid)); 56 uri = uri.replace("{verification_id}", WXPayUtility.urlEncode(request.verificationId)); 57 58 Request.Builder reqBuilder = new Request.Builder().url(HOST + uri); 59 reqBuilder.addHeader("Accept", "application/json"); 60 reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId); 61 reqBuilder.addHeader("Authorization", WXPayUtility.buildAuthorization(mchid, certificateSerialNo, privateKey, METHOD, uri, null)); 62 reqBuilder.method(METHOD, null); 63 Request httpRequest = reqBuilder.build(); 64 65 // 发送HTTP请求 66 OkHttpClient client = new OkHttpClient.Builder().build(); 67 try (Response httpResponse = client.newCall(httpRequest).execute()) { 68 String respBody = WXPayUtility.extractBody(httpResponse); 69 if (httpResponse.code() >= 200 && httpResponse.code() < 300) { 70 // 2XX 成功,验证应答签名 71 WXPayUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey, 72 httpResponse.headers(), respBody); 73 74 // 从HTTP应答报文构建返回数据 75 return WXPayUtility.fromJson(respBody, VerificationRecord.class); 76 } else { 77 throw new WXPayUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers()); 78 } 79 } catch (IOException e) { 80 throw new UncheckedIOException("Sending request to " + uri + " failed.", e); 81 } 82 } 83 84 private final String mchid; 85 private final String certificateSerialNo; 86 private final PrivateKey privateKey; 87 private final String wechatPayPublicKeyId; 88 private final PublicKey wechatPayPublicKey; 89 90 public QueryInactiveMerchantIdentityVerification(String mchid, String certificateSerialNo, String privateKeyFilePath, String wechatPayPublicKeyId, String wechatPayPublicKeyFilePath) { 91 this.mchid = mchid; 92 this.certificateSerialNo = certificateSerialNo; 93 this.privateKey = WXPayUtility.loadPrivateKeyFromPath(privateKeyFilePath); 94 this.wechatPayPublicKeyId = wechatPayPublicKeyId; 95 this.wechatPayPublicKey = WXPayUtility.loadPublicKeyFromPath(wechatPayPublicKeyFilePath); 96 } 97 98 public static class QueryInactiveMerchantIdentityVerificationRequest { 99 @SerializedName("sub_mchid") 100 @Expose(serialize = false) 101 public String subMchid; 102 103 @SerializedName("verification_id") 104 @Expose(serialize = false) 105 public String verificationId; 106 } 107 108 public static class VerificationRecord { 109 @SerializedName("sub_mchid") 110 public String subMchid; 111 112 @SerializedName("verification_id") 113 public String verificationId; 114 115 @SerializedName("state") 116 public State state; 117 118 @SerializedName("fail_reason") 119 public FailReason failReason; 120 121 @SerializedName("create_time") 122 public String createTime; 123 124 @SerializedName("finish_time") 125 public String finishTime; 126 } 127 128 public enum State { 129 @SerializedName("PROCESSING") 130 PROCESSING, 131 @SerializedName("SUCCESS") 132 SUCCESS, 133 @SerializedName("FAIL") 134 FAIL 135 } 136 137 public enum FailReason { 138 @SerializedName("MATERIALS_ABNORMAL") 139 MATERIALS_ABNORMAL, 140 @SerializedName("PROCESS_TIMEOUT") 141 PROCESS_TIMEOUT 142 } 143 144} 145
需配合微信支付工具库 wxpay_utility 使用,请参考Go
1package main 2 3import ( 4 "demo/wxpay_utility" // 引用微信支付工具库,参考 https://pay.weixin.qq.com/doc/v3/partner/4015119446 5 "encoding/json" 6 "fmt" 7 "net/http" 8 "net/url" 9 "strings" 10) 11 12func main() { 13 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340 14 config, err := wxpay_utility.CreateMchConfig( 15 "19xxxxxxxx", // 商户号,是由微信支付系统生成并分配给每个商户的唯一标识符,商户号获取方式参考 https://pay.weixin.qq.com/doc/v3/partner/4013080340 16 "1DDE55AD98Exxxxxxxxxx", // 商户API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/v3/partner/4013058924 17 "/path/to/apiclient_key.pem", // 商户API证书私钥文件路径,本地文件路径 18 "PUB_KEY_ID_xxxxxxxxxxxxx", // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/v3/partner/4013038589 19 "/path/to/wxp_pub.pem", // 微信支付公钥文件路径,本地文件路径 20 ) 21 if err != nil { 22 fmt.Println(err) 23 return 24 } 25 26 request := &QueryInactiveMerchantIdentityVerificationRequest{ 27 SubMchid: wxpay_utility.String("1900000000"), 28 VerificationId: wxpay_utility.String("28011678863778000000123124312"), 29 } 30 31 response, err := QueryInactiveMerchantIdentityVerification(config, request) 32 if err != nil { 33 fmt.Printf("请求失败: %+v\n", err) 34 // TODO: 请求失败,根据状态码执行不同的处理 35 return 36 } 37 38 // TODO: 请求成功,继续业务逻辑 39 fmt.Printf("请求成功: %+v\n", response) 40} 41 42func QueryInactiveMerchantIdentityVerification(config *wxpay_utility.MchConfig, request *QueryInactiveMerchantIdentityVerificationRequest) (response *VerificationRecord, err error) { 43 const ( 44 host = "https://api.mch.weixin.qq.com" 45 method = "GET" 46 path = "/v3/compliance/inactive-merchant-identity-verification/merchants/{sub_mchid}/verifications/{verification_id}" 47 ) 48 49 reqUrl, err := url.Parse(fmt.Sprintf("%s%s", host, path)) 50 if err != nil { 51 return nil, err 52 } 53 reqUrl.Path = strings.Replace(reqUrl.Path, "{sub_mchid}", url.PathEscape(*request.SubMchid), -1) 54 reqUrl.Path = strings.Replace(reqUrl.Path, "{verification_id}", url.PathEscape(*request.VerificationId), -1) 55 httpRequest, err := http.NewRequest(method, reqUrl.String(), nil) 56 if err != nil { 57 return nil, err 58 } 59 httpRequest.Header.Set("Accept", "application/json") 60 httpRequest.Header.Set("Wechatpay-Serial", config.WechatPayPublicKeyId()) 61 authorization, err := wxpay_utility.BuildAuthorization(config.MchId(), config.CertificateSerialNo(), config.PrivateKey(), method, reqUrl.RequestURI(), nil) 62 if err != nil { 63 return nil, err 64 } 65 httpRequest.Header.Set("Authorization", authorization) 66 67 client := &http.Client{} 68 httpResponse, err := client.Do(httpRequest) 69 if err != nil { 70 return nil, err 71 } 72 respBody, err := wxpay_utility.ExtractResponseBody(httpResponse) 73 if err != nil { 74 return nil, err 75 } 76 if httpResponse.StatusCode >= 200 && httpResponse.StatusCode < 300 { 77 // 2XX 成功,验证应答签名 78 err = wxpay_utility.ValidateResponse( 79 config.WechatPayPublicKeyId(), 80 config.WechatPayPublicKey(), 81 &httpResponse.Header, 82 respBody, 83 ) 84 if err != nil { 85 return nil, err 86 } 87 response := &VerificationRecord{} 88 if err := json.Unmarshal(respBody, response); err != nil { 89 return nil, err 90 } 91 92 return response, nil 93 } else { 94 return nil, wxpay_utility.NewApiException( 95 httpResponse.StatusCode, 96 httpResponse.Header, 97 respBody, 98 ) 99 } 100} 101 102type QueryInactiveMerchantIdentityVerificationRequest struct { 103 SubMchid *string `json:"sub_mchid,omitempty"` 104 VerificationId *string `json:"verification_id,omitempty"` 105} 106 107func (o *QueryInactiveMerchantIdentityVerificationRequest) MarshalJSON() ([]byte, error) { 108 type Alias QueryInactiveMerchantIdentityVerificationRequest 109 a := &struct { 110 SubMchid *string `json:"sub_mchid,omitempty"` 111 VerificationId *string `json:"verification_id,omitempty"` 112 *Alias 113 }{ 114 // 序列化时移除非 Body 字段 115 SubMchid: nil, 116 VerificationId: nil, 117 Alias: (*Alias)(o), 118 } 119 return json.Marshal(a) 120} 121 122type VerificationRecord struct { 123 SubMchid *string `json:"sub_mchid,omitempty"` 124 VerificationId *string `json:"verification_id,omitempty"` 125 State *State `json:"state,omitempty"` 126 FailReason *FailReason `json:"fail_reason,omitempty"` 127 CreateTime *string `json:"create_time,omitempty"` 128 FinishTime *string `json:"finish_time,omitempty"` 129} 130 131type State string 132 133func (e State) Ptr() *State { 134 return &e 135} 136 137const ( 138 STATE_PROCESSING State = "PROCESSING" 139 STATE_SUCCESS State = "SUCCESS" 140 STATE_FAIL State = "FAIL" 141) 142 143type FailReason string 144 145func (e FailReason) Ptr() *FailReason { 146 return &e 147} 148 149const ( 150 FAILREASON_MATERIALS_ABNORMAL FailReason = "MATERIALS_ABNORMAL" 151 FAILREASON_PROCESS_TIMEOUT FailReason = "PROCESS_TIMEOUT" 152) 153
应答参数
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 | 频率过快,请稍后重试 | 请降低频率后重试 |