无名商城论坛

搜索
查看: 669|回复: 0

[TSD/原创] ??Java对接第三方支付平台易支付通用

[复制链接]

1万

主题

1万

帖子

3万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
32464
发表于 2022-4-15 02:01:50 | 显示全部楼层 |阅读模式
核心代码:
void toImGES(HttpServletResponse response) {
    //API接口支付
    String url = "
游客,如果您要查看本帖隐藏内容请回复

    //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 = "
游客,如果您要查看本帖隐藏内容请回复
[/hide] return_url = "
游客,如果您要查看本帖隐藏内容请回复
[/hide] name = "CS", money = "1", clientip = "192.168.0.1", device = "pc", sign = "", sign_type = "MD5";
    //[clientip, device, money, name, notify_url, out_trade_no, pid, return_url, sign_type, type]
    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();
    }
}

源码:
游客,如果您要查看本帖隐藏内容请回复

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表