Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/UseCases/UC_Booking/Commands/ProcessPaymentWebhook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
using Hangfire;
using MediatR;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Logging;
using Net.payOS.Types;
using UseCases.Abstractions;
using UseCases.BackgroundServices.Bookings;
using UseCases.Services.EmailService;
using Transaction = Domain.Entities.Transaction;

Expand All @@ -20,8 +20,12 @@ public sealed class ProcessPaymentWebhook
{
public sealed record Command(WebhookType WebhookType) : IRequest<Result>;

public class Handler(IAppDBContext context, IEmailService emailService, ILogger<Handler> logger)
: IRequestHandler<Command, Result>
public class Handler(
IAppDBContext context,
IEmailService emailService,
ILogger<Handler> logger,
IMemoryCache cache
) : IRequestHandler<Command, Result>
{
public async Task<Result> Handle(Command request, CancellationToken cancellationToken)
{
Expand Down Expand Up @@ -130,6 +134,9 @@ out Transaction ownerEarningTransaction
booking.IsPaid = true;
}

var cacheKey = $"PaymentLink_{booking.Id}";
cache.Remove(cacheKey);

context.Transactions.AddRange(
bookingPayment,
platformFeeTransaction,
Expand Down
Loading