微信对接创建代金券批次400

 

       // 加载商户私钥(privateKey:私钥字符串)
        String privateKey = "私钥";
        // 请求地址
        String url = "https://api.mch.weixin.qq.com/v3/marketing/favor/coupon-stocks";
        // 商户号
        String mchId = "1608237***";
        // 商户证书序列号
        String mchSerialNo = "66B1019D93A4F2684D19DA465765BC02A545A***";
        // V3密钥
        String apiV3Key = "slcjyf20210413slcjyf202104136***";

        // 加载商户私钥(privateKey:私钥字符串)
        PrivateKey merchantPrivateKey = PemUtil
                .loadPrivateKey(new ByteArrayInputStream(privateKey.getBytes("utf-8")));

        // 加载平台证书(mchId:商户号,mchSerialNo:商户证书序列号,apiV3Key:V3密钥)
        AutoUpdateCertificatesVerifier verifier = new AutoUpdateCertificatesVerifier(
                new WechatPay2Credentials(mchId, new PrivateKeySigner(mchSerialNo, merchantPrivateKey)),apiV3Key.getBytes("utf-8"));

        // 初始化httpClient
        CloseableHttpClient httpClient = WechatPayHttpClientBuilder.create()
                .withMerchant(mchId, mchSerialNo, merchantPrivateKey)
                .withValidator(new WechatPay2Validator(verifier)).build();

        HttpPost httpPost = new HttpPost(url);

        StringEntity postEntity = new StringEntity(getMap(), "UTF-8");
        postEntity.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE,
                "application/json"));
        httpPost.setEntity(postEntity);
        CloseableHttpResponse response = httpClient.execute(httpPost);
        HttpEntity entity = response.getEntity();
        System.out.println(JSON.toJSONString(entity));
        httpClient.close();
        
{
    "stock_name":"测试微信支付代金券批次",
    "comment":"测试零售批次",
    "belong_merchant":"1608237***",
    "available_begin_time":"2021-04-13T14:00:00.120+08:00",
    "available_end_time":"2021-04-14T23:59:59.120+08:00",
    "stock_use_rule":{
        "max_coupons":10,
        "max_amount":10,
        "max_amount_by_day":10,
        "max_coupons_per_user":5,
        "natural_person_limit":false,
        "prevent_api_abuse":false
    },
    "pattern_info":{
        "description":"测试微信支付营销代金券",
        "merchant_name":"测试微信支付",
        "background_color":"COLOR030"
    },
    "coupon_use_rule":{
        "fixed_normal_coupon":{
            "coupon_amount":1,
            "transaction_minimum":100
        },
        "available_merchants":[
            "1608237904"
        ],
        "combine_use":false
    },
    "no_cash":true,
    "stock_type":"NORMAL",
    "out_request_no":"1608237***202104132001"
}

各位大侠,看我瞅瞅。一直是400,我都把微信官方的json拿出来改了还是不行。

麻烦贴图全部的返回信息,只是状态码没法看的