public JsonResult SetupCard() { var options = new SetupIntentCreateOptions { }; var service = new SetupIntentService(); var intent = service.Create(options); return(Json(intent.ClientSecret, JsonRequestBehavior.AllowGet)); }
public ActionResult Render(string tr) { var paymentIntent = PaymentService.GetPaymentIntentByTransactionRef(tr); StripeConfiguration.ApiKey = ConfigurationManager.AppSettings["Cashier:Stripe:Secret"]; string intentId = ""; string intentClientSecret = ""; if (paymentIntent.MotoMode == true) { var serviceSI = new SetupIntentService(); var setup = serviceSI.Create(new SetupIntentCreateOptions { PaymentMethodTypes = new List <string> { "card" }, Metadata = new Dictionary <string, string> { { "TransactionReference", paymentIntent.TransactionReference } } }); intentId = setup.Id; intentClientSecret = setup.ClientSecret; } else { var servicePI = new PaymentIntentService(); var createPI = new PaymentIntentCreateOptions { Amount = (long)paymentIntent.Amount * 100, Currency = paymentIntent.Currency, PaymentMethodTypes = new List <string> { "card" }, Description = paymentIntent.Description }; createPI.Metadata = new Dictionary <string, string> { { "TransactionReference", paymentIntent.TransactionReference } }; var responsePI = servicePI.Create(createPI); intentId = responsePI.Id; intentClientSecret = responsePI.ClientSecret; } ViewBag.PaymentIntent = paymentIntent; ViewBag.TransactionReference = paymentIntent.TransactionReference; ViewBag.ClientSecret = intentClientSecret; ViewBag.StripePaymentIntentId = intentId; ViewBag.TestMode = ConfigurationManager.AppSettings["Cashier:Stripe:LiveMode"].ToLower() == "false"; return(View("StripeCardPayment", CurrentPage)); }
public SetupIntent CreateNewCard(string customerId, string userId) { var setupIntentService = new SetupIntentService(); var intentOptions = new SetupIntentCreateOptions { Customer = customerId }; return(setupIntentService.Create(intentOptions)); }
public ActionResult Index() { //TODO: need to save customer var options = new SetupIntentCreateOptions { Customer = createACustomer() }; var service = new SetupIntentService(); var intent = service.Create(options); ViewData["ClientSecret"] = intent.ClientSecret; return(View()); }
public async Task <IActionResult> RegisterCard(AppZeroAPI.Entities.Customer customer) { var customerId = customer.customer_id; var options = new SetupIntentCreateOptions { Customer = customerId.ToString(), }; var service = new SetupIntentService(); var intent = service.Create(options); var clientSecret = intent.ClientSecret; var response = await Task.FromResult(clientSecret); return(Ok(response)); }