菜鸟猿坠机中 2019-04-25 11:11 采纳率: 20%
浏览 258

服务一直返回端验签失败

public void pay() {
PayWayRecord payWayRecord = psyService.getPayWay(PayWayEnum.TONGTONG.getCode());
Map sendParams = new HashMap<>();
Date date = new Date();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
sendParams.put("app_id", "s100000040");
sendParams.put("terminal_type", " web");
sendParams.put("version", "1.0");
sendParams.put("service", "fosun.sumpay.cashier.web.trade.order.apply");
sendParams.put("timestamp", simpleDateFormat.format(date.getTime()));
sendParams.put("mer_no", "s100000040");
sendParams.put("trade_code", "T0002");
sendParams.put("user_id", "111");
//sendParams.put("mer_id", "100001465");
sendParams.put("order_no", "D100174978");
sendParams.put("order_time", simpleDateFormat.format(date.getTime()));
sendParams.put("order_amount", "100.00");
sendParams.put("need_notify", "1");
sendParams.put("need_return", "0");
sendParams.put("goods_name", "Preety Toy");
sendParams.put("goods_num", "1");
sendParams.put("goods_type", "1");
// sendParams.put("mer_no", "100001465");
sendParams.put("amount", "1");
SignService signService = new SignServiceImpl();
String aesKey = AESUtil.getKey();
sendParams.put("aes_key", aesKey);
System.out.println(sendParams.get("aes_key"));
//sendParams.put("mor_id", "13131");
List keyList = new ArrayList(sendParams.keySet());
Collections.sort(keyList);
StringBuffer sb = new StringBuffer();
for (int i = 0; i < keyList.size(); i++) {
String key = keyList.get(i);
String keyValue = sendParams.get(key);
sb.append(key).append("=").append(keyValue);
if (i < keyList.size() - 1) {
sb.append("&");
}
}
//SignServiceImpl signService=new SignServiceImpl();
String signMsg = signService.signMsg(sb.toString(), pricateKeyPath, password, charset);
System.out.println("签名之后是:" + signMsg);
sendParams.put("sign", signMsg);
sendParams.put("sign_type", "CERT");
FormBody.Builder builder = new FormBody.Builder();
for (String key : sendParams.keySet()) {
builder.add(key, sendParams.get(key));
}
RequestBody formBody = builder.build();
Request request3 = new Request.Builder()
.url(TEST_URL)
.post(formBody)
// .addHeader("Referer","domain")
//.get()
.build();
Response response= null;
try {
response = okHttpClient.newCall(request3).execute();
String returnMsg=response.body().string();
if (response.isSuccessful()){
// boolean ss= signService.verifyMsg(returnMsg, String.valueOf(sb),publicKeyPath);
// logger.info("[tong query] response is {}", ss);
logger.info("[tong query] response is {}", returnMsg);
}else{
logger.error("[tongfu query] failed");
}
} catch (IOException e) {
e.printStackTrace();
}
}

单元测试返回:

2019-04-25 10:55:25.560 INFO 10908 --- [ main] ALL : [tong query] response is {"resp_code":"EG000001","resp_msg":"验签失败"}

这类错误的问题一般是什么情况造成的,希望大佬给点意见

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥35 平滑拟合曲线该如何生成
    • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
    • ¥15 名为“Product”的列已属于此 DataTable
    • ¥15 安卓adb backup备份应用数据失败
    • ¥15 eclipse运行项目时遇到的问题
    • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
    • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
    • ¥15 自己瞎改改,结果现在又运行不了了
    • ¥15 链式存储应该如何解决
    • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站