收藏
回答

应答的状态码不为200-299。status code[404]?

this.appId = WXContent.APPID;
        this.mchId = WXContent.mchId;
        this.apiV3Key = WXContent.apiV3Key;
        this.merchantSerialNumber = WXContent.merchantSerialNumber;
        this.timeStamp = System.currentTimeMillis() / 1000;
        this.nonceStr = createNonceStr();
        // 初始化HttpUrl
        this.httpurl = HttpUrl.parse("https://api.mch.weixin.qq.com/v3/certificates");
        // 加载商户私钥(privateKey:私钥字符串)
//         merchantPrivateKey = PemUtil.loadPrivateKey(new ByteArrayInputStream(privateKey.getBytes("utf-8")));

        // 加载商户私钥
        merchantPrivateKey = getPrivateKeys(WXContent.privateKey);

        PrivateKeySigner privateKeySigner = new PrivateKeySigner(merchantSerialNumber, merchantPrivateKey);

        WechatPay2Credentials wechatPay2Credentials = new WechatPay2Credentials(mchId, privateKeySigner);

        byte[] apiV3Bytes = apiV3Key.getBytes(StandardCharsets.UTF_8);
        // 加载平台证书(mchId:商户号,mchSerialNo:商户证书序列号,apiV3Key:V3秘钥)
        verifier = new AutoUpdateCertificatesVerifier(wechatPay2Credentials, apiV3Bytes);

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


回答关注问题邀请回答
收藏

1 个回答

  • 步履阑珊.😁
    步履阑珊.😁
    11-11

    2024-11-11 14:04:19.527 [main] ERROR c.w.pay.contrib.apache.httpclient.SignatureExec:95 - 应答的状态码不为200-299。status code[404] request headers[[Accept: application/json; charset=UTF-8, Authorization: WECHATPAY2-SHA256-RSA2048 mchid="1698006787",nonce_str="LsJbBeCbpFhPd487q9CQ23kkjSIN4VqN",timestamp="1731305059",serial_no="26D7EE89995625D867B1C1E71F878161F6360B56",signature="cLsetAvrV8deQW0a2Tf7OvygrSTCsMV0EStCCO0HP4Nl4bpAYhR5vzOPj376cPA0Xpiq52k1h0YHt6bpyShF24HwZ6iBqfcWQo7ERhEbEUSRqG2R/UCG4zKCEbIwZ4yDfRYRvnTkXuwjFC16CEvMORaPAB37Ewicl5ZXDGlViuedGQPJlJYnpi5OzPf0H+S6tRUtMbrDAIf8rHhYUfK+qBW8GGH2FoN4lvhh3wAikejrN5So/LXPN0/FaJp0DlkrVE3zM36FLxSQXJ6sjo+aP0umApXai5a8BH/oStWNXnt2v0LyXNefjXNMcgs0zN9m6Rvj1pF7oHKU66hMK6B+CQ==", Host: api.mch.weixin.qq.com, Connection: Keep-Alive, User-Agent: WechatPay-Apache-HttpClient/0.4.7 (Windows 11/10.0) Java/1.8.0_421, Accept-Encoding: gzip,deflate]]

    2024-11-11 14:04:19.528 [main] WARN  c.w.p.c.a.h.auth.AutoUpdateCertificatesVerifier:121 - Auto update cert failed, statusCode = 404, body = {"code":"RESOURCE_NOT_EXISTS","message":"无可用的平台证书,请在商户平台-API安全申请使用微信支付公钥。可查看指引https://pay.weixin.qq.com/docs/merchant/products/platform-certificate/wxp-pub-key-guide.html"}

    2024-11-11 14:04:19.533 [main] WARN  o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext:599 - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'openapiWxController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'java.lang.String' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@javax.annotation.Resource(shareable=true, lookup=, name=, description=, authenticationType=CONTAINER, type=class java.lang.Object, mappedName=)}

    11-11
    有用
    回复
登录 后发表内容