查询不活跃商户身份核实结果
更新时间: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)
【核实单号】 核实单据的唯一标识。
请求示例
需配合微信支付工具库 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
需配合微信支付工具库 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 73 respBody, err := wxpay_utility.ExtractResponseBody(httpResponse) 74 if err != nil { 75 return nil, err 76 } 77 78 if httpResponse.StatusCode >= 200 && httpResponse.StatusCode < 300 { 79 // 2XX 成功,验证应答签名 80 err = wxpay_utility.ValidateResponse( 81 config.WechatPayPublicKeyId(), 82 config.WechatPayPublicKey(), 83 &httpResponse.Header, 84 respBody, 85 ) 86 if err != nil { 87 return nil, err 88 } 89 90 response := &VerificationRecord{} 91 if err := json.Unmarshal(respBody, response); err != nil { 92 return nil, err 93 } 94 95 return response, nil 96 } else { 97 return nil, wxpay_utility.NewApiException( 98 httpResponse.StatusCode, 99 httpResponse.Header, 100 respBody, 101 ) 102 } 103} 104 105type QueryInactiveMerchantIdentityVerificationRequest struct { 106 SubMchid *string `json:"sub_mchid,omitempty"` 107 VerificationId *string `json:"verification_id,omitempty"` 108} 109 110func (o *QueryInactiveMerchantIdentityVerificationRequest) MarshalJSON() ([]byte, error) { 111 type Alias QueryInactiveMerchantIdentityVerificationRequest 112 a := &struct { 113 SubMchid *string `json:"sub_mchid,omitempty"` 114 VerificationId *string `json:"verification_id,omitempty"` 115 *Alias 116 }{ 117 // 序列化时移除非 Body 字段 118 SubMchid: nil, 119 VerificationId: nil, 120 Alias: (*Alias)(o), 121 } 122 return json.Marshal(a) 123} 124 125type VerificationRecord struct { 126 SubMchid *string `json:"sub_mchid,omitempty"` 127 VerificationId *string `json:"verification_id,omitempty"` 128 State *State `json:"state,omitempty"` 129 FailReason *FailReason `json:"fail_reason,omitempty"` 130 CreateTime *string `json:"create_time,omitempty"` 131 FinishTime *string `json:"finish_time,omitempty"` 132} 133 134type State string 135 136func (e State) Ptr() *State { 137 return &e 138} 139 140const ( 141 STATE_PROCESSING State = "PROCESSING" 142 STATE_SUCCESS State = "SUCCESS" 143 STATE_FAIL State = "FAIL" 144) 145 146type FailReason string 147 148func (e FailReason) Ptr() *FailReason { 149 return &e 150} 151 152const ( 153 FAILREASON_MATERIALS_ABNORMAL FailReason = "MATERIALS_ABNORMAL" 154 FAILREASON_PROCESS_TIMEOUT FailReason = "PROCESS_TIMEOUT" 155) 156
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
应答参数
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 | 频率过快,请稍后重试 | 请降低频率后重试 |