删除二级商户可扫码充值员工
更新时间:2025.07.29收付通平台可以调用此接口删除二级子商户的可扫码充值员工。
接口限频:单个平台商户10QPS,即每秒钟的请求频率不超过10次
接口说明
支持商户:【平台商户】
请求方式:【POST】/v3/platsolution/ecommerce/recharge-employees/sub-mchid/{sub_mchid}/sp-openid/{sp_openid}/delete
请求域名:【主域名】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)
【二级商户号】 二级商户号
sp_openid 必填 string(32)
【员工OpenID】 二级商户的员工在平台商户应用下的OpenID
请求示例
需配合微信支付工具库 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 PlatSolutionRechargeEmployeeDelete { 26 private static String HOST = "https://api.mch.weixin.qq.com"; 27 private static String METHOD = "POST"; 28 private static String PATH = "/v3/platsolution/ecommerce/recharge-employees/sub-mchid/{sub_mchid}/sp-openid/{sp_openid}/delete"; 29 30 public static void main(String[] args) { 31 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340 32 PlatSolutionRechargeEmployeeDelete client = new PlatSolutionRechargeEmployeeDelete( 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 PlatSolutionRechargeEmployeeDeleteRequest request = new PlatSolutionRechargeEmployeeDeleteRequest(); 41 request.subMchid = "1900001109"; 42 request.spOpenid = "oLTPCuCsfN3ABBz50VUZBNlHDbUU"; 43 try { 44 RechargeEmployee 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 RechargeEmployee run(PlatSolutionRechargeEmployeeDeleteRequest request) { 55 String uri = PATH; 56 uri = uri.replace("{sub_mchid}", WXPayUtility.urlEncode(request.subMchid)); 57 uri = uri.replace("{sp_openid}", WXPayUtility.urlEncode(request.spOpenid)); 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.addHeader("Content-Type", "application/json"); 64 RequestBody emptyBody = RequestBody.create(null, ""); 65 reqBuilder.method(METHOD, emptyBody); 66 Request httpRequest = reqBuilder.build(); 67 68 // 发送HTTP请求 69 OkHttpClient client = new OkHttpClient.Builder().build(); 70 try (Response httpResponse = client.newCall(httpRequest).execute()) { 71 String respBody = WXPayUtility.extractBody(httpResponse); 72 if (httpResponse.code() >= 200 && httpResponse.code() < 300) { 73 // 2XX 成功,验证应答签名 74 WXPayUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey, 75 httpResponse.headers(), respBody); 76 77 // 从HTTP应答报文构建返回数据 78 return WXPayUtility.fromJson(respBody, RechargeEmployee.class); 79 } else { 80 throw new WXPayUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers()); 81 } 82 } catch (IOException e) { 83 throw new UncheckedIOException("Sending request to " + uri + " failed.", e); 84 } 85 } 86 87 private final String mchid; 88 private final String certificateSerialNo; 89 private final PrivateKey privateKey; 90 private final String wechatPayPublicKeyId; 91 private final PublicKey wechatPayPublicKey; 92 93 public PlatSolutionRechargeEmployeeDelete(String mchid, String certificateSerialNo, String privateKeyFilePath, String wechatPayPublicKeyId, String wechatPayPublicKeyFilePath) { 94 this.mchid = mchid; 95 this.certificateSerialNo = certificateSerialNo; 96 this.privateKey = WXPayUtility.loadPrivateKeyFromPath(privateKeyFilePath); 97 this.wechatPayPublicKeyId = wechatPayPublicKeyId; 98 this.wechatPayPublicKey = WXPayUtility.loadPublicKeyFromPath(wechatPayPublicKeyFilePath); 99 } 100 101 public static class PlatSolutionRechargeEmployeeDeleteRequest { 102 @SerializedName("sub_mchid") 103 @Expose(serialize = false) 104 public String subMchid; 105 106 @SerializedName("sp_openid") 107 @Expose(serialize = false) 108 public String spOpenid; 109 } 110 111 public static class RechargeEmployee { 112 @SerializedName("sub_mchid") 113 public String subMchid; 114 115 @SerializedName("sp_openid") 116 public String spOpenid; 117 118 @SerializedName("state") 119 public RechargeEmployeeState state; 120 121 @SerializedName("create_time") 122 public String createTime; 123 124 @SerializedName("update_time") 125 public String updateTime; 126 } 127 128 public enum RechargeEmployeeState { 129 @SerializedName("EFFECTIVE") 130 EFFECTIVE, 131 @SerializedName("DELETED") 132 DELETED 133 } 134 135} 136
需配合微信支付工具库 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 "time" 11) 12 13func main() { 14 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340 15 config, err := wxpay_utility.CreateMchConfig( 16 "19xxxxxxxx", // 商户号,是由微信支付系统生成并分配给每个商户的唯一标识符,商户号获取方式参考 https://pay.weixin.qq.com/doc/v3/partner/4013080340 17 "1DDE55AD98Exxxxxxxxxx", // 商户API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/v3/partner/4013058924 18 "/path/to/apiclient_key.pem", // 商户API证书私钥文件路径,本地文件路径 19 "PUB_KEY_ID_xxxxxxxxxxxxx", // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/v3/partner/4013038589 20 "/path/to/wxp_pub.pem", // 微信支付公钥文件路径,本地文件路径 21 ) 22 if err != nil { 23 fmt.Println(err) 24 return 25 } 26 27 request := &PlatSolutionRechargeEmployeeDeleteRequest{ 28 SubMchid: wxpay_utility.String("1900001109"), 29 SpOpenid: wxpay_utility.String("oLTPCuCsfN3ABBz50VUZBNlHDbUU"), 30 } 31 32 response, err := PlatSolutionRechargeEmployeeDelete(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 PlatSolutionRechargeEmployeeDelete(config *wxpay_utility.MchConfig, request *PlatSolutionRechargeEmployeeDeleteRequest) (response *RechargeEmployee, err error) { 44 const ( 45 host = "https://api.mch.weixin.qq.com" 46 method = "POST" 47 path = "/v3/platsolution/ecommerce/recharge-employees/sub-mchid/{sub_mchid}/sp-openid/{sp_openid}/delete" 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, "{sp_openid}", url.PathEscape(*request.SpOpenid), -1) 56 httpRequest, err := http.NewRequest(method, reqUrl.String(), nil) 57 if err != nil { 58 return nil, err 59 } 60 httpRequest.Header.Set("Accept", "application/json") 61 httpRequest.Header.Set("Wechatpay-Serial", config.WechatPayPublicKeyId()) 62 httpRequest.Header.Set("Content-Type", "application/json") 63 authorization, err := wxpay_utility.BuildAuthorization(config.MchId(), config.CertificateSerialNo(), config.PrivateKey(), method, reqUrl.RequestURI(), nil) 64 if err != nil { 65 return nil, err 66 } 67 httpRequest.Header.Set("Authorization", authorization) 68 69 client := &http.Client{} 70 httpResponse, err := client.Do(httpRequest) 71 if err != nil { 72 return nil, err 73 } 74 75 respBody, err := wxpay_utility.ExtractResponseBody(httpResponse) 76 if err != nil { 77 return nil, err 78 } 79 80 if httpResponse.StatusCode >= 200 && httpResponse.StatusCode < 300 { 81 // 2XX 成功,验证应答签名 82 err = wxpay_utility.ValidateResponse( 83 config.WechatPayPublicKeyId(), 84 config.WechatPayPublicKey(), 85 &httpResponse.Header, 86 respBody, 87 ) 88 if err != nil { 89 return nil, err 90 } 91 92 if err := json.Unmarshal(respBody, response); err != nil { 93 return nil, err 94 } 95 96 return response, nil 97 } else { 98 return nil, wxpay_utility.NewApiException( 99 httpResponse.StatusCode, 100 httpResponse.Header, 101 respBody, 102 ) 103 } 104} 105 106type PlatSolutionRechargeEmployeeDeleteRequest struct { 107 SubMchid *string `json:"sub_mchid,omitempty"` 108 SpOpenid *string `json:"sp_openid,omitempty"` 109} 110 111func (o *PlatSolutionRechargeEmployeeDeleteRequest) MarshalJSON() ([]byte, error) { 112 type Alias PlatSolutionRechargeEmployeeDeleteRequest 113 a := &struct { 114 SubMchid *string `json:"sub_mchid,omitempty"` 115 SpOpenid *string `json:"sp_openid,omitempty"` 116 *Alias 117 }{ 118 // 序列化时移除非 Body 字段 119 SubMchid: nil, 120 SpOpenid: nil, 121 Alias: (*Alias)(o), 122 } 123 return json.Marshal(a) 124} 125 126type RechargeEmployee struct { 127 SubMchid *string `json:"sub_mchid,omitempty"` 128 SpOpenid *string `json:"sp_openid,omitempty"` 129 State *RechargeEmployeeState `json:"state,omitempty"` 130 CreateTime *time.Time `json:"create_time,omitempty"` 131 UpdateTime *time.Time `json:"update_time,omitempty"` 132} 133 134type RechargeEmployeeState string 135 136func (e RechargeEmployeeState) Ptr() *RechargeEmployeeState { 137 return &e 138} 139 140const ( 141 RECHARGEEMPLOYEESTATE_EFFECTIVE RechargeEmployeeState = "EFFECTIVE" 142 RECHARGEEMPLOYEESTATE_DELETED RechargeEmployeeState = "DELETED" 143) 144
POST
删除员工
1curl -X POST \ 2 /v3/platsolution/ecommerce/recharge-employees/sub-mchid/1900001109/sp-openid/oLTPCuCsfN3ABBz50VUZBNlHDbUU/delete \ 3 -H "Authorization: WECHATPAY2-SHA256-RSA2048 mchid=\"1900000001\",..." \ 4 -H "Accept: application/json" 5
应答参数
200 OK
sub_mchid 必填 string(32)
【二级商户号】 二级商户号
sp_openid 必填 string(32)
【员工OpenID】 二级商户的员工在平台商户应用下的OpenID
state 选填 string
【员工状态】 员工状态
可选取值
EFFECTIVE
: 生效中DELETED
: 已删除
create_time 选填 string(32)
【添加员工时间】 添加员工时间,使用rfc3339标准格式
update_time 选填 string(32)
【最后更新时间】 最后更新时间,使用rfc3339标准格式
应答示例
200 OK
删除员工
1{ 2 "create_time" : "2015-05-20T13:29:35.120+08:00", 3 "sp_openid" : "oLTPCuCsfN3ABBz50VUZBNlHDbUU", 4 "state" : "DELETED", 5 "sub_mchid" : "1900001109", 6 "update_time" : "2015-05-21T13:29:35.120+08:00" 7} 8
错误码
公共错误码
状态码 | 错误码 | 描述 | 解决方案 |
---|---|---|---|
400 | PARAM_ERROR | 参数错误 | 请根据错误提示正确传入参数 |
400 | INVALID_REQUEST | HTTP 请求不符合微信支付 APIv3 接口规则 | 请参阅 接口规则 |
401 | SIGN_ERROR | 验证不通过 | 请参阅 签名常见问题 |
500 | SYSTEM_ERROR | 系统异常,请稍后重试 | 请稍后重试 |
业务错误码
状态码 | 错误码 | 描述 | 解决方案 |
---|---|---|---|
400 | INVALID_REQUEST | 请求不符合业务规则 | 请按接口描述使用 |
403 | NO_AUTH | 没有相关权限 | 请核实是否开通了该功能 |
429 | FREQUENCY_LIMITED | 频率限制 | 请降低频率后重试 |