撤销申请
更新时间:2025.09.24当修改商户简称申请单状态为审核中/已驳回时,才支持撤销
接口说明
支持商户:【普通服务商】
请求方式:【POST】/v3/mchalterapply/merchantnamealterapplyment/{apply_id}/revoke
请求域名:【主域名】https://api.mch.weixin.qq.com 使用该域名将访问就近的接入点
【备域名】https://api2.mch.weixin.qq.com 使用该域名将访问异地的接入点 ,指引点击查看
请求参数
Header HTTP头参数
Authorization 必填 string
请参考签名认证生成认证信息
Accept 必填 string
请设置为application/json
path 路径参数
apply_id 必填 string(64)
【微信支付申请单号】 微信支付分配的申请单号
请求示例
curl
Java
Go
POST
1curl -X POST \ 2 https://api.mch.weixin.qq.com/v3/mchalterapply/merchantnamealterapplyment/20220617143306000013906025001/revoke \ 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 RevokeMerchantNameAlterApplyment { 26 private static String HOST = "https://api.mch.weixin.qq.com"; 27 private static String METHOD = "POST"; 28 private static String PATH = "/v3/mchalterapply/merchantnamealterapplyment/{apply_id}/revoke"; 29 30 public static void main(String[] args) { 31 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340 32 RevokeMerchantNameAlterApplyment client = new RevokeMerchantNameAlterApplyment( 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 RevokeMerchantNameAlterApplymentRequest request = new RevokeMerchantNameAlterApplymentRequest(); 41 request.applyId = "20220617143306000013906025001"; 42 try { 43 RevokeMerchantNameAlterApplymentResponse response = client.run(request); 44 // TODO: 请求成功,继续业务逻辑 45 System.out.println(response); 46 } catch (WXPayUtility.ApiException e) { 47 // TODO: 请求失败,根据状态码执行不同的逻辑 48 e.printStackTrace(); 49 } 50 } 51 52 public RevokeMerchantNameAlterApplymentResponse run(RevokeMerchantNameAlterApplymentRequest request) { 53 String uri = PATH; 54 uri = uri.replace("{apply_id}", WXPayUtility.urlEncode(request.applyId)); 55 56 Request.Builder reqBuilder = new Request.Builder().url(HOST + uri); 57 reqBuilder.addHeader("Accept", "application/json"); 58 reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId); 59 reqBuilder.addHeader("Authorization", WXPayUtility.buildAuthorization(mchid, certificateSerialNo, privateKey, METHOD, uri, null)); 60 reqBuilder.addHeader("Content-Type", "application/json"); 61 RequestBody emptyBody = RequestBody.create(null, ""); 62 reqBuilder.method(METHOD, emptyBody); 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, RevokeMerchantNameAlterApplymentResponse.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 RevokeMerchantNameAlterApplyment(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 RevokeMerchantNameAlterApplymentRequest { 99 @SerializedName("apply_id") 100 @Expose(serialize = false) 101 public String applyId; 102 } 103 104 public static class RevokeMerchantNameAlterApplymentResponse { 105 @SerializedName("apply_id") 106 public String applyId; 107 108 @SerializedName("state") 109 public RevokeApplymentState state; 110 } 111 112 public enum RevokeApplymentState { 113 @SerializedName("APPLYMENT_STATE_CANCELED") 114 APPLYMENT_STATE_CANCELED 115 } 116 117} 118
需配合微信支付工具库 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 := &RevokeMerchantNameAlterApplymentRequest{ 27 ApplyId: wxpay_utility.String("20220617143306000013906025001"), 28 } 29 30 response, err := RevokeMerchantNameAlterApplyment(config, request) 31 if err != nil { 32 fmt.Printf("请求失败: %+v\n", err) 33 // TODO: 请求失败,根据状态码执行不同的处理 34 return 35 } 36 37 // TODO: 请求成功,继续业务逻辑 38 fmt.Printf("请求成功: %+v\n", response) 39} 40 41func RevokeMerchantNameAlterApplyment(config *wxpay_utility.MchConfig, request *RevokeMerchantNameAlterApplymentRequest) (response *RevokeMerchantNameAlterApplymentResponse, err error) { 42 const ( 43 host = "https://api.mch.weixin.qq.com" 44 method = "POST" 45 path = "/v3/mchalterapply/merchantnamealterapplyment/{apply_id}/revoke" 46 ) 47 48 reqUrl, err := url.Parse(fmt.Sprintf("%s%s", host, path)) 49 if err != nil { 50 return nil, err 51 } 52 reqUrl.Path = strings.Replace(reqUrl.Path, "{apply_id}", url.PathEscape(*request.ApplyId), -1) 53 httpRequest, err := http.NewRequest(method, reqUrl.String(), nil) 54 if err != nil { 55 return nil, err 56 } 57 httpRequest.Header.Set("Accept", "application/json") 58 httpRequest.Header.Set("Wechatpay-Serial", config.WechatPayPublicKeyId()) 59 httpRequest.Header.Set("Content-Type", "application/json") 60 authorization, err := wxpay_utility.BuildAuthorization(config.MchId(), config.CertificateSerialNo(), config.PrivateKey(), method, reqUrl.RequestURI(), nil) 61 if err != nil { 62 return nil, err 63 } 64 httpRequest.Header.Set("Authorization", authorization) 65 66 client := &http.Client{} 67 httpResponse, err := client.Do(httpRequest) 68 if err != nil { 69 return nil, err 70 } 71 respBody, err := wxpay_utility.ExtractResponseBody(httpResponse) 72 if err != nil { 73 return nil, err 74 } 75 if httpResponse.StatusCode >= 200 && httpResponse.StatusCode < 300 { 76 // 2XX 成功,验证应答签名 77 err = wxpay_utility.ValidateResponse( 78 config.WechatPayPublicKeyId(), 79 config.WechatPayPublicKey(), 80 &httpResponse.Header, 81 respBody, 82 ) 83 if err != nil { 84 return nil, err 85 } 86 response := &RevokeMerchantNameAlterApplymentResponse{} 87 if err := json.Unmarshal(respBody, response); err != nil { 88 return nil, err 89 } 90 91 return response, nil 92 } else { 93 return nil, wxpay_utility.NewApiException( 94 httpResponse.StatusCode, 95 httpResponse.Header, 96 respBody, 97 ) 98 } 99} 100 101type RevokeMerchantNameAlterApplymentRequest struct { 102 ApplyId *string `json:"apply_id,omitempty"` 103} 104 105func (o *RevokeMerchantNameAlterApplymentRequest) MarshalJSON() ([]byte, error) { 106 type Alias RevokeMerchantNameAlterApplymentRequest 107 a := &struct { 108 ApplyId *string `json:"apply_id,omitempty"` 109 *Alias 110 }{ 111 // 序列化时移除非 Body 字段 112 ApplyId: nil, 113 Alias: (*Alias)(o), 114 } 115 return json.Marshal(a) 116} 117 118type RevokeMerchantNameAlterApplymentResponse struct { 119 ApplyId *string `json:"apply_id,omitempty"` 120 State *RevokeApplymentState `json:"state,omitempty"` 121} 122 123type RevokeApplymentState string 124 125func (e RevokeApplymentState) Ptr() *RevokeApplymentState { 126 return &e 127} 128 129const ( 130 REVOKEAPPLYMENTSTATE_APPLYMENT_STATE_CANCELED RevokeApplymentState = "APPLYMENT_STATE_CANCELED" 131) 132
应答参数
200 OK
apply_id 选填 string
【申请单号】 微信支付分配的申请单号
state 选填 string
【申请单状态】 当前申请单状态
可选取值
APPLYMENT_STATE_CANCELED
: 申请单已被撤销。
应答示例
200 OK
1{ 2 "apply_id" : "20220617143306000013906025001", 3 "state" : "APPLYMENT_STATE_CANCELED" 4} 5
错误码
以下是本接口返回的错误码列表。详细错误码规则,请参考微信支付接口规则-错误码和错误提示
文档是否有帮助