feat: 支持创建订单时自定义支付宝回调地址

This commit is contained in:
ccnetcore
2025-08-15 23:41:01 +08:00
parent f09a9fee75
commit 482dd73afd
4 changed files with 7 additions and 7 deletions

View File

@@ -13,4 +13,6 @@ public class CreateOrderInput
/// </summary>
[Required]
public GoodsTypeEnum GoodsType { get; set; }
public string? ReturnUrl{ get; set; }
}

View File

@@ -58,7 +58,8 @@ public class PayService : ApplicationService, IPayService
var paymentPageHtml = await _alipayManager.PaymentPageAsync(
order.GoodsName,
order.OutTradeNo,
order.TotalAmount);
order.TotalAmount,
input.ReturnUrl);
// 3. 返回结果
return new CreateOrderOutput

View File

@@ -10,12 +10,10 @@ namespace Yi.Framework.AiHub.Domain.Alipay;
public class AlipayManager : DomainService
{
private readonly ILogger<AlipayManager> _logger;
private readonly IConfiguration _configuration;
public AlipayManager(ILogger<AlipayManager> logger, IConfiguration configuration)
public AlipayManager(ILogger<AlipayManager> logger)
{
_logger = logger;
_configuration = configuration;
}
/// <summary>
@@ -24,13 +22,13 @@ public class AlipayManager : DomainService
/// <returns></returns>
/// <exception cref="AlipayException"></exception>
public Task<AlipayTradePagePayResponse> PaymentPageAsync(string productName, string orderNumber,
decimal totalAmount)
decimal totalAmount, string? returnUrl)
{
try
{
// 2. 发起API调用以创建当面付收款二维码为例
var response = Factory.Payment.Page()
.Pay(productName, orderNumber, totalAmount.ToString(), _configuration["Alipay:ReturnUrl"]);
.Pay(productName, orderNumber, totalAmount.ToString(), returnUrl ?? string.Empty);
// 3. 处理响应或异常
if (ResponseChecker.Success(response))
{