|
@@ -220,7 +220,7 @@ public abstract class AbstractAlipayService extends AbstractPayService { |
|
@@ -220,7 +220,7 @@ public abstract class AbstractAlipayService extends AbstractPayService { |
220
|
bizJson.put("out_trade_no", orderCode);
|
220
|
bizJson.put("out_trade_no", orderCode);
|
221
|
params.put("biz_content", bizJson.toJSONString());
|
221
|
params.put("biz_content", bizJson.toJSONString());
|
222
|
|
222
|
|
223
|
- String preSignStr = getOpenApiSignString(params, false);
|
223
|
+ String preSignStr = StringConvertUtils.covertToStrIgnoreSign(params);
|
224
|
params.put("sign", helper().signWithRsa(preSignStr, StandardCharsets.UTF_8.name()));
|
224
|
params.put("sign", helper().signWithRsa(preSignStr, StandardCharsets.UTF_8.name()));
|
225
|
return params;
|
225
|
return params;
|
226
|
}
|
226
|
}
|
|
@@ -243,7 +243,7 @@ public abstract class AbstractAlipayService extends AbstractPayService { |
|
@@ -243,7 +243,7 @@ public abstract class AbstractAlipayService extends AbstractPayService { |
243
|
bizJson.put("out_biz_no", orderCode);
|
243
|
bizJson.put("out_biz_no", orderCode);
|
244
|
params.put("biz_content", bizJson.toJSONString());
|
244
|
params.put("biz_content", bizJson.toJSONString());
|
245
|
|
245
|
|
246
|
- String preSignStr = getOpenApiSignString(params, false);
|
246
|
+ String preSignStr = StringConvertUtils.covertToStrIgnoreSign(params);
|
247
|
params.put("sign", helper().signWithRsa(preSignStr, StandardCharsets.UTF_8.name()));
|
247
|
params.put("sign", helper().signWithRsa(preSignStr, StandardCharsets.UTF_8.name()));
|
248
|
return params;
|
248
|
return params;
|
249
|
}
|
249
|
}
|
|
@@ -281,7 +281,7 @@ public abstract class AbstractAlipayService extends AbstractPayService { |
|
@@ -281,7 +281,7 @@ public abstract class AbstractAlipayService extends AbstractPayService { |
281
|
|
281
|
|
282
|
params.put("biz_content", bizJson.toJSONString());
|
282
|
params.put("biz_content", bizJson.toJSONString());
|
283
|
|
283
|
|
284
|
- String preSignStr = getOpenApiSignString(params, false);
|
284
|
+ String preSignStr = StringConvertUtils.covertToStrIgnoreSign(params);
|
285
|
String sign = helper().signWithRsa(preSignStr, StandardCharsets.UTF_8.name());
|
285
|
String sign = helper().signWithRsa(preSignStr, StandardCharsets.UTF_8.name());
|
286
|
params.put("sign", URLEncoder.encode(sign));
|
286
|
params.put("sign", URLEncoder.encode(sign));
|
287
|
|
287
|
|
|
@@ -353,8 +353,11 @@ public abstract class AbstractAlipayService extends AbstractPayService { |
|
@@ -353,8 +353,11 @@ public abstract class AbstractAlipayService extends AbstractPayService { |
353
|
|
353
|
|
354
|
params.put("biz_content", bizJson.toJSONString());
|
354
|
params.put("biz_content", bizJson.toJSONString());
|
355
|
|
355
|
|
356
|
- String preSignStr = getOpenApiSignString(params, false);
|
356
|
+ String preSignStr = StringConvertUtils.covertToStrIgnoreSign(params);
|
|
|
357
|
+
|
357
|
String sign = helper().signWithRsa(preSignStr, StandardCharsets.UTF_8.name());
|
358
|
String sign = helper().signWithRsa(preSignStr, StandardCharsets.UTF_8.name());
|
|
|
359
|
+
|
|
|
360
|
+ logger.debug("preSignStr {}, sign {}", preSignStr, sign);
|
358
|
params.put("sign", URLEncoder.encode(sign));
|
361
|
params.put("sign", URLEncoder.encode(sign));
|
359
|
|
362
|
|
360
|
// 对biz_content进行encode
|
363
|
// 对biz_content进行encode
|
|
@@ -396,35 +399,6 @@ public abstract class AbstractAlipayService extends AbstractPayService { |
|
@@ -396,35 +399,6 @@ public abstract class AbstractAlipayService extends AbstractPayService { |
396
|
return json;
|
399
|
return json;
|
397
|
}
|
400
|
}
|
398
|
|
401
|
|
399
|
- /**
|
|
|
400
|
- * 获取openapi支付宝待签名字符串
|
|
|
401
|
- *
|
|
|
402
|
- * @param paramsMap
|
|
|
403
|
- * @return
|
|
|
404
|
- */
|
|
|
405
|
- public static String getOpenApiSignString(Map<String, String> paramsMap, boolean ignoreSignType) {
|
|
|
406
|
- if (null == paramsMap) {
|
|
|
407
|
- return "";
|
|
|
408
|
- }
|
|
|
409
|
- //使用SortedMap将参数按名称的字典序排队,且滤去签名字段、空值字段
|
|
|
410
|
- SortedMap<String, String> sortMap = new TreeMap<String, String>();
|
|
|
411
|
- for (Map.Entry<String, String> entry : paramsMap.entrySet()) {
|
|
|
412
|
- if ("sign".equalsIgnoreCase(entry.getKey())) {
|
|
|
413
|
- continue;
|
|
|
414
|
- }
|
|
|
415
|
-
|
|
|
416
|
- if (ignoreSignType && "sign_type".equalsIgnoreCase(entry.getKey())) {
|
|
|
417
|
- continue;
|
|
|
418
|
- }
|
|
|
419
|
-
|
|
|
420
|
- if (StringUtils.isEmpty(entry.getValue())) {
|
|
|
421
|
- continue;
|
|
|
422
|
- }
|
|
|
423
|
- sortMap.put(entry.getKey(), entry.getValue());
|
|
|
424
|
- }
|
|
|
425
|
-
|
|
|
426
|
- return StringConvertUtils.covertToStr(sortMap);
|
|
|
427
|
- }
|
|
|
428
|
|
402
|
|
429
|
|
403
|
|
430
|
public PaymentData getPaymentData(Map<String, String> params) {
|
404
|
public PaymentData getPaymentData(Map<String, String> params) {
|
|
@@ -499,7 +473,7 @@ public abstract class AbstractAlipayService extends AbstractPayService { |
|
@@ -499,7 +473,7 @@ public abstract class AbstractAlipayService extends AbstractPayService { |
499
|
}
|
473
|
}
|
500
|
|
474
|
|
501
|
public boolean notifyVerifyMApi(Map<String, String> params) {
|
475
|
public boolean notifyVerifyMApi(Map<String, String> params) {
|
502
|
- String preSignStr = StringConvertUtils.covertToStr(params);
|
476
|
+ String preSignStr = StringConvertUtils.covertToStrIgnoreSignAndType(params);
|
503
|
return helper().verifyWithMapiRsa(preSignStr, StandardCharsets.UTF_8.name(), params.get("sign"));
|
477
|
return helper().verifyWithMapiRsa(preSignStr, StandardCharsets.UTF_8.name(), params.get("sign"));
|
504
|
}
|
478
|
}
|
505
|
|
479
|
|
|
@@ -584,23 +558,13 @@ public abstract class AbstractAlipayService extends AbstractPayService { |
|
@@ -584,23 +558,13 @@ public abstract class AbstractAlipayService extends AbstractPayService { |
584
|
bizJson.put("out_request_no", refundNo);
|
558
|
bizJson.put("out_request_no", refundNo);
|
585
|
params.put("biz_content", bizJson.toJSONString());
|
559
|
params.put("biz_content", bizJson.toJSONString());
|
586
|
|
560
|
|
587
|
- String preSignStr = getOpenApiSignString(params, false);
|
561
|
+ String preSignStr = StringConvertUtils.covertToStrIgnoreSign(params);
|
588
|
params.put("sign", helper().signWithRsa(preSignStr, StandardCharsets.UTF_8.name()));
|
562
|
params.put("sign", helper().signWithRsa(preSignStr, StandardCharsets.UTF_8.name()));
|
589
|
|
563
|
|
590
|
return params;
|
564
|
return params;
|
591
|
}
|
565
|
}
|
592
|
|
566
|
|
593
|
|
567
|
|
594
|
- /**
|
|
|
595
|
- * 生成RSA签名
|
|
|
596
|
- *
|
|
|
597
|
- * @param paramsMap
|
|
|
598
|
- * @return
|
|
|
599
|
- */
|
|
|
600
|
- public String rsaSign(Map<String, String> paramsMap) {
|
|
|
601
|
- String preSignStr = StringConvertUtils.covertToStr(paramsMap);
|
|
|
602
|
- return helper().signWithRsa(preSignStr, StandardCharsets.UTF_8.name());
|
|
|
603
|
- }
|
|
|
604
|
|
568
|
|
605
|
/**
|
569
|
/**
|
606
|
* 生成RSA签名
|
570
|
* 生成RSA签名
|
|
@@ -645,7 +609,7 @@ public abstract class AbstractAlipayService extends AbstractPayService { |
|
@@ -645,7 +609,7 @@ public abstract class AbstractAlipayService extends AbstractPayService { |
645
|
* @return
|
609
|
* @return
|
646
|
*/
|
610
|
*/
|
647
|
public boolean verify(Map<String, String> paramsMap) {
|
611
|
public boolean verify(Map<String, String> paramsMap) {
|
648
|
- String preSignStr = StringConvertUtils.covertToStr(paramsMap);
|
612
|
+ String preSignStr = StringConvertUtils.covertToStrIgnoreSignAndType(paramsMap);
|
649
|
return helper().verify(preSignStr, StandardCharsets.UTF_8.name(), paramsMap.get("sign"));
|
613
|
return helper().verify(preSignStr, StandardCharsets.UTF_8.name(), paramsMap.get("sign"));
|
650
|
}
|
614
|
}
|
651
|
|
615
|
|
|
@@ -720,11 +684,11 @@ public abstract class AbstractAlipayService extends AbstractPayService { |
|
@@ -720,11 +684,11 @@ public abstract class AbstractAlipayService extends AbstractPayService { |
720
|
params.put("_input_charset", "utf-8");
|
684
|
params.put("_input_charset", "utf-8");
|
721
|
params.put("batch_no", transferOrderCode);
|
685
|
params.put("batch_no", transferOrderCode);
|
722
|
params.put("email", abstractAlipayConfig().email());
|
686
|
params.put("email", abstractAlipayConfig().email());
|
723
|
- String preSignStr = getOpenApiSignString(params, false);
|
687
|
+ String preSignStr = StringConvertUtils.covertToStrIgnoreSign(params);
|
724
|
String sign = helper().signWithMapiRsa(preSignStr, "utf-8");
|
688
|
String sign = helper().signWithMapiRsa(preSignStr, "utf-8");
|
725
|
params.put("sign", URLEncoder.encode(sign));
|
689
|
params.put("sign", URLEncoder.encode(sign));
|
726
|
params.put("sign_type", "RSA");
|
690
|
params.put("sign_type", "RSA");
|
727
|
- return StringConvertUtils.covertToStr(params);
|
691
|
+ return StringConvertUtils.covertToStrIgnoreSignAndType(params);
|
728
|
}
|
692
|
}
|
729
|
|
693
|
|
730
|
} |
694
|
} |