撤销申请单-使用申请单号
更新时间:2025.07.22平台服务商提交申请单后需要进行撤销操作时,可调用该撤销申请单接口,仅当申请单状态为资料校验中、待账户验证、审核中、已驳回、待签约、已冻结时才允许撤销。
接口说明
支持商户:【平台商户】
请求方式:【POST】/v3/ecommerce/applyments/{applyment_id}/revoke
请求域名:【主域名】https://api.mch.weixin.qq.com 使用该域名将访问就近的接入点
【备域名】https://api2.mch.weixin.qq.com 使用该域名将访问异地的接入点 ,指引点击查看
请求参数
Header HTTP头参数
Authorization 必填 string
请参考签名认证生成认证信息
Accept 必填 string
请设置为application/json
path 路径参数
applyment_id 必填 integer
【微信支付申请单号】 微信支付分配的申请单号
请求示例
Java
Go
curl
需配合微信支付工具库 WXPayUtility 使用,请参考 iwiki-document:inline_state
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 RevokeApplymentById { 26 private static String HOST = "https://api.mch.weixin.qq.com"; 27 private static String METHOD = "POST"; 28 private static String PATH = "/v3/ecommerce/applyments/{applyment_id}/revoke"; 29 30 public static void main(String[] args) { 31 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340 32 RevokeApplymentById client = new RevokeApplymentById( 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 RevokeApplymentByIdRequest request = new RevokeApplymentByIdRequest(); 41 request.applymentId = 2000002124775691L; 42 try { 43 RevokeApplymentResponse response = client.run(request); 44 45 // TODO: 请求成功,继续业务逻辑 46 System.out.println(response); 47 } catch (WXPayUtility.ApiException e) { 48 // TODO: 请求失败,根据状态码执行不同的逻辑 49 e.printStackTrace(); 50 } 51 } 52 53 public RevokeApplymentResponse run(RevokeApplymentByIdRequest request) { 54 String uri = PATH; 55 uri = uri.replace("{applyment_id}", WXPayUtility.urlEncode(request.applymentId.toString())); 56 57 Request.Builder reqBuilder = new Request.Builder().url(HOST + uri); 58 reqBuilder.addHeader("Accept", "application/json"); 59 reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId); 60 reqBuilder.addHeader("Authorization", WXPayUtility.buildAuthorization(mchid, certificateSerialNo, privateKey, METHOD, uri, null)); 61 reqBuilder.addHeader("Content-Type", "application/json"); 62 RequestBody emptyBody = RequestBody.create(null, ""); 63 reqBuilder.method(METHOD, emptyBody); 64 Request httpRequest = reqBuilder.build(); 65 66 // 发送HTTP请求 67 OkHttpClient client = new OkHttpClient.Builder().build(); 68 try (Response httpResponse = client.newCall(httpRequest).execute()) { 69 String respBody = WXPayUtility.extractBody(httpResponse); 70 if (httpResponse.code() >= 200 && httpResponse.code() < 300) { 71 // 2XX 成功,验证应答签名 72 WXPayUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey, 73 httpResponse.headers(), respBody); 74 75 // 从HTTP应答报文构建返回数据 76 return WXPayUtility.fromJson(respBody, RevokeApplymentResponse.class); 77 } else { 78 throw new WXPayUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers()); 79 } 80 } catch (IOException e) { 81 throw new UncheckedIOException("Sending request to " + uri + " failed.", e); 82 } 83 } 84 85 private final String mchid; 86 private final String certificateSerialNo; 87 private final PrivateKey privateKey; 88 private final String wechatPayPublicKeyId; 89 private final PublicKey wechatPayPublicKey; 90 91 public RevokeApplymentById(String mchid, String certificateSerialNo, String privateKeyFilePath, String wechatPayPublicKeyId, String wechatPayPublicKeyFilePath) { 92 this.mchid = mchid; 93 this.certificateSerialNo = certificateSerialNo; 94 this.privateKey = WXPayUtility.loadPrivateKeyFromPath(privateKeyFilePath); 95 this.wechatPayPublicKeyId = wechatPayPublicKeyId; 96 this.wechatPayPublicKey = WXPayUtility.loadPublicKeyFromPath(wechatPayPublicKeyFilePath); 97 } 98 99 public static class RevokeApplymentByIdRequest { 100 @SerializedName("applyment_id") 101 @Expose(serialize = false) 102 public Long applymentId; 103 } 104 105 public static class RevokeApplymentResponse { 106 @SerializedName("applyment_id") 107 public Long applymentId; 108 109 @SerializedName("out_request_no") 110 public String outRequestNo; 111 } 112 113} 114
需配合微信支付工具库 wxpay_utility 使用,请参考 iwiki-document:inline_state
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 := &RevokeApplymentByIdRequest{ 27 ApplymentId: wxpay_utility.Int64(2000002124775691), 28 } 29 30 response, err := RevokeApplymentById(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 RevokeApplymentById(config *wxpay_utility.MchConfig, request *RevokeApplymentByIdRequest) (response *RevokeApplymentResponse, err error) { 42 const ( 43 host = "https://api.mch.weixin.qq.com" 44 method = "POST" 45 path = "/v3/ecommerce/applyments/{applyment_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, "{applyment_id}", url.PathEscape(fmt.Sprintf("%v", *request.ApplymentId)), -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 72 respBody, err := wxpay_utility.ExtractResponseBody(httpResponse) 73 if err != nil { 74 return nil, err 75 } 76 77 if httpResponse.StatusCode >= 200 && httpResponse.StatusCode < 300 { 78 // 2XX 成功,验证应答签名 79 err = wxpay_utility.ValidateResponse( 80 config.WechatPayPublicKeyId(), 81 config.WechatPayPublicKey(), 82 &httpResponse.Header, 83 respBody, 84 ) 85 if err != nil { 86 return nil, err 87 } 88 89 if err := json.Unmarshal(respBody, response); err != nil { 90 return nil, err 91 } 92 93 return response, nil 94 } else { 95 return nil, &wxpay_utility.ApiException{ 96 StatusCode: httpResponse.StatusCode, 97 Header: httpResponse.Header, 98 Body: respBody, 99 } 100 } 101} 102 103type RevokeApplymentByIdRequest struct { 104 ApplymentId *int64 `json:"applyment_id,omitempty"` 105} 106 107func (o *RevokeApplymentByIdRequest) MarshalJSON() ([]byte, error) { 108 type Alias RevokeApplymentByIdRequest 109 a := &struct { 110 ApplymentId *int64 `json:"applyment_id,omitempty"` 111 *Alias 112 }{ 113 // 序列化时移除非 Body 字段 114 ApplymentId: nil, 115 Alias: (*Alias)(o), 116 } 117 return json.Marshal(a) 118} 119 120type RevokeApplymentResponse struct { 121 ApplymentId *int64 `json:"applyment_id,omitempty"` 122 OutRequestNo *string `json:"out_request_no,omitempty"` 123} 124
POST
1curl -X POST \ 2 https://api.mch.weixin.qq.com/v3/ecommerce/applyments/2000002124775691/revoke \ 3 -H "Authorization: WECHATPAY2-SHA256-RSA2048 mchid=\"1900000001\",..." \ 4 -H "Accept: application/json" 5
应答参数
200 OK
applyment_id 必填 integer
【微信支付申请单号】 微信支付分配的申请单号 。
out_request_no 必填 string(124)
【业务申请编号】 1、服务商自定义的商户唯一编号。 2、每个编号对应一个申请单,每个申请单审核通过后会生成一个微信支付商户号。
应答示例
200 OK
1{ 2 "applyment_id" : 2000002124775691, 3 "out_request_no" : "APPLYMENT_00000000001" 4} 5
错误码
公共错误码
文档是否有帮助