解管
更新时间:2025.09.09解除对微众台账的管控。接口仅受理,解管成功或失败后,可以通知发起方(需发起方提供通知地址)。
接口支持重入,重入有效期1年。
限频:200/分钟
接口说明
支持商户:【普通商户】
请求方式:【POST】/v3/aggracct-bc/wb-channel/control-orders/recover
请求域名:【主域名】https://api.mch.weixin.qq.com 使用该域名将访问就近的接入点
【备域名】https://api2.mch.weixin.qq.com 使用该域名将访问异地的接入点 ,指引点击查看
请求参数
Header HTTP头参数
Authorization 必填 string
请参考签名认证生成认证信息
Accept 必填 string
请设置为application/json
Content-Type 必填 string
请设置为application/json
Wechatpay-Serial 必填 string
【微信支付公钥ID】或【微信支付平台证书序列号】 请求参数中的敏感字段,需要使用微信支付公钥加密(推荐),请参考获取微信支付公钥ID说明以及微信支付公钥加密敏感信息指引;也可以使用微信支付平台证书公钥加密,参考获取平台证书序列号、平台证书加密敏感信息指引
body 包体参数
out_request_no 必填 string(64)
【微众解管单号】 “微众解管单号”不能和“关联微众管控单号”相同
related_webank_punish_no 必填 string
【关联微众管控单号】 微众管控单号
related_wxpay_punish_no 必填 string
【关联微信支付管控单号】 微信支付管控单号
mchid 必填 string
【目标解管商户号】 微信支付商户号
bal_account_no 选填 string
【目标解管台账ID】 【加密】台账ID,对应微众支用账号(req_scene=SJT_CONVENIENT_SETTLEMENT_SERVICE_MERCHANT时必传)
recover_reason 选填 string(256)
【解管原因描述】 仅支持UTF8可见字符
card_no 选填 string
【目标解管卡号】 【加密】二类卡卡号(req_scene=SJT_MICRO_MERCHANT时必传)
sgn_no 选填 string
【目标解管商户子账户协议号】 商户子账户协议号(req_scene=SJT_MICRO_MERCHANT时必传)
req_scene 选填 string
【请求场景】 不填默认按SJT_CONVENIENT_SETTLEMENT_SERVICE_MERCHANT处理
可选取值
SJT_CONVENIENT_SETTLEMENT_SERVICE_MERCHANT: 经营账户-结算便利服务商户SJT_MICRO_MERCHANT: 经营账户-微商户WX_SHOP_CONVENIENT_SETTLEMENT_SERVICE_MERCHANT: 微信小店-结算便利服务商户
请求示例
POST
1curl -X POST \ 2 https://api.mch.weixin.qq.com/v3/aggracct-bc/wb-channel/control-orders/recover \ 3 -H "Authorization: WECHATPAY2-SHA256-RSA2048 mchid=\"1900000001\",..." \ 4 -H "Accept: application/json" \ 5 -H "Wechatpay-Serial: 5157F09EFDC096DE15EBE81A47057A7232F1B8E1" \ 6 -H "Content-Type: application/json" \ 7 -d '{ 8 "out_request_no" : "example_out_request_no", 9 "related_webank_punish_no" : "example_related_webank_punish_no", 10 "related_wxpay_punish_no" : "example_related_wxpay_punish_no", 11 "mchid" : "example_mchid", 12 "bal_account_no" : "example_bal_account_no", 13 "recover_reason" : "example_recover_reason", 14 "card_no" : "example_card_no", 15 "sgn_no" : "example_sgn_no", 16 "req_scene" : "SJT_CONVENIENT_SETTLEMENT_SERVICE_MERCHANT" 17 }' 18
需配合微信支付工具库 WXPayUtility 使用,请参考Java
1package com.java.demo; 2 3import com.java.utils.WXPayUtility; // 引用微信支付工具库,参考:https://pay.weixin.qq.com/doc/v3/merchant/4014931831 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 Recover { 26 private static String HOST = "https://api.mch.weixin.qq.com"; 27 private static String METHOD = "POST"; 28 private static String PATH = "/v3/aggracct-bc/wb-channel/control-orders/recover"; 29 30 public static void main(String[] args) { 31 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/merchant/4013070756 32 Recover client = new Recover( 33 "19xxxxxxxx", // 商户号,是由微信支付系统生成并分配给每个商户的唯一标识符,商户号获取方式参考 https://pay.weixin.qq.com/doc/v3/merchant/4013070756 34 "1DDE55AD98Exxxxxxxxxx", // 商户API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/v3/merchant/4013053053 35 "/path/to/apiclient_key.pem", // 商户API证书私钥文件路径,本地文件路径 36 "PUB_KEY_ID_xxxxxxxxxxxxx", // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/v3/merchant/4013038816 37 "/path/to/wxp_pub.pem" // 微信支付公钥文件路径,本地文件路径 38 ); 39 40 RecoverRequest request = new RecoverRequest(); 41 request.outRequestNo = "example_out_request_no"; 42 request.relatedWebankPunishNo = "example_related_webank_punish_no"; 43 request.relatedWxpayPunishNo = "example_related_wxpay_punish_no"; 44 request.mchid = "example_mchid"; 45 request.balAccountNo = client.encrypt("bal_account_no"); 46 request.recoverReason = "example_recover_reason"; 47 request.cardNo = client.encrypt("card_no"); 48 request.sgnNo = "example_sgn_no"; 49 request.reqScene = RequestScene.SJT_CONVENIENT_SETTLEMENT_SERVICE_MERCHANT; 50 try { 51 RecoverResponse response = client.run(request); 52 // TODO: 请求成功,继续业务逻辑 53 System.out.println(response); 54 } catch (WXPayUtility.ApiException e) { 55 // TODO: 请求失败,根据状态码执行不同的逻辑 56 e.printStackTrace(); 57 } 58 } 59 60 public RecoverResponse run(RecoverRequest request) { 61 String uri = PATH; 62 String reqBody = WXPayUtility.toJson(request); 63 64 Request.Builder reqBuilder = new Request.Builder().url(HOST + uri); 65 reqBuilder.addHeader("Accept", "application/json"); 66 reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId); 67 reqBuilder.addHeader("Authorization", WXPayUtility.buildAuthorization(mchid, certificateSerialNo,privateKey, METHOD, uri, reqBody)); 68 reqBuilder.addHeader("Content-Type", "application/json"); 69 RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), reqBody); 70 reqBuilder.method(METHOD, requestBody); 71 Request httpRequest = reqBuilder.build(); 72 73 // 发送HTTP请求 74 OkHttpClient client = new OkHttpClient.Builder().build(); 75 try (Response httpResponse = client.newCall(httpRequest).execute()) { 76 String respBody = WXPayUtility.extractBody(httpResponse); 77 if (httpResponse.code() >= 200 && httpResponse.code() < 300) { 78 // 2XX 成功,验证应答签名 79 WXPayUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey, 80 httpResponse.headers(), respBody); 81 82 // 从HTTP应答报文构建返回数据 83 return WXPayUtility.fromJson(respBody, RecoverResponse.class); 84 } else { 85 throw new WXPayUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers()); 86 } 87 } catch (IOException e) { 88 throw new UncheckedIOException("Sending request to " + uri + " failed.", e); 89 } 90 } 91 92 private final String mchid; 93 private final String certificateSerialNo; 94 private final PrivateKey privateKey; 95 private final String wechatPayPublicKeyId; 96 private final PublicKey wechatPayPublicKey; 97 98 public Recover(String mchid, String certificateSerialNo, String privateKeyFilePath, String wechatPayPublicKeyId, String wechatPayPublicKeyFilePath) { 99 this.mchid = mchid; 100 this.certificateSerialNo = certificateSerialNo; 101 this.privateKey = WXPayUtility.loadPrivateKeyFromPath(privateKeyFilePath); 102 this.wechatPayPublicKeyId = wechatPayPublicKeyId; 103 this.wechatPayPublicKey = WXPayUtility.loadPublicKeyFromPath(wechatPayPublicKeyFilePath); 104 } 105 106 public String encrypt(String plainText) { 107 return WXPayUtility.encrypt(this.wechatPayPublicKey, plainText); 108 } 109 110 public static class RecoverRequest { 111 @SerializedName("out_request_no") 112 public String outRequestNo; 113 114 @SerializedName("related_webank_punish_no") 115 public String relatedWebankPunishNo; 116 117 @SerializedName("related_wxpay_punish_no") 118 public String relatedWxpayPunishNo; 119 120 @SerializedName("mchid") 121 public String mchid; 122 123 @SerializedName("bal_account_no") 124 public String balAccountNo; 125 126 @SerializedName("recover_reason") 127 public String recoverReason; 128 129 @SerializedName("card_no") 130 public String cardNo; 131 132 @SerializedName("sgn_no") 133 public String sgnNo; 134 135 @SerializedName("req_scene") 136 public RequestScene reqScene; 137 } 138 139 public static class RecoverResponse { 140 @SerializedName("wxpay_recover_no") 141 public String wxpayRecoverNo; 142 143 @SerializedName("out_request_no") 144 public String outRequestNo; 145 } 146 147 public enum RequestScene { 148 @SerializedName("SJT_CONVENIENT_SETTLEMENT_SERVICE_MERCHANT") 149 SJT_CONVENIENT_SETTLEMENT_SERVICE_MERCHANT, 150 @SerializedName("SJT_MICRO_MERCHANT") 151 SJT_MICRO_MERCHANT, 152 @SerializedName("WX_SHOP_CONVENIENT_SETTLEMENT_SERVICE_MERCHANT") 153 WX_SHOP_CONVENIENT_SETTLEMENT_SERVICE_MERCHANT 154 } 155 156} 157
需配合微信支付工具库 wxpay_utility 使用,请参考Go
1package main 2 3import ( 4 "bytes" 5 "demo/wxpay_utility" // 引用微信支付工具库,参考 https://pay.weixin.qq.com/doc/v3/merchant/4015119334 6 "encoding/json" 7 "fmt" 8 "net/http" 9 "net/url" 10) 11 12func main() { 13 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/merchant/4013070756 14 config, err := wxpay_utility.CreateMchConfig( 15 "19xxxxxxxx", // 商户号,是由微信支付系统生成并分配给每个商户的唯一标识符,商户号获取方式参考 https://pay.weixin.qq.com/doc/v3/merchant/4013070756 16 "1DDE55AD98Exxxxxxxxxx", // 商户API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/v3/merchant/4013053053 17 "/path/to/apiclient_key.pem", // 商户API证书私钥文件路径,本地文件路径 18 "PUB_KEY_ID_xxxxxxxxxxxxx", // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/v3/merchant/4013038816 19 "/path/to/wxp_pub.pem", // 微信支付公钥文件路径,本地文件路径 20 ) 21 if err != nil { 22 fmt.Println(err) 23 return 24 } 25 26 request := &RecoverRequest{ 27 OutRequestNo: wxpay_utility.String("example_out_request_no"), 28 RelatedWebankPunishNo: wxpay_utility.String("example_related_webank_punish_no"), 29 RelatedWxpayPunishNo: wxpay_utility.String("example_related_wxpay_punish_no"), 30 Mchid: wxpay_utility.String("example_mchid"), 31 BalAccountNo: wxpay_utility.String("example_bal_account_no"), /*请传入wxpay_utility.EncryptOAEPWithPublicKey 加密结果*/ 32 RecoverReason: wxpay_utility.String("example_recover_reason"), 33 CardNo: wxpay_utility.String("example_card_no"), /*请传入wxpay_utility.EncryptOAEPWithPublicKey 加密结果*/ 34 SgnNo: wxpay_utility.String("example_sgn_no"), 35 ReqScene: REQUESTSCENE_SJT_CONVENIENT_SETTLEMENT_SERVICE_MERCHANT.Ptr(), 36 } 37 38 response, err := Recover(config, request) 39 if err != nil { 40 fmt.Printf("请求失败: %+v\n", err) 41 // TODO: 请求失败,根据状态码执行不同的处理 42 return 43 } 44 45 // TODO: 请求成功,继续业务逻辑 46 fmt.Printf("请求成功: %+v\n", response) 47} 48 49func Recover(config *wxpay_utility.MchConfig, request *RecoverRequest) (response *RecoverResponse, err error) { 50 const ( 51 host = "https://api.mch.weixin.qq.com" 52 method = "POST" 53 path = "/v3/aggracct-bc/wb-channel/control-orders/recover" 54 ) 55 56 reqUrl, err := url.Parse(fmt.Sprintf("%s%s", host, path)) 57 if err != nil { 58 return nil, err 59 } 60 reqBody, err := json.Marshal(request) 61 if err != nil { 62 return nil, err 63 } 64 httpRequest, err := http.NewRequest(method, reqUrl.String(), bytes.NewReader(reqBody)) 65 if err != nil { 66 return nil, err 67 } 68 httpRequest.Header.Set("Accept", "application/json") 69 httpRequest.Header.Set("Wechatpay-Serial", config.WechatPayPublicKeyId()) 70 httpRequest.Header.Set("Content-Type", "application/json") 71 authorization, err := wxpay_utility.BuildAuthorization(config.MchId(), config.CertificateSerialNo(), config.PrivateKey(), method, reqUrl.RequestURI(), reqBody) 72 if err != nil { 73 return nil, err 74 } 75 httpRequest.Header.Set("Authorization", authorization) 76 77 client := &http.Client{} 78 httpResponse, err := client.Do(httpRequest) 79 if err != nil { 80 return nil, err 81 } 82 respBody, err := wxpay_utility.ExtractResponseBody(httpResponse) 83 if err != nil { 84 return nil, err 85 } 86 if httpResponse.StatusCode >= 200 && httpResponse.StatusCode < 300 { 87 // 2XX 成功,验证应答签名 88 err = wxpay_utility.ValidateResponse( 89 config.WechatPayPublicKeyId(), 90 config.WechatPayPublicKey(), 91 &httpResponse.Header, 92 respBody, 93 ) 94 if err != nil { 95 return nil, err 96 } 97 response := &RecoverResponse{} 98 if err := json.Unmarshal(respBody, response); err != nil { 99 return nil, err 100 } 101 102 return response, nil 103 } else { 104 return nil, wxpay_utility.NewApiException( 105 httpResponse.StatusCode, 106 httpResponse.Header, 107 respBody, 108 ) 109 } 110} 111 112type RecoverRequest struct { 113 OutRequestNo *string `json:"out_request_no,omitempty"` 114 RelatedWebankPunishNo *string `json:"related_webank_punish_no,omitempty"` 115 RelatedWxpayPunishNo *string `json:"related_wxpay_punish_no,omitempty"` 116 Mchid *string `json:"mchid,omitempty"` 117 BalAccountNo *string `json:"bal_account_no,omitempty"` 118 RecoverReason *string `json:"recover_reason,omitempty"` 119 CardNo *string `json:"card_no,omitempty"` 120 SgnNo *string `json:"sgn_no,omitempty"` 121 ReqScene *RequestScene `json:"req_scene,omitempty"` 122} 123 124type RecoverResponse struct { 125 WxpayRecoverNo *string `json:"wxpay_recover_no,omitempty"` 126 OutRequestNo *string `json:"out_request_no,omitempty"` 127} 128 129type RequestScene string 130 131func (e RequestScene) Ptr() *RequestScene { 132 return &e 133} 134 135const ( 136 REQUESTSCENE_SJT_CONVENIENT_SETTLEMENT_SERVICE_MERCHANT RequestScene = "SJT_CONVENIENT_SETTLEMENT_SERVICE_MERCHANT" 137 REQUESTSCENE_SJT_MICRO_MERCHANT RequestScene = "SJT_MICRO_MERCHANT" 138 REQUESTSCENE_WX_SHOP_CONVENIENT_SETTLEMENT_SERVICE_MERCHANT RequestScene = "WX_SHOP_CONVENIENT_SETTLEMENT_SERVICE_MERCHANT" 139) 140
应答参数
200 OK
wxpay_recover_no 必填 string
【微信支付解管单号】 仅解管受理成功返回
out_request_no 必填 string
【微众解管单号】 请求时传入的微众解管单号
应答示例
200 OK
1{ 2 "wxpay_recover_no" : "example_wxpay_recover_no", 3 "out_request_no" : "example_out_request_no" 4} 5
错误码
以下是本接口返回的错误码列表。详细错误码规则,请参考微信支付接口规则-错误码和错误提示
状态码 | 错误码 | 描述 | 解决方案 |
|---|---|---|---|
400 | PARAM_ERROR | 参数错误 | 请根据错误提示正确传入参数 |
400 | INVALID_REQUEST | HTTP 请求不符合微信支付 APIv3 接口规则 | 请参阅 接口规则 |
401 | SIGN_ERROR | 验证不通过 | 请参阅 签名常见问题 |
500 | SYSTEM_ERROR | 系统异常,请稍后重试 | 请稍后重试 |
400 | INVALID_REQUEST | 请求参数符合参数格式,但不符合业务规则 | 此状态代表解管申请失败,请根据具体的错误提示做相应的处理。 |
400 | NOT_FOUND | 目标解管商户号不存在 | 目标解管商户号不存在,请检查后重试 |
404 | NOT_FOUND | 关联管控单不存在 | 传入的关联管控单号不存在,请检查后重试 |
400 | ALREADY_EXISTS | 商户已被解管 | 商户已被解管,无需再解管 |
