67,512
社区成员
发帖
与我相关
我的任务
分享
//AlipayConfig.private_key, 这个私钥已经用了几个月了,用在支付功能上面,支付功能签名都是正常的
//zfbGy 支付宝公钥我已经换过几个了,开发平台公钥,合作伙伴公钥,开发者公钥,我全试了,都返回同一个错误
AlipayClient alipayClient = new DefaultAlipayClient(
"https://openapi.alipay.com/gateway.do", "2016081001726566",
AlipayConfig.private_key, "json", "UTF-8", zfbGy);
AlipayTradeRefundRequest request = new AlipayTradeRefundRequest();
request.setBizContent("{" +
" \"out_trade_no\":\"1480398912492\"," +
" \"trade_no\":\"2016113021001004690245950007\"," +
" \"refund_amount\":\"0.01\"," +
" \"refund_reason\":\"ttt1\"," +
" \"out_request_no\":\"HZ01RF001\"," +
" \"operator_id\":\"OP001\"," +
" \"store_id\":\"NJ_S_001\"," +
" \"terminal_id\":\"NJ_T_001\"" +
" }");
AlipayTradeRefundResponse response = alipayClient.execute(request);
log.info("code:" + response.getCode() + ",subCode:"
+ response.getSubCode() + ",msg:" + response.getMsg()
+ ",subMsg:" + response.getSubMsg());
Map<String, String> list = new HashMap<String, String>();
list.put("app_id", "2016081001726566");
list.put("method", "alipay.trade.refund");
list.put("format", "json");
list.put("charset", "utf-8");
list.put("sign_type", "RSA");
list.put("timestamp", Util.getTime(0));//这里得到的时间是:2016-12-01 00:00:00 这种格式
list.put("version", "1.0");
String biz_content = "{\"out_trade_no\":1480398912492,\"refund_amount\":0.01}";
list.put("biz_content", biz_content);
Map<String, String> sPara = AlipayCore.paraFilter(list);
String mSign = AlipaySubmit.buildRequestMysign(sPara);
log.error("mSign "+mSign+","+sPara);
try {
mSign = URLEncoder.encode(mSign, "UTF-8");
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
}
String url = "https://openapi.alipay.com/gateway.do";
//将签名添加到参数中去
list.put("sign", mSign);
NetworkBean networkBean = new NetworkBean();
networkBean.setUrl(url);
Map<String , Object> param = new TreeMap<String, Object>(list);
networkBean.setParams(param);
//封装调用接口
HttpClientManager.getInstance().sendRequest(url,param, networkBean);;
log.error("zfbResund result:"+networkBean.getResult());
返回结果:
2016-12-01 09:45:53,775 ERROR [com.yufu.web.api.user.UserZf] - zfbResund result:{"alipay_trade_refund_response":{"code":"40002","msg":"Invalid Arguments","sub_code":"isv.invalid-signature","sub_msg":"鏍骁?},"sign":"aUududgICSy+Wr5NppUHX3FedZeQJCZ+L+xYy7q/TwwXLT5PEkF1PGlbG8hohV0kLZO9iFkWt7mhJeozz5GAp9cqVCnvEdiOT1ausq1EdBXIWF4kPb8C2ssoq6OpgBoHgd+cPbpaekbwbyHxWIHvfZopDUCG+G8aTUxJjLrTVsY="}
请问这是什么原因,支付宝退款和支付的私钥难道不是同一个?