diff --git a/LiteCharms.Features.MidrandBooks/Payments/Events/Handlers/PayfastPaymentConfirmationReceivedEventHandler.cs b/LiteCharms.Features.MidrandBooks/Payments/Events/Handlers/PayfastPaymentConfirmationReceivedEventHandler.cs index 96682ed..66ba389 100644 --- a/LiteCharms.Features.MidrandBooks/Payments/Events/Handlers/PayfastPaymentConfirmationReceivedEventHandler.cs +++ b/LiteCharms.Features.MidrandBooks/Payments/Events/Handlers/PayfastPaymentConfirmationReceivedEventHandler.cs @@ -6,12 +6,14 @@ namespace LiteCharms.Features.MidrandBooks.Payments.Events.Handlers; public sealed class PayfastPaymentConfirmationReceivedEventHandler(IServiceProvider services, ILogger logger) : INotificationHandler { - private readonly PaymentService paymentService = services.GetRequiredService(); - private readonly OrderService orderService = services.GetRequiredService(); - private readonly HashService hashService = services.GetRequiredService(); - public async ValueTask Handle(PayfastPaymentConfirmationReceivedEvent notification, CancellationToken cancellationToken) { + await using var scope = services.CreateAsyncScope(); + + PaymentService paymentService = scope.ServiceProvider.GetRequiredService(); + OrderService orderService = scope.ServiceProvider.GetRequiredService(); + HashService hashService = scope.ServiceProvider.GetRequiredService(); + var hashResult = hashService.DecodeLongIdHash(notification.Payload?.MPaymentId!); if (hashResult.IsFailed) {