♻️ Refactored order handling
This commit is contained in:
@@ -4,6 +4,7 @@ using DysonNetwork.Pass.Auth;
|
||||
using DysonNetwork.Pass.Credit;
|
||||
using DysonNetwork.Pass.Leveling;
|
||||
using DysonNetwork.Pass.Permission;
|
||||
using DysonNetwork.Pass.Wallet;
|
||||
using Microsoft.AspNetCore.HttpOverrides;
|
||||
using Microsoft.Extensions.FileProviders;
|
||||
using Prometheus;
|
||||
@@ -81,6 +82,8 @@ public static class ApplicationConfiguration
|
||||
app.MapGrpcService<SocialCreditServiceGrpc>();
|
||||
app.MapGrpcService<ExperienceServiceGrpc>();
|
||||
app.MapGrpcService<BotAccountReceiverGrpc>();
|
||||
app.MapGrpcService<WalletServiceGrpc>();
|
||||
app.MapGrpcService<PaymentServiceGrpc>();
|
||||
|
||||
return app;
|
||||
}
|
||||
|
34
DysonNetwork.Pass/Startup/BroadcastEventHandler.cs
Normal file
34
DysonNetwork.Pass/Startup/BroadcastEventHandler.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System.Text.Json;
|
||||
using DysonNetwork.Pass.Wallet;
|
||||
using DysonNetwork.Shared.Stream;
|
||||
using NATS.Client.Core;
|
||||
|
||||
namespace DysonNetwork.Pass.Startup;
|
||||
|
||||
public class BroadcastEventHandler(
|
||||
INatsConnection nats,
|
||||
ILogger<BroadcastEventHandler> logger,
|
||||
IServiceProvider serviceProvider
|
||||
) : BackgroundService
|
||||
{
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
await foreach (var msg in nats.SubscribeAsync<byte[]>(PaymentOrderEvent.Type, cancellationToken: stoppingToken))
|
||||
{
|
||||
try
|
||||
{
|
||||
var evt = JsonSerializer.Deserialize<PaymentOrderEvent>(msg.Data);
|
||||
|
||||
if (evt?.ProductIdentifier is null || !evt.ProductIdentifier.StartsWith(SubscriptionType.StellarProgram))
|
||||
continue;
|
||||
|
||||
logger.LogInformation("Stellar program order paid: {OrderId}", evt.OrderId);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Error processing AccountDeleted");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -54,10 +54,6 @@ public static class ServiceCollectionExtensions
|
||||
|
||||
services.AddPusherService();
|
||||
|
||||
// Register gRPC services
|
||||
services.AddScoped<AccountServiceGrpc>();
|
||||
services.AddScoped<AuthServiceGrpc>();
|
||||
|
||||
// Register OIDC services
|
||||
services.AddScoped<OidcService, GoogleOidcService>();
|
||||
services.AddScoped<OidcService, AppleOidcService>();
|
||||
|
Reference in New Issue
Block a user