查询结算账户修改申请状态
更新时间: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)
【修改结算账户申请单号】 提交二级商户修改结算账户申请后,由微信支付返回的单号,作为查询申请状态的唯一标识。
请求示例
GET
1curl -X GET \ 2 https://api.mch.weixin.qq.com/v3/apply4sub/sub_merchants/1511101111/application/102329389XXXX \ 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 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 try { 44 SubMerchantsGetApplicationResponse 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 SubMerchantsGetApplicationResponse run(GetApplicationRequest request) { 54 String uri = PATH; 55 uri = uri.replace("{sub_mchid}", WXPayUtility.urlEncode(request.subMchid)); 56 uri = uri.replace("{application_no}", WXPayUtility.urlEncode(request.applicationNo)); 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, SubMerchantsGetApplicationResponse.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 GetApplication(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 GetApplicationRequest { 99 @SerializedName("sub_mchid") 100 @Expose(serialize = false) 101 public String subMchid; 102 103 @SerializedName("application_no") 104 @Expose(serialize = false) 105 public String applicationNo; 106 } 107 108 public static class SubMerchantsGetApplicationResponse { 109 @SerializedName("account_name") 110 public String accountName; 111 112 @SerializedName("account_type") 113 public BankAccountType accountType; 114 115 @SerializedName("account_bank") 116 public String accountBank; 117 118 @SerializedName("bank_name") 119 public String bankName; 120 121 @SerializedName("bank_branch_id") 122 public String bankBranchId; 123 124 @SerializedName("account_number") 125 public String accountNumber; 126 127 @SerializedName("verify_result") 128 public AuditResult verifyResult; 129 130 @SerializedName("verify_fail_reason") 131 public String verifyFailReason; 132 133 @SerializedName("verify_finish_time") 134 public String verifyFinishTime; 135 } 136 137 public enum BankAccountType { 138 @SerializedName("ACCOUNT_TYPE_BUSINESS") 139 ACCOUNT_TYPE_BUSINESS, 140 @SerializedName("ACCOUNT_TYPE_PRIVATE") 141 ACCOUNT_TYPE_PRIVATE 142 } 143 144 public enum AuditResult { 145 @SerializedName("AUDIT_SUCCESS") 146 AUDIT_SUCCESS, 147 @SerializedName("AUDITING") 148 AUDITING, 149 @SerializedName("AUDIT_FAIL") 150 AUDIT_FAIL 151 } 152 153} 154
需配合微信支付工具库 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 } 30 31 response, err := GetApplication(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 GetApplication(config *wxpay_utility.MchConfig, request *GetApplicationRequest) (response *SubMerchantsGetApplicationResponse, err error) { 43 const ( 44 host = "https://api.mch.weixin.qq.com" 45 method = "GET" 46 path = "/v3/apply4sub/sub_merchants/{sub_mchid}/application/{application_no}" 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, "{application_no}", url.PathEscape(*request.ApplicationNo), -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 := &SubMerchantsGetApplicationResponse{} 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 GetApplicationRequest struct { 103 SubMchid *string `json:"sub_mchid,omitempty"` 104 ApplicationNo *string `json:"application_no,omitempty"` 105} 106 107func (o *GetApplicationRequest) MarshalJSON() ([]byte, error) { 108 type Alias GetApplicationRequest 109 a := &struct { 110 SubMchid *string `json:"sub_mchid,omitempty"` 111 ApplicationNo *string `json:"application_no,omitempty"` 112 *Alias 113 }{ 114 // 序列化时移除非 Body 字段 115 SubMchid: nil, 116 ApplicationNo: nil, 117 Alias: (*Alias)(o), 118 } 119 return json.Marshal(a) 120} 121 122type SubMerchantsGetApplicationResponse struct { 123 AccountName *string `json:"account_name,omitempty"` 124 AccountType *BankAccountType `json:"account_type,omitempty"` 125 AccountBank *string `json:"account_bank,omitempty"` 126 BankName *string `json:"bank_name,omitempty"` 127 BankBranchId *string `json:"bank_branch_id,omitempty"` 128 AccountNumber *string `json:"account_number,omitempty"` 129 VerifyResult *AuditResult `json:"verify_result,omitempty"` 130 VerifyFailReason *string `json:"verify_fail_reason,omitempty"` 131 VerifyFinishTime *string `json:"verify_finish_time,omitempty"` 132} 133 134type BankAccountType string 135 136func (e BankAccountType) Ptr() *BankAccountType { 137 return &e 138} 139 140const ( 141 BANKACCOUNTTYPE_ACCOUNT_TYPE_BUSINESS BankAccountType = "ACCOUNT_TYPE_BUSINESS" 142 BANKACCOUNTTYPE_ACCOUNT_TYPE_PRIVATE BankAccountType = "ACCOUNT_TYPE_PRIVATE" 143) 144 145type AuditResult string 146 147func (e AuditResult) Ptr() *AuditResult { 148 return &e 149} 150 151const ( 152 AUDITRESULT_AUDIT_SUCCESS AuditResult = "AUDIT_SUCCESS" 153 AUDITRESULT_AUDITING AuditResult = "AUDITING" 154 AUDITRESULT_AUDIT_FAIL AuditResult = "AUDIT_FAIL" 155) 156
应答参数
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)
【银行账号】 特约商户的结算账户-银行账号,掩码显示。
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 | 系统失败 | 请使用相同参数稍后重新调用 |