查询结算账户修改申请状态
更新时间:2025.01.21服务商/电商平台(不包括支付机构、银行),可使用本接口,查询其进件且已签约特约商户/二级商户的结算账户的修改申请单信息和审核结果。
|
接口说明
支持商户:【普通服务商】 【平台商户】
请求方式:【GET】/v3/apply4sub/sub_merchants/{sub_mchid}/application/{application_no}
请求域名:【主域名】https://api.mch.weixin.qq.com 使用该域名将访问就近的接入点
【备域名】https://api2.mch.weixin.qq.com 使用该域名将访问异地的接入点 ,指引点击查看
请求参数
Header HTTP头参数
Authorization 必填 string
请参考签名认证生成认证信息
Accept 必填 string
请设置为application/json
path 路径参数
sub_mchid 必填 string(10)
【特约商户/二级商户号】 请填写本服务商负责进件的特约商户/二级商户号。
application_no 必填 string(64)
【修改结算账户申请单号】 提交二级商户修改结算账户申请后,由微信支付返回的单号,作为查询申请状态的唯一标识。
query 查询参数
account_number_rule 选填 string
【银行账号展示规则】 请输入预期的银行账号展示规则,默认为ACCOUNT_NUMBER_RULE_MASK_V1
可选取值
ACCOUNT_NUMBER_RULE_MASK_V1: 银行账号展示规则掩码v1,保留前2位和最后2位,中间用*代替ACCOUNT_NUMBER_RULE_MASK_V2: 银行账号展示规则掩码v2,保留前6位和最后4位,中间用*代替
请求示例
GET
1curl -X GET \ 2 https://api.mch.weixin.qq.com/v3/apply4sub/sub_merchants/1511101111/application/102329389XXXX?account_number_rule=ACCOUNT_NUMBER_RULE_MASK_V1 \ 3 -H "Authorization: WECHATPAY2-SHA256-RSA2048 mchid=\"1900000001\",..." \ 4 -H "Accept: application/json"
需配合微信支付工具库 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 GetApplication { 26 private static String HOST = "https://api.mch.weixin.qq.com"; 27 private static String METHOD = "GET"; 28 private static String PATH = "/v3/apply4sub/sub_merchants/{sub_mchid}/application/{application_no}"; 29 30 public static void main(String[] args) { 31 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340 32 GetApplication client = new GetApplication( 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 GetApplicationRequest request = new GetApplicationRequest(); 41 request.subMchid = "1511101111"; 42 request.applicationNo = "102329389XXXX"; 43 request.accountNumberRule = AccountNumberRule.ACCOUNT_NUMBER_RULE_MASK_V1; 44 try { 45 SubMerchantsGetApplicationResponse response = client.run(request); 46 // TODO: 请求成功,继续业务逻辑 47 System.out.println(response); 48 } catch (WXPayUtility.ApiException e) { 49 // TODO: 请求失败,根据状态码执行不同的逻辑 50 e.printStackTrace(); 51 } 52 } 53 54 public SubMerchantsGetApplicationResponse run(GetApplicationRequest request) { 55 String uri = PATH; 56 uri = uri.replace("{sub_mchid}", WXPayUtility.urlEncode(request.subMchid)); 57 uri = uri.replace("{application_no}", WXPayUtility.urlEncode(request.applicationNo)); 58 Map<String, Object> args = new HashMap<>(); 59 args.put("account_number_rule", request.accountNumberRule); 60 String queryString = WXPayUtility.urlEncode(args); 61 if (!queryString.isEmpty()) { 62 uri = uri + "?" + queryString; 63 } 64 65 Request.Builder reqBuilder = new Request.Builder().url(HOST + uri); 66 reqBuilder.addHeader("Accept", "application/json"); 67 reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId); 68 reqBuilder.addHeader("Authorization", WXPayUtility.buildAuthorization(mchid, certificateSerialNo, privateKey, METHOD, uri, null)); 69 reqBuilder.method(METHOD, null); 70 Request httpRequest = reqBuilder.build(); 71 72 // 发送HTTP请求 73 OkHttpClient client = new OkHttpClient.Builder().build(); 74 try (Response httpResponse = client.newCall(httpRequest).execute()) { 75 String respBody = WXPayUtility.extractBody(httpResponse); 76 if (httpResponse.code() >= 200 && httpResponse.code() < 300) { 77 // 2XX 成功,验证应答签名 78 WXPayUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey, 79 httpResponse.headers(), respBody); 80 81 // 从HTTP应答报文构建返回数据 82 return WXPayUtility.fromJson(respBody, SubMerchantsGetApplicationResponse.class); 83 } else { 84 throw new WXPayUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers()); 85 } 86 } catch (IOException e) { 87 throw new UncheckedIOException("Sending request to " + uri + " failed.", e); 88 } 89 } 90 91 private final String mchid; 92 private final String certificateSerialNo; 93 private final PrivateKey privateKey; 94 private final String wechatPayPublicKeyId; 95 private final PublicKey wechatPayPublicKey; 96 97 public GetApplication(String mchid, String certificateSerialNo, String privateKeyFilePath, String wechatPayPublicKeyId, String wechatPayPublicKeyFilePath) { 98 this.mchid = mchid; 99 this.certificateSerialNo = certificateSerialNo; 100 this.privateKey = WXPayUtility.loadPrivateKeyFromPath(privateKeyFilePath); 101 this.wechatPayPublicKeyId = wechatPayPublicKeyId; 102 this.wechatPayPublicKey = WXPayUtility.loadPublicKeyFromPath(wechatPayPublicKeyFilePath); 103 } 104 105 public static class GetApplicationRequest { 106 @SerializedName("sub_mchid") 107 @Expose(serialize = false) 108 public String subMchid; 109 110 @SerializedName("application_no") 111 @Expose(serialize = false) 112 public String applicationNo; 113 114 @SerializedName("account_number_rule") 115 @Expose(serialize = false) 116 public AccountNumberRule accountNumberRule; 117 } 118 119 public static class SubMerchantsGetApplicationResponse { 120 @SerializedName("account_name") 121 public String accountName; 122 123 @SerializedName("account_type") 124 public BankAccountType accountType; 125 126 @SerializedName("account_bank") 127 public String accountBank; 128 129 @SerializedName("bank_name") 130 public String bankName; 131 132 @SerializedName("bank_branch_id") 133 public String bankBranchId; 134 135 @SerializedName("account_number") 136 public String accountNumber; 137 138 @SerializedName("verify_result") 139 public AuditResult verifyResult; 140 141 @SerializedName("verify_fail_reason") 142 public String verifyFailReason; 143 144 @SerializedName("verify_finish_time") 145 public String verifyFinishTime; 146 } 147 148 public enum AccountNumberRule { 149 @SerializedName("ACCOUNT_NUMBER_RULE_MASK_V1") 150 ACCOUNT_NUMBER_RULE_MASK_V1, 151 @SerializedName("ACCOUNT_NUMBER_RULE_MASK_V2") 152 ACCOUNT_NUMBER_RULE_MASK_V2 153 } 154 155 public enum BankAccountType { 156 @SerializedName("ACCOUNT_TYPE_BUSINESS") 157 ACCOUNT_TYPE_BUSINESS, 158 @SerializedName("ACCOUNT_TYPE_PRIVATE") 159 ACCOUNT_TYPE_PRIVATE 160 } 161 162 public enum AuditResult { 163 @SerializedName("AUDIT_SUCCESS") 164 AUDIT_SUCCESS, 165 @SerializedName("AUDITING") 166 AUDITING, 167 @SerializedName("AUDIT_FAIL") 168 AUDIT_FAIL 169 } 170 171}
需配合微信支付工具库 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 := &GetApplicationRequest{ 27 SubMchid: wxpay_utility.String("1511101111"), 28 ApplicationNo: wxpay_utility.String("102329389XXXX"), 29 AccountNumberRule: ACCOUNTNUMBERRULE_ACCOUNT_NUMBER_RULE_MASK_V1.Ptr(), 30 } 31 32 response, err := GetApplication(config, request) 33 if err != nil { 34 fmt.Printf("请求失败: %+v\n", err) 35 // TODO: 请求失败,根据状态码执行不同的处理 36 return 37 } 38 39 // TODO: 请求成功,继续业务逻辑 40 fmt.Printf("请求成功: %+v\n", response) 41} 42 43func GetApplication(config *wxpay_utility.MchConfig, request *GetApplicationRequest) (response *SubMerchantsGetApplicationResponse, err error) { 44 const ( 45 host = "https://api.mch.weixin.qq.com" 46 method = "GET" 47 path = "/v3/apply4sub/sub_merchants/{sub_mchid}/application/{application_no}" 48 ) 49 50 reqUrl, err := url.Parse(fmt.Sprintf("%s%s", host, path)) 51 if err != nil { 52 return nil, err 53 } 54 reqUrl.Path = strings.Replace(reqUrl.Path, "{sub_mchid}", url.PathEscape(*request.SubMchid), -1) 55 reqUrl.Path = strings.Replace(reqUrl.Path, "{application_no}", url.PathEscape(*request.ApplicationNo), -1) 56 query := reqUrl.Query() 57 if request.AccountNumberRule != nil { 58 query.Add("account_number_rule", fmt.Sprintf("%v", *request.AccountNumberRule)) 59 } 60 reqUrl.RawQuery = query.Encode() 61 httpRequest, err := http.NewRequest(method, reqUrl.String(), nil) 62 if err != nil { 63 return nil, err 64 } 65 httpRequest.Header.Set("Accept", "application/json") 66 httpRequest.Header.Set("Wechatpay-Serial", config.WechatPayPublicKeyId()) 67 authorization, err := wxpay_utility.BuildAuthorization(config.MchId(), config.CertificateSerialNo(), config.PrivateKey(), method, reqUrl.RequestURI(), nil) 68 if err != nil { 69 return nil, err 70 } 71 httpRequest.Header.Set("Authorization", authorization) 72 73 client := &http.Client{} 74 httpResponse, err := client.Do(httpRequest) 75 if err != nil { 76 return nil, err 77 } 78 respBody, err := wxpay_utility.ExtractResponseBody(httpResponse) 79 if err != nil { 80 return nil, err 81 } 82 if httpResponse.StatusCode >= 200 && httpResponse.StatusCode < 300 { 83 // 2XX 成功,验证应答签名 84 err = wxpay_utility.ValidateResponse( 85 config.WechatPayPublicKeyId(), 86 config.WechatPayPublicKey(), 87 &httpResponse.Header, 88 respBody, 89 ) 90 if err != nil { 91 return nil, err 92 } 93 response := &SubMerchantsGetApplicationResponse{} 94 if err := json.Unmarshal(respBody, response); err != nil { 95 return nil, err 96 } 97 98 return response, nil 99 } else { 100 return nil, wxpay_utility.NewApiException( 101 httpResponse.StatusCode, 102 httpResponse.Header, 103 respBody, 104 ) 105 } 106} 107 108type GetApplicationRequest struct { 109 SubMchid *string `json:"sub_mchid,omitempty"` 110 ApplicationNo *string `json:"application_no,omitempty"` 111 AccountNumberRule *AccountNumberRule `json:"account_number_rule,omitempty"` 112} 113 114func (o *GetApplicationRequest) MarshalJSON() ([]byte, error) { 115 type Alias GetApplicationRequest 116 a := &struct { 117 SubMchid *string `json:"sub_mchid,omitempty"` 118 ApplicationNo *string `json:"application_no,omitempty"` 119 AccountNumberRule *AccountNumberRule `json:"account_number_rule,omitempty"` 120 *Alias 121 }{ 122 // 序列化时移除非 Body 字段 123 SubMchid: nil, 124 ApplicationNo: nil, 125 AccountNumberRule: nil, 126 Alias: (*Alias)(o), 127 } 128 return json.Marshal(a) 129} 130 131type SubMerchantsGetApplicationResponse struct { 132 AccountName *string `json:"account_name,omitempty"` 133 AccountType *BankAccountType `json:"account_type,omitempty"` 134 AccountBank *string `json:"account_bank,omitempty"` 135 BankName *string `json:"bank_name,omitempty"` 136 BankBranchId *string `json:"bank_branch_id,omitempty"` 137 AccountNumber *string `json:"account_number,omitempty"` 138 VerifyResult *AuditResult `json:"verify_result,omitempty"` 139 VerifyFailReason *string `json:"verify_fail_reason,omitempty"` 140 VerifyFinishTime *string `json:"verify_finish_time,omitempty"` 141} 142 143type AccountNumberRule string 144 145func (e AccountNumberRule) Ptr() *AccountNumberRule { 146 return &e 147} 148 149const ( 150 ACCOUNTNUMBERRULE_ACCOUNT_NUMBER_RULE_MASK_V1 AccountNumberRule = "ACCOUNT_NUMBER_RULE_MASK_V1" 151 ACCOUNTNUMBERRULE_ACCOUNT_NUMBER_RULE_MASK_V2 AccountNumberRule = "ACCOUNT_NUMBER_RULE_MASK_V2" 152) 153 154type BankAccountType string 155 156func (e BankAccountType) Ptr() *BankAccountType { 157 return &e 158} 159 160const ( 161 BANKACCOUNTTYPE_ACCOUNT_TYPE_BUSINESS BankAccountType = "ACCOUNT_TYPE_BUSINESS" 162 BANKACCOUNTTYPE_ACCOUNT_TYPE_PRIVATE BankAccountType = "ACCOUNT_TYPE_PRIVATE" 163) 164 165type AuditResult string 166 167func (e AuditResult) Ptr() *AuditResult { 168 return &e 169} 170 171const ( 172 AUDITRESULT_AUDIT_SUCCESS AuditResult = "AUDIT_SUCCESS" 173 AUDITRESULT_AUDITING AuditResult = "AUDITING" 174 AUDITRESULT_AUDIT_FAIL AuditResult = "AUDIT_FAIL" 175)
应答参数
200 OK
account_name 必填 string(1024)
【开户名称】 特约商户的结算账户-开户名称,掩码显示。
account_type 必填 string
【账户类型】 特约商户的结算账户类型。
可选取值
ACCOUNT_TYPE_BUSINESS: 对公银行账户ACCOUNT_TYPE_PRIVATE: 经营者个人银行卡
account_bank 必填 string(128)
【开户银行】 特约商户的结算账户-开户银行全称。
bank_name 选填 string(128)
【开户银行全称(含支行)】 特约商户的结算账户-开户银行全称(含支行)。
bank_branch_id 选填 string(128)
【开户银行联行号】 特约商户的结算账户-联行号。
account_number 必填 string(128)
【银行账号】 特约商户的结算账户-银行账号,根据account_number_rule指定规则展示。
verify_result 必填 string
【审核状态】 审核状态
可选取值
AUDIT_SUCCESS: 审核成功AUDITING: 审核中AUDIT_FAIL: 审核驳回
verify_fail_reason 选填 string
【审核驳回原因】 审核驳回原因。审核成功时为空,审核驳回时为具体原因。
verify_finish_time 选填 string
【审核结果更新时间】 遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35+08:00表示,北京时间2015年5月20日13点29分35秒。
应答示例
200 OK
1{ 2 "account_name" : "张*", 3 "account_type" : "ACCOUNT_TYPE_BUSINESS", 4 "account_bank" : "工商银行", 5 "bank_name" : "施秉县农村信用合作联社城关信用社", 6 "bank_branch_id" : "402713354941", 7 "account_number" : "62*************78", 8 "verify_result" : "AUDIT_SUCCESS", 9 "verify_fail_reason" : "银行卡户名或卡号有误", 10 "verify_finish_time" : "2015-05-20T13:29:35+08:00" 11} 12
错误码
公共错误码
状态码 | 错误码 | 描述 | 解决方案 |
|---|---|---|---|
400 | PARAM_ERROR | 参数错误 | 请根据错误提示正确传入参数 |
400 | INVALID_REQUEST | HTTP 请求不符合微信支付 APIv3 接口规则 | 请参阅 接口规则 |
401 | SIGN_ERROR | 验证不通过 | 请参阅 签名常见问题 |
500 | SYSTEM_ERROR | 系统异常,请稍后重试 | 请稍后重试 |
业务错误码
状态码 | 错误码 | 描述 | 解决方案 |
|---|---|---|---|
403 | NO_AUTH | 商户权限异常 | 该商户不是本服务商进件的子商户,无权限操作 |
404 | ORDER_NOT_EXIST | 查询的申请单不存在 | 查询的申请单不存在 |
500 | SYSTEM_ERROR | 系统失败 | 请使用相同参数稍后重新调用 |

