Added endpoint to create a sessionCheckout with stripe

This commit is contained in:
Dominic Villemure
2024-03-20 01:10:44 -04:00
parent 0689a3d85c
commit 2b810772b3
8 changed files with 157 additions and 7 deletions

View File

@@ -0,0 +1,31 @@
using Hutopy.Application.Common.Interfaces;
namespace Hutopy.Application.Stripe.Commands;
public record CreateSessionCheckoutCommand : IRequest<string>
{
public required int Price { get; init; }
public string Currency { get; init; } = "cad";
}
public class CreateSessionCheckoutCommandHandler : IRequestHandler<CreateSessionCheckoutCommand, string>
{
private readonly IApplicationDbContext _context;
private readonly IStripeService _stripeService;
public CreateSessionCheckoutCommandHandler(IApplicationDbContext context, IStripeService stripeService)
{
_context = context;
_stripeService = stripeService;
}
public async Task<string> Handle(CreateSessionCheckoutCommand request, CancellationToken cancellationToken)
{
var stripeSecret = await _stripeService.CreateCheckoutSession(request.Price, request.Currency);
return stripeSecret;
}
}