From 837a123c3bd80636b3c93622797b23d86b4b76f0 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Wed, 9 Jul 2025 22:00:06 +0800 Subject: [PATCH] :bug: Trying to fix payment handler --- .../Wallet/PaymentHandlers/AfdianPaymentHandler.cs | 10 ++-------- DysonNetwork.Sphere/Wallet/SubscriptionController.cs | 4 +--- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/DysonNetwork.Sphere/Wallet/PaymentHandlers/AfdianPaymentHandler.cs b/DysonNetwork.Sphere/Wallet/PaymentHandlers/AfdianPaymentHandler.cs index 0aa83e1..b3d310d 100644 --- a/DysonNetwork.Sphere/Wallet/PaymentHandlers/AfdianPaymentHandler.cs +++ b/DysonNetwork.Sphere/Wallet/PaymentHandlers/AfdianPaymentHandler.cs @@ -87,9 +87,8 @@ public class AfdianPaymentHandler( /// Get a specific order by its ID (out_trade_no) /// /// The order ID to query - /// The account ID /// The order item if found, otherwise null - public async Task GetOrderAsync(string orderId, Guid accountId) + public async Task 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 diff --git a/DysonNetwork.Sphere/Wallet/SubscriptionController.cs b/DysonNetwork.Sphere/Wallet/SubscriptionController.cs index 3892779..12fb747 100644 --- a/DysonNetwork.Sphere/Wallet/SubscriptionController.cs +++ b/DysonNetwork.Sphere/Wallet/SubscriptionController.cs @@ -183,9 +183,7 @@ public class SubscriptionController(SubscriptionService subscriptions, AfdianPay [Authorize] public async Task 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);