Merge pull request 'Used scope to inject services' (#59) from payments into master
Reviewed-on: #59
This commit was merged in pull request #59.
This commit is contained in:
+6
-4
@@ -6,12 +6,14 @@ namespace LiteCharms.Features.MidrandBooks.Payments.Events.Handlers;
|
|||||||
public sealed class PayfastPaymentConfirmationReceivedEventHandler(IServiceProvider services, ILogger<PayfastPaymentConfirmationReceivedEvent> logger) :
|
public sealed class PayfastPaymentConfirmationReceivedEventHandler(IServiceProvider services, ILogger<PayfastPaymentConfirmationReceivedEvent> logger) :
|
||||||
INotificationHandler<PayfastPaymentConfirmationReceivedEvent>
|
INotificationHandler<PayfastPaymentConfirmationReceivedEvent>
|
||||||
{
|
{
|
||||||
private readonly PaymentService paymentService = services.GetRequiredService<PaymentService>();
|
|
||||||
private readonly OrderService orderService = services.GetRequiredService<OrderService>();
|
|
||||||
private readonly HashService hashService = services.GetRequiredService<HashService>();
|
|
||||||
|
|
||||||
public async ValueTask Handle(PayfastPaymentConfirmationReceivedEvent notification, CancellationToken cancellationToken)
|
public async ValueTask Handle(PayfastPaymentConfirmationReceivedEvent notification, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
|
await using var scope = services.CreateAsyncScope();
|
||||||
|
|
||||||
|
PaymentService paymentService = scope.ServiceProvider.GetRequiredService<PaymentService>();
|
||||||
|
OrderService orderService = scope.ServiceProvider.GetRequiredService<OrderService>();
|
||||||
|
HashService hashService = scope.ServiceProvider.GetRequiredService<HashService>();
|
||||||
|
|
||||||
var hashResult = hashService.DecodeLongIdHash(notification.Payload?.MPaymentId!);
|
var hashResult = hashService.DecodeLongIdHash(notification.Payload?.MPaymentId!);
|
||||||
if (hashResult.IsFailed)
|
if (hashResult.IsFailed)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user