无名 发表于 2022-4-15 02:01:50

??Java对接第三方支付平台易支付通用

核心代码:
void toImGES(HttpServletResponse response) {
    //API接口支付
    String url = "**** Hidden Message *****
    //pid={商户ID}&type={支付方式}&out_trade_no={商户订单号}&notify_url={服务器异步通知地址}&return_url={页面跳转通知地址}&name={商品名称}&money={金额}&clientip={用户IP地址}&device={设备类型}&sign={签名字符串}&sign_type=MD5
    String pid = "16356", type = "wxpay", out_trade_no = "5D4A5S4D5WQ", notify_url = "**** Hidden Message ***** return_url = "**** Hidden Message ***** name = "CS", money = "1", clientip = "192.168.0.1", device = "pc", sign = "", sign_type = "MD5";
    //
    String mdString = "clientip=" + clientip + "&device=" + device + "&money=" + money + "&name=" + name + "&" +
            "notify_url=" + notify_url + "&out_trade_no=" + out_trade_no + "&pid=" + pid + "&return_url=" + return_url +
            "&type=" + type + "f56f7fe37D753X77WfA5fe3GAE74dw7w";
    sign = MD5.GetMD5Code(mdString);
    System.out.println(sign);
    System.out.println(mdString);
    Map<String, Object> map = new HashMap<>();
    map.put("clientip", clientip);
    map.put("device", device);
    map.put("money", money);
    map.put("name", name);
    map.put("notify_url", notify_url);
    map.put("out_trade_no", out_trade_no);
    map.put("pid", pid);
    map.put("return_url", return_url);
    map.put("sign_type", sign_type);
    map.put("type", type);
    map.put("sign", sign);
    String body = HttpUtil.post(url, map);
    JSONObject jsonObject = new JSONObject(body);
    String wxUrl = (String) jsonObject.get("qrcode");
    try {
      QrConfig config = new QrConfig(300, 300);
      QrCodeUtil.generate(wxUrl, config, "png", response.getOutputStream());
    } catch (IOException e) {
      e.printStackTrace();
    }
}

源码:**** Hidden Message *****
http://cdn.u1.huluxia.com/g4/M03/BA/92/rBAAdmI-4U2AaQ0NAAROa02uA1M353.jpg
页: [1]
查看完整版本: ??Java对接第三方支付平台易支付通用