- 普通商户调用单次分账接口一直报错,使用工具校验签名是校验正确通过的,请问这是什么问题?
问题描述: 普通商户调用单次分账接口一直报错,使用工具校验签名是校验正确通过的,请问这是什么问题?请求需要双向证书,请问是我代码加载p12证书有问题吗?还是证书加载错误了? 错误提示: {"chunked":false,"contentLength":476,"contentType":{"buffer":{"empty":false,"full":false},"elements":[{"name":"text/plain","parameterCount":1,"parameters":[{"name":"charset","value":"UTF-8"}]}],"name":"Content-Type","value":"text/plain;charset=UTF-8","valuePos":13},"repeatable":false,"streaming":true} 具体代码如下: // 调用请求单次分账接口必需传的参数 jsonArray.add(jsonObject); List<NameValuePair> nvps = new ArrayList<NameValuePair>(); nvps.add(new BasicNameValuePair("appid",APPID)); //服务商商户号对应服务号的appid nvps.add(new BasicNameValuePair("mch_id",mchId));//服务商商户号 nvps.add(new BasicNameValuePair("nonce_str",nonceStr)); nvps.add(new BasicNameValuePair("out_order_no",profitSharingUuid));//商户系统内部的分账单号 nvps.add(new BasicNameValuePair("receivers",jsonArray.toJSONString())); nvps.add(new BasicNameValuePair("transaction_id",profit.getTransaction_id())); StringBuffer sb = new StringBuffer(); for (NameValuePair nvp : nvps) { sb.append(nvp.getName() + "=" + nvp.getValue() + "&"); } String signA = sb.toString(); String stringSignTemp = signA + "key="+apiV3Key; // key是服务商商户号的密钥 String sign = HMACSHA256(stringSignTemp, apiV3Key);//校验通过 nvps.add(new BasicNameValuePair("sign", sign)); // 把签名后的数据组装成参数 //加载P12证书并POST调用单次请求接口 CloseableHttpResponse response=null; try { KeyStore clientStore = KeyStore.getInstance("PKCS12"); // 读取本机存放的PKCS12证书文件 FileInputStream inputStream =new FileInputStream(certPath); try { // 指定PKCS12的密码(商户ID) clientStore.load(inputStream, certPass.toCharArray()); }finally { inputStream.close(); } SSLContext sslcontext = SSLContexts.custom().loadKeyMaterial(clientStore, certPass.toCharArray()).build(); // 指定TLS版本 SSLConnectionSocketFactory sslsf =new SSLConnectionSocketFactory(sslcontext, new String[]{"TLSv1"}, null, SSLConnectionSocketFactory.getDefaultHostnameVerifier()); // 设置httpclient的SSLSocketFactory CloseableHttpClient httpclient = HttpClients.custom().setSSLSocketFactory(sslsf).build(); try { HttpPost httpost =new HttpPost(url); // 设置响应头信息 httpost.addHeader("Connection", "keep-alive"); httpost.addHeader("Accept", "*/*"); httpost.addHeader("Content-Type", "text/xml"); httpost.addHeader("X-Requested-With", "XMLHttpRequest"); httpost.addHeader("Cache-Control", "max-age=0"); httpost.addHeader("User-Agent", "*"); httpost.setEntity(new StringEntity(data, "UTF-8")); response = httpclient.execute(httpost); }finally { httpclient.close(); }
2021-04-16 - 微信小程序支付异常
微信小程序支付输入支付密码后一直在闪动,最后提示系统繁忙,请稍后再试。 我这边的具体情况是:微信小程序登录得到code,并通过code得到openid,然后通过微信小程序的appid(不是公众号或者移动程序的appid)、商户号mchid等商品信息请求统一下单并获取到了prepay_id,然后将prepay_id、timeStamp、nonceStr、package进行签名,最后微信小程序调起支付,输入支付密码后一直在闪动,最后提示系统繁忙,请稍后再试,请问这种情况是什么原因? [图片][图片][图片][图片]
2021-04-03