| | |
| | | import cn.hutool.http.*; |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.order.util.payment.model.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | |
| | | * 商户号 |
| | | */ |
| | | private static final String merchantNo = "888122600004175"; |
| | | /** |
| | | * 平台-报备商户号 |
| | | */ |
| | | private static final String sysTradeMerchantNo = "777168500885852"; |
| | | /** |
| | | * 支付回调地址 |
| | | */ |
| | |
| | | //APPID |
| | | body.put("q7_AppId", appId); |
| | | //报备商户号 |
| | | body.put("qa_TradeMerchantNo", tradeMerchantNo); |
| | | body.put("qa_TradeMerchantNo", StringUtils.isNotEmpty(tradeMerchantNo) ? tradeMerchantNo : sysTradeMerchantNo); |
| | | String sign = null; |
| | | try { |
| | | sign = sign(body); |
| | |
| | | //退款金额 |
| | | body.put("p4_RefundAmount", refundAmount); |
| | | //服务器异步通知地址 |
| | | body.put("p6_NotifyUrl", notifyUrl); |
| | | body.put("p6_NotifyUrl", callbackUrl + notifyUrl); |
| | | String sign = null; |
| | | try { |
| | | sign = sign(body); |
| | |
| | | |
| | | |
| | | |
| | | 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()); |
| | | } |
| | | }); |
| | | // 构造签名键值对的格式 |