收藏
回答

服务商功能 接入商户进件接口提示"message”:"Http头Authorization值格式错误

部分代码:


String auth = " WECHATPAY2-SHA256-RSA2048 mchid=\""+merchantId+"\",nonce_str=\""+ nonce +"\",signature=\"" +sign  + "\",timestamp=\"" +String.valueOf(timestamp)  + "\",serial_no=\"" + getSerialNumber() + "\"";
//String auth  = PayKit.getAuthorization(merchantId,getSerialNumber(),nonce,String.valueOf(timestamp),sign,"WECHATPAY2-SHA256-RSA2048");
/*String auth = "WECHATPAY2-SHA256-RSA2048 "
        + "mchid=\""+merchantId+"\",timestamp=\""+ timestamp +"\",nonce_str=\"" +nonce  + "\",serial_no=\"" + getSerialNumber() + "\",signature=\"" + sign + "\"";*/

System.out.println("======================");
System.out.println(auth);
System.out.println("======================");
String url = "https://api.mch.weixin.qq.com/v3/applyment4sub/applyment/";
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpPost httppost = new HttpPost(url);
String res = "";
try {
    StringEntity strEntity = new StringEntity(body, "utf-8");
    strEntity.setContentEncoding("UTF-8");
    strEntity.setContentType("application/json");


    //下面几个Header必须设置
    httppost.addHeader("Authorization", auth);

    httppost.addHeader("Content-Type", "application/json");
    httppost.addHeader("Accept", "application/json");
    //这里的User-Agent根据自己的实际情况来
   // httppost.addHeader("User-Agent", "WeChatPay-IJPay-HttpClient/4.5 (Windows 10/10.0) Java/1.8.0_221");
    //微信平台证书序列号
    httppost.addHeader("Wechatpay-Serial", getPlatSerialNumber());


===================================

b不知道哪里出了问题了,弄了好久,Authorization应该怎么填?还是应该怎么处理


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

4 个回答

  • risen
    risen
    09-26

    我的Authorization格式是下面这样的

     WECHATPAY2-SHA256-RSA2048 mchid="1685248***",nonce_str="83D393ABA84243EC921697CDAB65E4F8",signature="Lsf2tJc0TgQZe4SNkpw3DPYA7CDqZruEDTsyyc3FEfuTgGkwce2pWdhV8DZNdPCR+XLdazU1XQ2BRpi8lvi+RXIyn5q51TFdl8fD4PKhHnTsMex9et+oKskukR0f2eg3PCX+Xby8WksQ/Fhn3qTFovn/nAhCxv5I8jJUfaGjUgcMr+fu4ir9clD5oDFXdEJPvmFsxggbEwvLjStG/pWnQIgl3NSWCJYCEowNErlFhzSZ0EyoqbSOlURHWKl73Twkw3Gjo+SjTTUOZdQmbzRqB1JOe36anbxhOmiGni2IQIvSOPE357u6LJUphVVAfpYLbnZKK3Mk65ZZ2E+Ohy8PSw==",timestamp="1727312637",serial_no="4CF9FF7FBDF784C1222914607784A0C14F18***"

    <dependency>
       <groupId>com.github.wechatpay-apiv3</groupId>
       <artifactId>wechatpay-java</artifactId>
       <version>0.2.14</version>
    </dependency>
    这个是我导入的包
    
    09-26
    有用
    回复 3
    • risen
      risen
      09-26
      我导入的wechatpay-java-main 这个源码包里面没有商户进件的demo ,按道理应该有个Applyment4subservice,我这没有,谁可以帮忙提供一下,谢谢
      09-26
      回复
    • risen
      risen
      09-26
      结帖,问题已经解决,是不能在浏览器里面访问状态接口,需要调用接口,呵呵 ,
      09-26
      回复
    • risen
      risen
      09-26回复risen
      不过还是,谢谢下面各位大侠
      09-26
      回复
  • 困了不想睡
    困了不想睡
    09-23

    打印出你传的Authorization和文档对下格式 注意空格

    09-23
    有用
    回复
  • Memory (私信不回复)
    Memory (私信不回复)
    09-23

    直接去用sdk吧https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay6_0.shtml

    09-23
    有用
    回复
  • 北望沣渭
    北望沣渭
    09-23

    Gradle


    在你的 build.gradle 文件中加入如下的依赖

    implementation 'com.github.wechatpay-apiv3:wechatpay-java:0.2.14'
    


    Maven


    加入以下依赖

    <dependency>
      <groupId>com.github.wechatpay-apiv3</groupId>
      <artifactId>wechatpay-java</artifactId>
      <version>0.2.14</version>
    </dependency>
    


    参考 https://github.com/wechatpay-apiv3/wechatpay-java

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