...
|
...
|
@@ -220,7 +220,7 @@ public abstract class AbstractAlipayService extends AbstractPayService { |
|
|
bizJson.put("out_trade_no", orderCode);
|
|
|
params.put("biz_content", bizJson.toJSONString());
|
|
|
|
|
|
String preSignStr = getOpenApiSignString(params, false);
|
|
|
String preSignStr = StringConvertUtils.covertToStrIgnoreSign(params);
|
|
|
params.put("sign", helper().signWithRsa(preSignStr, StandardCharsets.UTF_8.name()));
|
|
|
return params;
|
|
|
}
|
...
|
...
|
@@ -243,7 +243,7 @@ public abstract class AbstractAlipayService extends AbstractPayService { |
|
|
bizJson.put("out_biz_no", orderCode);
|
|
|
params.put("biz_content", bizJson.toJSONString());
|
|
|
|
|
|
String preSignStr = getOpenApiSignString(params, false);
|
|
|
String preSignStr = StringConvertUtils.covertToStrIgnoreSign(params);
|
|
|
params.put("sign", helper().signWithRsa(preSignStr, StandardCharsets.UTF_8.name()));
|
|
|
return params;
|
|
|
}
|
...
|
...
|
@@ -281,7 +281,7 @@ public abstract class AbstractAlipayService extends AbstractPayService { |
|
|
|
|
|
params.put("biz_content", bizJson.toJSONString());
|
|
|
|
|
|
String preSignStr = getOpenApiSignString(params, false);
|
|
|
String preSignStr = StringConvertUtils.covertToStrIgnoreSign(params);
|
|
|
String sign = helper().signWithRsa(preSignStr, StandardCharsets.UTF_8.name());
|
|
|
params.put("sign", URLEncoder.encode(sign));
|
|
|
|
...
|
...
|
@@ -353,8 +353,11 @@ public abstract class AbstractAlipayService extends AbstractPayService { |
|
|
|
|
|
params.put("biz_content", bizJson.toJSONString());
|
|
|
|
|
|
String preSignStr = getOpenApiSignString(params, false);
|
|
|
String preSignStr = StringConvertUtils.covertToStrIgnoreSign(params);
|
|
|
|
|
|
String sign = helper().signWithRsa(preSignStr, StandardCharsets.UTF_8.name());
|
|
|
|
|
|
logger.debug("preSignStr {}, sign {}", preSignStr, sign);
|
|
|
params.put("sign", URLEncoder.encode(sign));
|
|
|
|
|
|
// 对biz_content进行encode
|
...
|
...
|
@@ -396,35 +399,6 @@ public abstract class AbstractAlipayService extends AbstractPayService { |
|
|
return json;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取openapi支付宝待签名字符串
|
|
|
*
|
|
|
* @param paramsMap
|
|
|
* @return
|
|
|
*/
|
|
|
public static String getOpenApiSignString(Map<String, String> paramsMap, boolean ignoreSignType) {
|
|
|
if (null == paramsMap) {
|
|
|
return "";
|
|
|
}
|
|
|
//使用SortedMap将参数按名称的字典序排队,且滤去签名字段、空值字段
|
|
|
SortedMap<String, String> sortMap = new TreeMap<String, String>();
|
|
|
for (Map.Entry<String, String> entry : paramsMap.entrySet()) {
|
|
|
if ("sign".equalsIgnoreCase(entry.getKey())) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
if (ignoreSignType && "sign_type".equalsIgnoreCase(entry.getKey())) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isEmpty(entry.getValue())) {
|
|
|
continue;
|
|
|
}
|
|
|
sortMap.put(entry.getKey(), entry.getValue());
|
|
|
}
|
|
|
|
|
|
return StringConvertUtils.covertToStr(sortMap);
|
|
|
}
|
|
|
|
|
|
|
|
|
public PaymentData getPaymentData(Map<String, String> params) {
|
...
|
...
|
@@ -499,7 +473,7 @@ public abstract class AbstractAlipayService extends AbstractPayService { |
|
|
}
|
|
|
|
|
|
public boolean notifyVerifyMApi(Map<String, String> params) {
|
|
|
String preSignStr = StringConvertUtils.covertToStr(params);
|
|
|
String preSignStr = StringConvertUtils.covertToStrIgnoreSignAndType(params);
|
|
|
return helper().verifyWithMapiRsa(preSignStr, StandardCharsets.UTF_8.name(), params.get("sign"));
|
|
|
}
|
|
|
|
...
|
...
|
@@ -584,23 +558,13 @@ public abstract class AbstractAlipayService extends AbstractPayService { |
|
|
bizJson.put("out_request_no", refundNo);
|
|
|
params.put("biz_content", bizJson.toJSONString());
|
|
|
|
|
|
String preSignStr = getOpenApiSignString(params, false);
|
|
|
String preSignStr = StringConvertUtils.covertToStrIgnoreSign(params);
|
|
|
params.put("sign", helper().signWithRsa(preSignStr, StandardCharsets.UTF_8.name()));
|
|
|
|
|
|
return params;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 生成RSA签名
|
|
|
*
|
|
|
* @param paramsMap
|
|
|
* @return
|
|
|
*/
|
|
|
public String rsaSign(Map<String, String> paramsMap) {
|
|
|
String preSignStr = StringConvertUtils.covertToStr(paramsMap);
|
|
|
return helper().signWithRsa(preSignStr, StandardCharsets.UTF_8.name());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 生成RSA签名
|
...
|
...
|
@@ -645,7 +609,7 @@ public abstract class AbstractAlipayService extends AbstractPayService { |
|
|
* @return
|
|
|
*/
|
|
|
public boolean verify(Map<String, String> paramsMap) {
|
|
|
String preSignStr = StringConvertUtils.covertToStr(paramsMap);
|
|
|
String preSignStr = StringConvertUtils.covertToStrIgnoreSignAndType(paramsMap);
|
|
|
return helper().verify(preSignStr, StandardCharsets.UTF_8.name(), paramsMap.get("sign"));
|
|
|
}
|
|
|
|
...
|
...
|
@@ -720,11 +684,11 @@ public abstract class AbstractAlipayService extends AbstractPayService { |
|
|
params.put("_input_charset", "utf-8");
|
|
|
params.put("batch_no", transferOrderCode);
|
|
|
params.put("email", abstractAlipayConfig().email());
|
|
|
String preSignStr = getOpenApiSignString(params, false);
|
|
|
String preSignStr = StringConvertUtils.covertToStrIgnoreSign(params);
|
|
|
String sign = helper().signWithMapiRsa(preSignStr, "utf-8");
|
|
|
params.put("sign", URLEncoder.encode(sign));
|
|
|
params.put("sign_type", "RSA");
|
|
|
return StringConvertUtils.covertToStr(params);
|
|
|
return StringConvertUtils.covertToStrIgnoreSignAndType(params);
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|