评论

避坑:特约商户进件 返回 平台证书序列号Wechatpay-Serial错误

平台证书序列号Wechatpay-Serial错误

String signature=getSignature(method,canonicalUrl,jsonData,nonceStr,timestamp);
String authorization="mchid=\"" + wxMchServerConfig.getMchId() + "\","
        + "nonce_str=\"" + nonceStr + "\","
        + "timestamp=\"" + timestamp + "\","
        + "serial_no=\"" + wxMchServerConfig.getSerialNo() + "\","
        + "signature=\"" + signature + "\"";
Map<String,String> headers=new HashMap<>();
headers.put("Authorization","WECHATPAY2-SHA256-RSA2048"+" "+authorization);
headers.put("Content-Type" ,"application/json");
headers.put("User-Agent","WechatPay-TEST-HttpClient");
if(isWxpaySerial){
    //需要实时获取证书
    Certificates certificates=this.getCertificates();
    if(certificates==null)
        throw new WxException("证书获取失败");
    String WechatpaySerial=certificates.getData().get(0).getSerial_no();
    headers.put("Wechatpay-Serial",WechatpaySerial);
}

请注意:

1、header里面的 wechatpay-serial 需要实时获取

2、authorization里的serial_no 我用的是平台里获取的

最后一次编辑于  2020-07-01  
点赞 1
收藏
评论

3 个评论

登录 后发表内容