| | |
| | | package com.ruoyi.order.util.payment; |
| | | |
| | | import cn.hutool.http.ContentType; |
| | | import cn.hutool.http.HttpRequest; |
| | | import cn.hutool.http.HttpResponse; |
| | | import cn.hutool.http.HttpUtil; |
| | |
| | | public static SinglePayResult singlePay(SinglePay singlePay){ |
| | | String url = "https://www.joinpay.com/payment/pay/singlePay"; |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | | post.contentType(ContentType.JSON.toString()); |
| | | JSONObject body = new JSONObject(); |
| | | //商户编号 |
| | | body.put("userNo", merchantNo); |
| | |
| | | public static SinglePayQueryResult singlePayQuery(String merchantOrderNo){ |
| | | String url = "https://www.joinpay.com/payment/pay/singlePayQuery"; |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | | post.contentType(ContentType.JSON.toString()); |
| | | JSONObject body = new JSONObject(); |
| | | //商户编号 |
| | | body.put("userNo", merchantNo); |
| | |
| | | public static AccountBalanceQueryResult accountBalanceQuery(){ |
| | | String url = "https://www.joinpay.com/payment/pay/accountBalanceQuery"; |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | | post.contentType(ContentType.JSON.toString()); |
| | | JSONObject body = new JSONObject(); |
| | | //商户编号 |
| | | body.put("userNo", merchantNo); |
| | |
| | | |
| | | |
| | | |
| | | public static String sign(JSONObject body) throws Exception{ |
| | | public static String sign(JSONObject body) { |
| | | Set<Map.Entry<String, Object>> entries = body.entrySet(); |
| | | List<Map.Entry<String, Object>> infoIds = new ArrayList<Map.Entry<String, Object>>(entries); |
| | | // 对所有传入参数按照字段名的 ASCII 码从小到大排序(字典序) |
| | | Collections.sort(infoIds, new Comparator<Map.Entry<String, Object>>() { |
| | | public int compare(Map.Entry<String, Object> o1, Map.Entry<String, Object> o2) { |
| | | return (o1.getKey()).toString().compareTo(o2.getKey()); |
| | | return (o1.getKey()).compareTo(o2.getKey()); |
| | | } |
| | | }); |
| | | // 构造签名键值对的格式 |
| | |
| | | return MD5AndKL.MD5(sb.toString()); |
| | | } |
| | | |
| | | |
| | | } |