update:
1. 重构支付宝支付
This commit is contained in:
@@ -10,6 +10,7 @@ import jakarta.servlet.http.HttpServletRequest;
|
|||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.springblade.common.cache.PaymentCache;
|
||||||
import org.springblade.core.log.exception.ServiceException;
|
import org.springblade.core.log.exception.ServiceException;
|
||||||
import org.springblade.core.tool.utils.StringUtil;
|
import org.springblade.core.tool.utils.StringUtil;
|
||||||
import org.springblade.plugin.pay.api.wxpay.IWxPayApiService;
|
import org.springblade.plugin.pay.api.wxpay.IWxPayApiService;
|
||||||
@@ -148,26 +149,26 @@ public class CallbackController {
|
|||||||
try {
|
try {
|
||||||
// 获取支付宝POST过来反馈信息
|
// 获取支付宝POST过来反馈信息
|
||||||
Map<String, String> params = AliPayApiUtil.toMap(request);
|
Map<String, String> params = AliPayApiUtil.toMap(request);
|
||||||
System.out.println("支付宝回调参数:" + params.toString());
|
System.out.println("支付宝回调参数:" + params);
|
||||||
String mchId = params.get("seller_id");
|
String mchId = params.get("seller_id");
|
||||||
String appId = params.get("app_id");
|
String appId = params.get("app_id");
|
||||||
if (StringUtils.isBlank(mchId)) {
|
if (StringUtils.isBlank(mchId)) {
|
||||||
result = "seller_id is not null";
|
result = "seller_id is not null";
|
||||||
AliPayApiUtil.render(response, ContentType.TEXT_PLAIN.getValue(), result, new String[]{"encoding:UTF-8"});
|
AliPayApiUtil.render(response, ContentType.TEXT_PLAIN.getValue(), result, "encoding:UTF-8");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
AliPayAccountConfig aliPayAccountConfig = aliPayAccountConfigService.getInfoByMchIdAndAppId(mchId, appId);
|
AliPayAccountConfig config = PaymentCache.getAliConfig();
|
||||||
if (aliPayAccountConfig == null) {
|
if (config == null) {
|
||||||
result = "该商户号尚未接入";
|
result = "该商户号尚未接入";
|
||||||
AliPayApiUtil.render(response, ContentType.TEXT_PLAIN.getValue(), result, new String[]{"encoding:UTF-8"});
|
AliPayApiUtil.render(response, ContentType.TEXT_PLAIN.getValue(), result, "encoding:UTF-8");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String signType = aliPayAccountConfig.getSignType();
|
String signType = config.getSignType();
|
||||||
String pubKey = aliPayAccountConfig.getPubKey();
|
String pubKey = config.getPubKey();
|
||||||
boolean verify_result = AlipaySignature.rsaCheckV1(params, pubKey, "UTF-8", signType);
|
boolean verify_result = AlipaySignature.rsaCheckV1(params, pubKey, "UTF-8", signType);
|
||||||
if (!verify_result) {
|
if (!verify_result) {
|
||||||
result = "签名验证失败";
|
result = "签名验证失败";
|
||||||
AliPayApiUtil.render(response, ContentType.TEXT_PLAIN.getValue(), result, new String[]{"encoding:UTF-8"});
|
AliPayApiUtil.render(response, ContentType.TEXT_PLAIN.getValue(), result, "encoding:UTF-8");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//支付状态
|
//支付状态
|
||||||
@@ -218,13 +219,13 @@ public class CallbackController {
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
AliPayApiUtil.render(response, ContentType.TEXT_PLAIN.getValue(), result, new String[]{"encoding:UTF-8"});
|
AliPayApiUtil.render(response, ContentType.TEXT_PLAIN.getValue(), result, "encoding:UTF-8");
|
||||||
} catch (AlipayApiException e) {
|
} catch (AlipayApiException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
AliPayApiUtil.render(response, ContentType.TEXT_PLAIN.getValue(), e.getMessage(), new String[]{"encoding:UTF-8"});
|
AliPayApiUtil.render(response, ContentType.TEXT_PLAIN.getValue(), e.getMessage(), "encoding:UTF-8");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
AliPayApiUtil.render(response, ContentType.TEXT_PLAIN.getValue(), e.getMessage(), new String[]{"encoding:UTF-8"});
|
AliPayApiUtil.render(response, ContentType.TEXT_PLAIN.getValue(), e.getMessage(), "encoding:UTF-8");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user