Closed wcp1230 closed 9 years ago
没有设置 openid 参数
底下这段是我运行的代码,我看了一下有设置了 openid 参数不过依然出现 "签名错误" 应该如何解决?
Unifiedorder unifiedorder = new Unifiedorder();
unifiedorder.setAppid(appid);
unifiedorder.setMch_id(mchid);
unifiedorder.setNonce_str(UUID.randomUUID().toString().toString().replace("-", ""));
unifiedorder.setOpenid(session.openid);
unifiedorder.setBody("this_is_english");
unifiedorder.setOut_trade_no("123456");
unifiedorder.setTotal_fee("1");//单位分
unifiedorder.setSpbill_create_ip(request.getRemoteAddr());//IP
unifiedorder.setNotify_url("http://test.mycompany.com/imis/market/notify");
unifiedorder.setTrade_type("JSAPI");//JSAPI,NATIVE,APP,WAP
// 统一下单,生成预支付订单
UnifiedorderResult unifiedorderResult = PayMchAPI.payUnifiedorder(unifiedorder,key);
解决了, 我没去商户平台设置API密钥, 设置后正常
Unifiedorder unifiedorder = new Unifiedorder(); unifiedorder.setAppid(appid); unifiedorder.setMch_id(mch_id); unifiedorder.setNonce_str(UUID.randomUUID().toString().replace("-", "")); //body中数据设置为中文时,无法验证签名通过 unifiedorder.setBody("商品信息"); unifiedorder.setOut_trade_no("123456"); unifiedorder.setTotal_fee("1");//单位分 unifiedorder.setSpbill_create_ip(request.getRemoteAddr());//IP unifiedorder.setNotify_url("http://mydomain.com/test/notify"); unifiedorder.setTrade_type("JSAPI");//JSAPI,NATIVE,APP,WAP