diff --git a/Controllers/PagamentoController.cs b/Controllers/PagamentoController.cs index 13a4fa0..461bf6b 100644 --- a/Controllers/PagamentoController.cs +++ b/Controllers/PagamentoController.cs @@ -126,21 +126,27 @@ namespace QRRapidoApp.Controllers { // Create Stripe Checkout Session (One-Time Payment) // We create an ad-hoc price on the fly using line_items + var useUsd = string.Equals(request.Currency, "usd", StringComparison.OrdinalIgnoreCase); + var currency = useUsd ? "usd" : "brl"; + var unitAmount = useUsd + ? (long)(package.PriceUsd * 100) + : (long)(package.PriceCard * 100); + var options = new SessionCreateOptions { PaymentMethodTypes = new List { "card" }, - Mode = "payment", // One-time payment + Mode = "payment", LineItems = new List { new SessionLineItemOptions { PriceData = new SessionLineItemPriceDataOptions { - Currency = "brl", - UnitAmount = (long)(package.PriceCard * 100), // Centavos + Currency = currency, + UnitAmount = unitAmount, ProductData = new SessionLineItemPriceDataProductDataOptions { - Name = $"{package.Credits} Créditos QR Rapido", + Name = $"{package.Credits} QR Rapido Credits", Description = package.Description } }, @@ -173,33 +179,36 @@ namespace QRRapidoApp.Controllers { return new List { - new CreditPackageViewModel { - Id = "starter", - Name = "Iniciante", - Credits = 10, - PricePix = 5.00m, // R$ 0,50/un - PriceCard = 6.00m, - Description = "Ideal para testes rápidos", - Savings = 0 + new CreditPackageViewModel { + Id = "starter", + Name = "Iniciante", + Credits = 10, + PricePix = 5.00m, + PriceCard = 6.00m, + PriceUsd = 1.09m, + Description = "Ideal para testes rápidos", + Savings = 0 }, - new CreditPackageViewModel { - Id = "pro", - Name = "Profissional", - Credits = 50, - PricePix = 22.50m, // R$ 0,45/un (Desconto de volume) - PriceCard = 27.00m, - Description = "Para uso recorrente", - Savings = 10, - IsPopular = true + new CreditPackageViewModel { + Id = "pro", + Name = "Profissional", + Credits = 50, + PricePix = 22.50m, + PriceCard = 27.00m, + PriceUsd = 4.99m, + Description = "Para uso recorrente", + Savings = 10, + IsPopular = true }, - new CreditPackageViewModel { - Id = "agency", - Name = "Agência", - Credits = 100, - PricePix = 40.00m, // R$ 0,40/un (Super desconto) - PriceCard = 48.00m, - Description = "Volume alto com desconto máximo", - Savings = 20 + new CreditPackageViewModel { + Id = "agency", + Name = "Agência", + Credits = 100, + PricePix = 40.00m, + PriceCard = 48.00m, + PriceUsd = 8.99m, + Description = "Volume alto com desconto máximo", + Savings = 20 } }; } @@ -212,6 +221,7 @@ namespace QRRapidoApp.Controllers public class CreateOrderRequest { public string PackageId { get; set; } + public string Currency { get; set; } = "brl"; // "brl" or "usd" } public class CreditPackageViewModel @@ -219,8 +229,9 @@ namespace QRRapidoApp.Controllers public string Id { get; set; } public string Name { get; set; } public int Credits { get; set; } - public decimal PricePix { get; set; } // Preço PIX - public decimal PriceCard { get; set; } // Preço Cartão (+taxas) + public decimal PricePix { get; set; } // Preço PIX (BRL only) + public decimal PriceCard { get; set; } // Preço Cartão BRL + public decimal PriceUsd { get; set; } // Preço Cartão USD public string Description { get; set; } public int Savings { get; set; } public bool IsPopular { get; set; } diff --git a/Views/Pagamento/SelecaoPlano.cshtml b/Views/Pagamento/SelecaoPlano.cshtml index 2121997..c89764e 100644 --- a/Views/Pagamento/SelecaoPlano.cshtml +++ b/Views/Pagamento/SelecaoPlano.cshtml @@ -35,7 +35,7 @@ QR Codes - +
@if (isBrazilian) { @@ -43,11 +43,19 @@ PIX R$ @package.PricePix.ToString("F2")
+
+ Cartão + R$ @package.PriceCard.ToString("F2") +
+ } + else + { +
+ Card + $ @package.PriceUsd.ToString("F2") +
+
USD · charged via Stripe
} -
- @(isBrazilian ? "Cartão" : "Card") - @(isBrazilian ? "R$" : "BRL") @package.PriceCard.ToString("F2") -
    @@ -67,8 +75,10 @@ } } @@ -197,10 +207,11 @@ this.innerHTML = ' Redirecionando...'; try { + const currency = this.dataset.currency || 'brl'; const response = await fetch('/api/Pagamento/CreateStripeSession', { method: 'POST', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ packageId: packageId }) + body: JSON.stringify({ packageId: packageId, currency: currency }) }); const result = await response.json();