关闭广告展示
更新时间:2024.11.18||
使用此接口为特约商户的点金计划页面关闭广告展示功能
接口说明
请求方式:【POST】/v3/goldplan/merchants/close-advertising-show
请求域名:【主域名】https://api.mch.weixin.qq.com 使用该域名将访问就近的接入点
【备域名】https://api2.mch.weixin.qq.com 使用该域名将访问异地的接入点 ,指引点击查看
请求参数
Header HTTP头参数
Authorization 必填 string
Accept 必填 string
Content-Type 必填 string
body 包体参数
sub_mchid 必填 string(32)
【特约商户号】需要关闭广告展示的特约商户号,由微信支付生成并下发。
请求示例
POST

1curl -X POST \
2 https://api.mch.weixin.qq.com/v3/goldplan/merchants/close-advertising-show \
3 -H "Authorization: WECHATPAY2-SHA256-RSA2048 mchid=\"1900000001\",..." \
4 -H "Accept: application/json" \
5 -H "Content-Type: application/json" \
6 -d '{
7 "sub_mchid" : "1900000109"
8 }'
9需配合微信支付工具库 WXPayUtility 使用,请参考Java

1package com.java.demo;
2
3import com.java.utils.WXPayUtility;
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 CloseAdvertisingShow {
26 private static String HOST = "https://api.mch.weixin.qq.com";
27 private static String METHOD = "POST";
28 private static String PATH = "/v3/goldplan/merchants/close-advertising-show";
29
30 public static void main(String[] args) {
31
32 CloseAdvertisingShow client = new CloseAdvertisingShow(
33 "19xxxxxxxx",
34 "1DDE55AD98Exxxxxxxxxx",
35 "/path/to/apiclient_key.pem",
36 "PUB_KEY_ID_xxxxxxxxxxxxx",
37 "/path/to/wxp_pub.pem"
38 );
39
40 CloseAdvertisingShowRequest request = new CloseAdvertisingShowRequest();
41 request.subMchid = "1900000109";
42 try {
43 client.run(request);
44 } catch (WXPayUtility.ApiException e) {
45
46 e.printStackTrace();
47 }
48 }
49
50 public void run(CloseAdvertisingShowRequest request) {
51 String uri = PATH;
52 String reqBody = WXPayUtility.toJson(request);
53
54 Request.Builder reqBuilder = new Request.Builder().url(HOST + uri);
55 reqBuilder.addHeader("Accept", "application/json");
56 reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId);
57 reqBuilder.addHeader("Authorization", WXPayUtility.buildAuthorization(mchid, certificateSerialNo,privateKey, METHOD, uri, reqBody));
58 reqBuilder.addHeader("Content-Type", "application/json");
59 RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), reqBody);
60 reqBuilder.method(METHOD, requestBody);
61 Request httpRequest = reqBuilder.build();
62
63
64 OkHttpClient client = new OkHttpClient.Builder().build();
65 try (Response httpResponse = client.newCall(httpRequest).execute()) {
66 String respBody = WXPayUtility.extractBody(httpResponse);
67 if (httpResponse.code() >= 200 && httpResponse.code() < 300) {
68
69 WXPayUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey,
70 httpResponse.headers(), respBody);
71
72 return;
73 } else {
74 throw new WXPayUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers());
75 }
76 } catch (IOException e) {
77 throw new UncheckedIOException("Sending request to " + uri + " failed.", e);
78 }
79 }
80
81 private final String mchid;
82 private final String certificateSerialNo;
83 private final PrivateKey privateKey;
84 private final String wechatPayPublicKeyId;
85 private final PublicKey wechatPayPublicKey;
86
87 public CloseAdvertisingShow(String mchid, String certificateSerialNo, String privateKeyFilePath, String wechatPayPublicKeyId, String wechatPayPublicKeyFilePath) {
88 this.mchid = mchid;
89 this.certificateSerialNo = certificateSerialNo;
90 this.privateKey = WXPayUtility.loadPrivateKeyFromPath(privateKeyFilePath);
91 this.wechatPayPublicKeyId = wechatPayPublicKeyId;
92 this.wechatPayPublicKey = WXPayUtility.loadPublicKeyFromPath(wechatPayPublicKeyFilePath);
93 }
94
95 public static class CloseAdvertisingShowRequest {
96 @SerializedName("sub_mchid")
97 public String subMchid;
98 }
99
100}
101需配合微信支付工具库 wxpay_utility 使用,请参考Go

1package main
2
3import (
4 "bytes"
5 "demo/wxpay_utility"
6 "encoding/json"
7 "fmt"
8 "net/http"
9 "net/url"
10)
11
12func main() {
13
14 config, err := wxpay_utility.CreateMchConfig(
15 "19xxxxxxxx",
16 "1DDE55AD98Exxxxxxxxxx",
17 "/path/to/apiclient_key.pem",
18 "PUB_KEY_ID_xxxxxxxxxxxxx",
19 "/path/to/wxp_pub.pem",
20 )
21 if err != nil {
22 fmt.Println(err)
23 return
24 }
25
26 request := &CloseAdvertisingShowRequest{
27 SubMchid: wxpay_utility.String("1900000109"),
28 }
29
30 err = CloseAdvertisingShow(config, request)
31 if err != nil {
32 fmt.Printf("请求失败: %+v\n", err)
33
34 return
35 }
36
37
38 fmt.Println("请求成功")
39}
40
41func CloseAdvertisingShow(config *wxpay_utility.MchConfig, request *CloseAdvertisingShowRequest) (err error) {
42 const (
43 host = "https://api.mch.weixin.qq.com"
44 method = "POST"
45 path = "/v3/goldplan/merchants/close-advertising-show"
46 )
47
48 reqUrl, err := url.Parse(fmt.Sprintf("%s%s", host, path))
49 if err != nil {
50 return err
51 }
52 reqBody, err := json.Marshal(request)
53 if err != nil {
54 return err
55 }
56 httpRequest, err := http.NewRequest(method, reqUrl.String(), bytes.NewReader(reqBody))
57 if err != nil {
58 return 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(), reqBody)
64 if err != nil {
65 return 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 err
73 }
74 respBody, err := wxpay_utility.ExtractResponseBody(httpResponse)
75 if err != nil {
76 return err
77 }
78 if httpResponse.StatusCode >= 200 && httpResponse.StatusCode < 300 {
79
80 err = wxpay_utility.ValidateResponse(
81 config.WechatPayPublicKeyId(),
82 config.WechatPayPublicKey(),
83 &httpResponse.Header,
84 respBody,
85 )
86 if err != nil {
87 return err
88 }
89 return nil
90 } else {
91 return wxpay_utility.NewApiException(
92 httpResponse.StatusCode,
93 httpResponse.Header,
94 respBody,
95 )
96 }
97}
98
99type CloseAdvertisingShowRequest struct {
100 SubMchid *string `json:"sub_mchid,omitempty"`
101}
102应答参数
应答示例
204 No Content

1'无应答包体'
2
错误码
公共错误码
|
400 | PARAM_ERROR | 参数错误 | 请根据错误提示正确传入参数 |
400 | INVALID_REQUEST | HTTP 请求不符合微信支付 APIv3 接口规则 | 请参阅 接口规则 |
401 | SIGN_ERROR | 验证不通过 | 请参阅 签名常见问题 |
500 | SYSTEM_ERROR | 系统异常,请稍后重试 | 请稍后重试 |
业务错误码
|
400 | INVALID_REQUEST | 调用方非普通服务商/渠道商 | 只有普通服务商和渠道商才能调用该接口 |
400 | INVALID_REQUEST | 服务商未开通点金计划 | 请在服务商平台先行开通点金计划后再试 |
400 | INVALID_REQUEST | 服务商被处罚中 | 请在服务商平台处理处罚后再试 |
400 | INVALID_REQUEST | 特约商户未开通点金计划 | 该商户暂未开通点金计划,请开通后配置 |
400 | INVALID_REQUEST | 特约商户被处罚中 | 请让特约商户在商户平台处理处罚后再试 |
400 | INVALID_REQUEST | 操作失败 | 操作失败,请稍后重试 |
400 | INVALID_REQUEST | 特约商户信息逻辑错误 | 特约商户号不存在或不是当前服务商的特约商户 |
400 | INVALID_REQUEST | 命中频率限制 | 接口调用速度过快,请降低频率调用该接口 |
400 | INVALID_REQUEST | 商户类型不合法 | 只有普通服务商和普通渠道商才能调用该接口 |
400 | INVALID_REQUEST | 商户关系错误 | 特约商户号不存在或不是当前服务商的特约商户 |
400 | INVALID_REQUEST | 服务商未开通点金计划 | 服务商未开通点金计划,请开通服务商后重试 |
400 | MCH_NOT_EXISTS | 特约商户号不存在 | 特约商户号不存在,请确认特约商户号准确性 |