feat: 支持创建订单时自定义支付宝回调地址
This commit is contained in:
@@ -13,4 +13,6 @@ public class CreateOrderInput
|
||||
/// </summary>
|
||||
[Required]
|
||||
public GoodsTypeEnum GoodsType { get; set; }
|
||||
|
||||
public string? ReturnUrl{ get; set; }
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user