Clearing out the payment path

This commit is contained in:
2025-04-17 00:18:17 -04:00
parent 910c5572a1
commit 9d2a00a928
4 changed files with 37 additions and 43 deletions

View File

@@ -44,7 +44,8 @@ public class SendTipRequestValidator : Validator<SendTipRequest>
[PublicAPI]
public class SendTipHandler(
MembershipDbContext dbContext,
StripeService stripeService)
StripeService stripeService,
ILogger<SendTipHandler> logger)
: Endpoint<SendTipRequest, SendTipResponse>
{
public override void Configure()
@@ -59,29 +60,36 @@ public class SendTipHandler(
SendTipRequest req,
CancellationToken ct)
{
var creator = await dbContext.Creators.FindAsync(
[req.CreatorId],
cancellationToken: ct);
if (creator == null)
try
{
await SendNotFoundAsync(ct);
return;
var creator = await dbContext.Creators.FindAsync(
[req.CreatorId],
cancellationToken: ct);
if (creator == null)
{
await SendNotFoundAsync(ct);
return;
}
var checkoutSession = await stripeService.CreateTipCheckoutSessionAsync(
creator.Id,
creator.Name,
req.Amount,
req.Currency,
req.Message,
creator.StripeAccountId!,
req.CheckoutSuccessUrl,
req.CheckoutCancelledUrl,
ct);
await SendAsync(
new SendTipResponse("Pending", checkoutSession.Url),
cancellation: ct);
}
catch (Exception e)
{
logger.LogError(e.Message);
}
var checkoutSession = await stripeService.CreateTipCheckoutSessionAsync(
creator.Id,
creator.Name,
req.Amount,
req.Currency,
req.Message,
creator.StripeAccountId!,
req.CheckoutSuccessUrl,
req.CheckoutCancelledUrl,
ct);
await SendAsync(
new SendTipResponse("Pending", checkoutSession.Url),
cancellation: ct);
}
}