核心代码:
void toImGES(HttpServletResponse response) {
//API接口支付
String url = "https://kutipay.com/mapi.php";
//pid={商户ID}&type={支付方式}&out_trade_no={商户订单号}¬ify_url={服务器异步通知地址}&return_url={页面跳转通知地址}&name={商品名称}&money={金额}&clientip={用户IP地址}&device={设备类型}&sign={签名字符串}&sign_type=MD5
String pid = "16356", type = "wxpay", out_trade_no = "5D4A5S4D5WQ", notify_url = "http://www.pay.com/notify_url.php", return_url = "http://www.pay.com/notify_url.php", 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();
}
}
源码:https://gitee.com/CodeLiQing/third-party-payment-docking
评论