收藏
回答

分账业务,调用分账接口,能正常调用,但是报错,找不到原因, 大佬帮忙看看

Java SDK

ResponseEntityProxy{[Content-Type: application/json; charset=utf-8,Content-Length: 71,Chunked: false]} 返回体 的String字符串

代码:

CertificatesManager certificatesManager = CertificatesManager.getInstance();
// 向证书管理器增加需要自动更新平台证书的商户信息
certificatesManager.putMerchant(merchantId, new WechatPay2Credentials(merchantId,
        new PrivateKeySigner(merchantSerialNumber, merchantPrivateKey)), apiV3.getBytes(StandardCharsets.UTF_8));
// ... 若有多个商户号,可继续调用putMerchant添加商户信息

// 从证书管理器中获取verifier
Verifier verifier = certificatesManager.getVerifier(merchantId);
WechatPayHttpClientBuilder builder = WechatPayHttpClientBuilder.create()
        .withMerchant(merchantId, merchantSerialNumber, merchantPrivateKey)
        .withValidator(new WechatPay2Validator(verifier));
// ... 接下来,你仍然可以通过builder设置各种参数,来配置你的HttpClient

// 通过WechatPayHttpClientBuilder构造的HttpClient,会自动的处理签名和验签,并进行证书自动更新
CloseableHttpClient httpClient = builder.build();

HttpPost httpPost = new HttpPost(url);

httpPost.setHeader("Content-Type", "application/json");
HttpEntity entity = new StringEntity(json, StandardCharsets.UTF_8);
httpPost.setEntity(entity);

try {
    CloseableHttpResponse response = httpClient.execute(httpPost);
    return response;


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

1 个回答

  • Memory
    Memory
    2023-07-31

    报错什么?

    2023-07-31
    有用 1
    回复 9
    • 消失的海
      消失的海
      2023-08-01
      2023-08-01
      回复
    • 消失的海
      消失的海
      2023-08-01回复Memory
      [http-nio-8095-exec-1][SignatureExec.java:95] - 应答的状态码不为200-299。status code[400] request headers[[Content-Type: application/json, Accept: application/json, Authorization: WECHATPAY2-SHA256-RSA2048 mchid="1643227312",nonce_str="FUr3kBAppQoyl1YRCoaHSID3vn8bKTlo",timestamp="1690869758",serial_no="1E78C5FCBD84FB0B6F7B624D23A3145009BD38C0",signature="j013NqLfMmoR89yvKTfD66pQWqvMoJesCpP57CDHLMjITCUff15ug1PPAIWmJuhR7tuEFirjQK86sOoxcCraIpdKT4/qu1V5JSKmc4XRXFgHoYO51EUbIZqV4Tmy3pYTei2ZuP9/jeWvguDsQ5A98KSo2gp5UdU4DEuTitX72UmGHodTA1KikrrIvcPun2k9Nyk49oZTa3mwh5dG4D3+ufzdavOehYhxwNoccaDYUbaAY6dCTzV+9cFkM9SNITZ6+uuQm9p/e3RaObAj1JdADUFnK+RqCRcHrwoh8P2zry4mAdKMD6M5/SmG68TZETyJ44O4+1B9+iz+owlzdZaqZQ==", Content-Length: 308, Host: api.mch.weixin.qq.com, Connection: Keep-Alive, User-Agent: WechatPay-Apache-HttpClient/0.4.9 (Windows 10/10.0) Java/1.8.0_271, Accept-Encoding: gzip,deflate]]
      2023-08-01
      回复
    • 消失的海
      消失的海
      2023-08-01
      大佬 刚刚那个搞错了
      2023-08-01
      回复
    • 消失的海
      消失的海
      2023-08-01
      ResponseEntityProxy{[Content-Type: application/json; charset=utf-8,Content-Length: 71,Chunked: false]}
      2023-08-01
      回复
    • 消失的海
      消失的海
      2023-08-01
      我用postman调试过 ,也是报错 
      {
      code:SIGN_ERROR;
      ;messageHttp头Authorization值格式错误,请参考《微信支付商户REST API签名规则》
      ;}
      2023-08-01
      回复
    查看更多(4)
登录 后发表内容