无标题文章

 Gson gson = new Gson();
                            OkHttpClient client = new OkHttpClient();
                            // http://kaifa.huandengpai.com/ajax/pay/wxpay/api/preorder?nid=1&price=0.01&description=aaa&tag=recharge
                            Request req = new Request.Builder()
                                    .url("http://kaifa.huandengpai.com/ajax/pay/wxpay/api/preorder?nid=1&price=0.01&description=aaa&tag=recharge")
                                    .build();
                            Response res = null;
                            try {
                                res = client.newCall(req).execute();
                                if (res.isSuccessful()) {
                                    WxPay wxPay = gson.fromJson(res.body().charStream(),WxPay.class);
                                    String appId = wxPay.getData().getAppid();
                                    String partnerId = wxPay.getData().getPartnerid();
                                    String prepayId = wxPay.getData().getPrepayid();
                                    String nonceStr = wxPay.getData().getNoncestr();
                                    String sign = wxPay.getData().getSign();
                                    String timeStamp = String.valueOf(wxPay.getData().getTimestamp());

                                    PayReq request = new PayReq();
                                    request.appId = appId;
                                    request.partnerId = partnerId;
                                    request.prepayId= prepayId;
                                    request.packageValue = "Sign=WXPay";
                                    request.nonceStr= nonceStr;
                                    request.timeStamp= timeStamp;
                                    request.sign= sign;
                                    msgApi.sendReq(request);
                                }
                            } catch (IOException e) {
                                e.printStackTrace();
                            }

                        }
                    }).start();

你可能感兴趣的:(无标题文章)