fix: 修复支付宝支付功能相关问题

- 修复支付接口参数顺序错误,调整商品名称和订单号参数位置
- 修复支付页面HTML返回格式,直接返回Body内容而非序列化字符串
- 添加支付相关接口的权限控制,支付回调接口允许匿名访问
- 优化支付宝回调验签逻辑,保持原始参数顺序避免验签失败
- 增加回调格式错误的异常处理
- 修复商品类型枚举显示名称为英文,新增测试商品类型
- 修正Token服务提示文案中的错别字
- 移除订单更新时不必要的时间字段设置
This commit is contained in:
chenchun
2025-08-13 17:42:13 +08:00
parent 0ba4e3240b
commit f0cf6bf5c8
6 changed files with 28 additions and 13 deletions

View File

@@ -20,7 +20,8 @@ public class AlipayManager : DomainService
/// </summary>
/// <returns></returns>
/// <exception cref="AlipayException"></exception>
public Task<AlipayTradePagePayResponse> PaymentPageAsync(string productName, string orderNumber, decimal totalAmount)
public Task<AlipayTradePagePayResponse> PaymentPageAsync(string productName, string orderNumber,
decimal totalAmount)
{
try
{
@@ -54,12 +55,16 @@ public class AlipayManager : DomainService
/// <exception cref="AlipayException"></exception>
public Task VerifyNotifyAsync(Dictionary<string, string> form)
{
// 注意:不要对参数进行排序,保持支付宝回调的原始参数顺序
// 支付宝的验签需要保持原始参数顺序,排序会导致验签失败
var result = Factory.Payment.Common().VerifyNotify(form);
if (result == false)
{
_logger.LogError($"支付宝支付验签失败,回调参数:{System.Text.Json.JsonSerializer.Serialize(form)}");
throw new AlipayException($"支付宝支付,验签失败");
}
_logger.LogInformation("支付宝回调验签成功");
return Task.CompletedTask;
}
}

View File

@@ -82,8 +82,6 @@ public class PayManager : DomainService
{
order.TradeNo = tradeNo;
}
order.LastModificationTime = DateTime.Now;
await _payOrderRepository.UpdateAsync(order);
}