parent
5e8a27ef34
commit
21a5bdc97d
@ -0,0 +1,70 @@ |
||||
package com.hai.config; |
||||
|
||||
import com.alibaba.fastjson.JSON; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.hai.common.pay.util.sdk.WXPayConstants; |
||||
import com.hai.common.utils.HttpsUtils; |
||||
import com.hai.common.utils.MD5Util; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
|
||||
import java.util.*; |
||||
|
||||
/** |
||||
* 银联支付 |
||||
* @author hurui |
||||
*/ |
||||
public class UnionPayConfig { |
||||
|
||||
public static JSONObject apppayacc() throws Exception { |
||||
Map<String,Object> paramMap = new HashMap<>(); |
||||
/* paramMap.put("channelid", "D01X66666666761"); |
||||
paramMap.put("merid", "531000012972390"); |
||||
paramMap.put("termid", "W1489519"); |
||||
paramMap.put("tradetrace", System.currentTimeMillis()); |
||||
paramMap.put("opt", "dirBankPay"); |
||||
paramMap.put("tradetype", "APP"); |
||||
paramMap.put("tradeamt", "1"); |
||||
paramMap.put("body", "test"); |
||||
paramMap.put("notifyurl", "notifyurl"); |
||||
paramMap.put("returnurl", "returnurl");*/ |
||||
|
||||
paramMap.put("channelid", "D01X66666666761"); |
||||
paramMap.put("merid", "531000012972390"); |
||||
paramMap.put("termid", "W1489519"); |
||||
paramMap.put("tradetrace", System.currentTimeMillis()); |
||||
paramMap.put("opt", "upPreOrder"); |
||||
paramMap.put("tradetype", "APP"); |
||||
paramMap.put("tradeamt", "1"); |
||||
paramMap.put("body", "test"); |
||||
paramMap.put("notifyurl", "notifyurl"); |
||||
|
||||
String reqStr = generateSignature(paramMap, null); |
||||
paramMap.put("sign", MD5Util.encode(generateSignature(paramMap,"sa72ivadl84273dlj2kdaia2idiadik5").getBytes()).toLowerCase()); |
||||
reqStr += "&sign=" + MD5Util.encode(generateSignature(paramMap,"sa72ivadl84273dlj2kdaia2idiadik5").getBytes()).toUpperCase(); |
||||
Map<String,Object> body = new LinkedHashMap<>(); |
||||
body.put("from", reqStr); |
||||
return HttpsUtils.doSmsPost("https://notify-test.eycard.cn:7443/WorthTech_Access_AppPaySystemV2/apppayacc", body, new HashMap<>()); |
||||
} |
||||
|
||||
public static String generateSignature(final Map<String, Object> data, String key){ |
||||
Set<String> keySet = data.keySet(); |
||||
String[] keyArray = keySet.toArray(new String[keySet.size()]); |
||||
Arrays.sort(keyArray); |
||||
StringBuilder sb = new StringBuilder(); |
||||
for (String k : keyArray) { |
||||
if (k.equals(WXPayConstants.FIELD_SIGN)) { |
||||
continue; |
||||
} |
||||
if (StringUtils.isBlank(sb.toString())) { |
||||
sb.append(k).append("=").append(data.get(k)); |
||||
} else { |
||||
sb.append("&").append(k).append("=").append(data.get(k)); |
||||
} |
||||
} |
||||
if (StringUtils.isNotBlank(key)) { |
||||
sb.append("&key=").append(key); |
||||
} |
||||
return sb.toString(); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue