🐛 Optimize order handling
This commit is contained in:
		| @@ -39,6 +39,7 @@ public class BroadcastEventHandler( | |||||||
|                 if (order is null) |                 if (order is null) | ||||||
|                 { |                 { | ||||||
|                     logger.LogWarning("Order with ID {OrderId} not found.", evt.OrderId); |                     logger.LogWarning("Order with ID {OrderId} not found.", evt.OrderId); | ||||||
|  |                     await nats.PublishAsync(PaymentOrderEventBase.Type, msg.Data, cancellationToken: stoppingToken); | ||||||
|                     continue; |                     continue; | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
| @@ -49,6 +50,7 @@ public class BroadcastEventHandler( | |||||||
|             catch (Exception ex) |             catch (Exception ex) | ||||||
|             { |             { | ||||||
|                 logger.LogError(ex, "Error processing payment order event for order {OrderId}", evt?.OrderId); |                 logger.LogError(ex, "Error processing payment order event for order {OrderId}", evt?.OrderId); | ||||||
|  |                 await nats.PublishAsync(PaymentOrderEventBase.Type, msg.Data, cancellationToken: stoppingToken); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -24,8 +24,7 @@ public class OrderController(PaymentService payment, AuthService auth, AppDataba | |||||||
|     [Authorize] |     [Authorize] | ||||||
|     public async Task<ActionResult<Order>> PayOrder(Guid id, [FromBody] PayOrderRequest request) |     public async Task<ActionResult<Order>> PayOrder(Guid id, [FromBody] PayOrderRequest request) | ||||||
|     { |     { | ||||||
|         if (HttpContext.Items["CurrentUser"] is not Account.Account currentUser || |         if (HttpContext.Items["CurrentUser"] is not Account.Account currentUser) return Unauthorized(); | ||||||
|             HttpContext.Items["CurrentSession"] is not AuthSession currentSession) return Unauthorized(); |  | ||||||
|      |      | ||||||
|         // Validate PIN code |         // Validate PIN code | ||||||
|         if (!await auth.ValidatePinCode(currentUser.Id, request.PinCode)) |         if (!await auth.ValidatePinCode(currentUser.Id, request.PinCode)) | ||||||
|   | |||||||
| @@ -282,7 +282,7 @@ public class PaymentService( | |||||||
|  |  | ||||||
|         await NotifyOrderPaid(order, payerWallet, order.PayeeWallet); |         await NotifyOrderPaid(order, payerWallet, order.PayeeWallet); | ||||||
|  |  | ||||||
|         await nats.PublishAsync(PaymentOrderEvent.Type, JsonSerializer.SerializeToUtf8Bytes(new PaymentOrderEvent |         await nats.PublishAsync(PaymentOrderEventBase.Type, JsonSerializer.SerializeToUtf8Bytes(new PaymentOrderEvent | ||||||
|         { |         { | ||||||
|             OrderId = order.Id, |             OrderId = order.Id, | ||||||
|             WalletId = payerWallet.Id, |             WalletId = payerWallet.Id, | ||||||
|   | |||||||
| @@ -229,8 +229,6 @@ public class SubscriptionService( | |||||||
|         return subscription; |         return subscription; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public const string SubscriptionOrderIdentifier = "solian.subscription.order"; |  | ||||||
|  |  | ||||||
|     /// <summary> |     /// <summary> | ||||||
|     /// Creates a subscription order for an unpaid or expired subscription. |     /// Creates a subscription order for an unpaid or expired subscription. | ||||||
|     /// If the subscription is active, it will extend its expiration date. |     /// If the subscription is active, it will extend its expiration date. | ||||||
|   | |||||||
| @@ -63,11 +63,15 @@ public class BroadcastEventHandler( | |||||||
|  |  | ||||||
|                         break; |                         break; | ||||||
|                     } |                     } | ||||||
|  |                     default: | ||||||
|  |                         await nats.PublishAsync(PaymentOrderEventBase.Type, msg.Data, cancellationToken: stoppingToken); | ||||||
|  |                         break; | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|             catch (Exception ex) |             catch (Exception ex) | ||||||
|             { |             { | ||||||
|                 logger.LogError(ex, "Error processing payment order event for order {OrderId}", evt?.OrderId); |                 logger.LogError(ex, "Error processing payment order event for order {OrderId}", evt?.OrderId); | ||||||
|  |                 await nats.PublishAsync(PaymentOrderEventBase.Type, msg.Data, cancellationToken: stoppingToken); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user