ChatMVC/Chat/Controllers/PayController.cs
2025-01-25 10:41:37 -03:00

74 lines
2.5 KiB
C#

using Microsoft.AspNetCore.Mvc;
using Stripe;
using Stripe.Checkout;
namespace ChatMvc.Controllers
{
[Route("Pay")]
public class PayController : Controller
{
private string domain = "";
public PayController()
{
domain = "http://192.168.0.27:5094/";
}
public IActionResult Index()
{
return View();
}
[HttpPost("createbio")]
public ActionResult CreateBio()
{
StripeConfiguration.ApiKey = "sk_test_51PvIzkBk8jHwC3c0sGuWDUO8MV9KeOdSkir3Ulo2RZWmUhJLBIAgzxQScuomVi2l333MNmi0yr3FgeFv7OZnCJ0j00hD94yGx1";
var options = new SessionCreateOptions
{
UiMode = "embedded",
LineItems = new List<SessionLineItemOptions>
{
new SessionLineItemOptions
{
// Provide the exact Price ID (for example, pr_1234) of the product you want to sell
Price = "price_1Q1CXGBk8jHwC3c0YwypjEVd",
Quantity = 1,
},
},
Mode = "subscription",
ReturnUrl = domain + "/Plans/OrderView?SessionId={CHECKOUT_SESSION_ID}",
};
var service = new SessionService();
Session session = service.Create(options);
return Json(new { clientSecret = session.ClientSecret });
}
[HttpPost("createcatalogo")]
public ActionResult CreateCatalogo()
{
StripeConfiguration.ApiKey = "sk_test_51PvIzkBk8jHwC3c0sGuWDUO8MV9KeOdSkir3Ulo2RZWmUhJLBIAgzxQScuomVi2l333MNmi0yr3FgeFv7OZnCJ0j00hD94yGx1";
var options = new SessionCreateOptions
{
UiMode = "embedded",
LineItems = new List<SessionLineItemOptions>
{
new SessionLineItemOptions
{
// Provide the exact Price ID (for example, pr_1234) of the product you want to sell
Price = "price_1Q1CjvBk8jHwC3c03D82tbH8",
Quantity = 1,
},
},
Mode = "subscription",
ReturnUrl = domain + "/Plans/OrderView?SessionId={CHECKOUT_SESSION_ID}",
};
var service = new SessionService();
Session session = service.Create(options);
return Json(new { clientSecret = session.ClientSecret });
}
}
}