优化支付工具类
This commit is contained in:
parent
6e569971fe
commit
5ae84c4202
|
|
@ -22,6 +22,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -133,7 +134,7 @@ public class JeepayKit {
|
|||
Set<String> keySet = paraMap.keySet();
|
||||
int i = 0;
|
||||
for(String key:keySet) {
|
||||
urlParam.append(key).append("=").append( paraMap.get(key) == null ? "" : paraMap.get(key) );
|
||||
urlParam.append(key).append("=").append( paraMap.get(key) == null ? "" : doEncode(paraMap.get(key).toString()) );
|
||||
if(++i == keySet.size()) {
|
||||
break;
|
||||
}
|
||||
|
|
@ -142,6 +143,13 @@ public class JeepayKit {
|
|||
return urlParam.toString();
|
||||
}
|
||||
|
||||
static String doEncode(String str) {
|
||||
if(str.contains("+")) {
|
||||
return URLEncoder.encode(str);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/** 校验微信/支付宝二维码是否符合规范, 并根据支付类型返回对应的支付方式 **/
|
||||
public static String getPayWayCodeByBarCode(String barCode){
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.jeequan.jeepay.pay.channel.xxpay;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
|
@ -16,6 +17,7 @@ import java.util.Map;
|
|||
* @site https://www.jeequan.com
|
||||
* @date 2021/9/20 10:09
|
||||
*/
|
||||
@Slf4j
|
||||
public class XxpayKit {
|
||||
|
||||
private static String encodingCharset = "UTF-8";
|
||||
|
|
@ -42,6 +44,7 @@ public class XxpayKit {
|
|||
}
|
||||
String result = sb.toString();
|
||||
result += "key=" + key;
|
||||
log.info("signStr:{}", result);
|
||||
result = md5(result, encodingCharset).toUpperCase();
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue