#27 small changes for the userTransaction

This commit is contained in:
Dominic Villemure
2024-04-24 19:37:35 -04:00
parent bd6028c524
commit 6883855ecb
4 changed files with 15 additions and 11 deletions

View File

@@ -5,7 +5,7 @@ namespace Hutopy.Application.Stripe.Commands;
public record CreateSessionCheckoutCommand : IRequest<string>
{
public required string CreatorId { get; init; }
public required int Price { get; init; }
public required int Amount { get; init; }
public string Currency { get; init; } = "CAD";
public string TipMessage { get; init; } = string.Empty;
}
@@ -18,11 +18,16 @@ public class CreateSessionCheckoutCommandHandler(
{
public async Task<string> Handle(CreateSessionCheckoutCommand request, CancellationToken cancellationToken)
{
var stripeSecret = await stripeService.CreateCheckoutSession(request.Price, request.Currency);
var stripeSecret = await stripeService.CreateCheckoutSession(request.Amount, request.Currency);
// ReSharper disable once PossibleLossOfFraction
decimal priceInDollars = (request.Amount / 100);
//todo: Need to add this transaction after the confirmation from stripe in the frontEnd ( redirect, re-call backend )
var userTransaction = new UserTransaction
{
Currency = request.Currency, Amount = request.Price, TipMessage = request.TipMessage, ApplicationUserId = request.CreatorId
Currency = request.Currency, Amount = priceInDollars, TipMessage = request.TipMessage, ApplicationUserId = request.CreatorId
};
await dbContext.UserTransactions.AddAsync(userTransaction, cancellationToken);