32 lines
923 B
C#
32 lines
923 B
C#
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;
|
|
}
|
|
}
|