many fixes and improvements - rework for modules/ and common/
feat(emailer): add Postmark and Resend providers
This commit is contained in:
31
backend/Modules/Tipping/Services/TipPaymentNotifier.cs
Normal file
31
backend/Modules/Tipping/Services/TipPaymentNotifier.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using Hutopy.Modules.Tipping.Contracts;
|
||||
using Hutopy.Modules.Tipping.Data;
|
||||
|
||||
namespace Hutopy.Modules.Tipping.Services;
|
||||
|
||||
public class TipPaymentNotifier(
|
||||
TippingDbContext dbContext,
|
||||
ILogger<TipPaymentNotifier> logger)
|
||||
: ITipPaymentNotifier
|
||||
{
|
||||
public async Task NotifyPaymentSucceedAsync(
|
||||
string sessionId,
|
||||
string invoiceUrl,
|
||||
CancellationToken ct)
|
||||
{
|
||||
var tip = await dbContext.Tips.SingleOrDefaultAsync(
|
||||
t => t.StripeSessionId == sessionId,
|
||||
cancellationToken: ct);
|
||||
|
||||
if (tip is not null)
|
||||
{
|
||||
tip.Status = TipStatus.Paid;
|
||||
tip.StripeInvoiceUrl = invoiceUrl;
|
||||
await dbContext.SaveChangesAsync(ct);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.LogError("Tip with session ID {SessionId} not found", sessionId);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user