Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PayMchAPI.payUnifiedorder 接口中 unifiedorder.setBody(中文),无法验证签名通过 #20

Closed
wcp1230 opened this issue Aug 19, 2015 · 3 comments

Comments

@wcp1230
Copy link

wcp1230 commented Aug 19, 2015

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

    UnifiedorderResult unifiedorderResult = PayMchAPI.payUnifiedorder(unifiedorder,key);

    String json = PayUtil.generateMchPayJsRequestJson(unifiedorderResult.getPrepay_id(), appid, key);
@liyiorg
Copy link
Owner

liyiorg commented Aug 20, 2015

没有设置 openid 参数

@summerwxy
Copy link

底下这段是我运行的代码,我看了一下有设置了 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);

@summerwxy
Copy link

解决了, 我没去商户平台设置API密钥, 设置后正常

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants