Clearing out the payment path
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user