🐛 Trying to fix payment handler
This commit is contained in:
@ -87,9 +87,8 @@ public class AfdianPaymentHandler(
|
||||
/// Get a specific order by its ID (out_trade_no)
|
||||
/// </summary>
|
||||
/// <param name="orderId">The order ID to query</param>
|
||||
/// <param name="accountId">The account ID</param>
|
||||
/// <returns>The order item if found, otherwise null</returns>
|
||||
public async Task<OrderItem?> GetOrderAsync(string orderId, Guid accountId)
|
||||
public async Task<OrderItem?> GetOrderAsync(string orderId)
|
||||
{
|
||||
if (string.IsNullOrEmpty(orderId))
|
||||
{
|
||||
@ -97,11 +96,6 @@ public class AfdianPaymentHandler(
|
||||
return null;
|
||||
}
|
||||
|
||||
var connection = await db.AccountConnections
|
||||
.Where(c => c.AccountId == accountId && c.Provider == "afdian")
|
||||
.FirstOrDefaultAsync();
|
||||
if (connection is null) throw new InvalidOperationException("Account need to link an afdian account first.");
|
||||
|
||||
try
|
||||
{
|
||||
var token = _configuration["Payment:Auth:Afdian"] ?? "_:_";
|
||||
@ -119,7 +113,7 @@ public class AfdianPaymentHandler(
|
||||
{
|
||||
Content = new StringContent(JsonSerializer.Serialize(new
|
||||
{
|
||||
user_id = connection.ProvidedIdentifier,
|
||||
user_id = userId,
|
||||
@params = paramsJson,
|
||||
ts,
|
||||
sign
|
||||
|
@ -183,9 +183,7 @@ public class SubscriptionController(SubscriptionService subscriptions, AfdianPay
|
||||
[Authorize]
|
||||
public async Task<IActionResult> RestorePurchaseFromAfdian([FromBody] RestorePurchaseRequest request)
|
||||
{
|
||||
if (HttpContext.Items["CurrentUser"] is not Account.Account currentUser) return Unauthorized();
|
||||
|
||||
var order = await afdian.GetOrderAsync(request.OrderId, currentUser.Id);
|
||||
var order = await afdian.GetOrderAsync(request.OrderId);
|
||||
if (order is null) return NotFound($"Order with ID {request.OrderId} was not found.");
|
||||
|
||||
var subscription = await subscriptions.CreateSubscriptionFromOrder(order);
|
||||
|
Reference in New Issue
Block a user