Exemple #1
0
        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));
        }
Exemple #3
0
        public SetupIntent CreateNewCard(string customerId, string userId)
        {
            var setupIntentService = new SetupIntentService();
            var intentOptions      = new SetupIntentCreateOptions
            {
                Customer = customerId
            };

            return(setupIntentService.Create(intentOptions));
        }
Exemple #4
0
        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());
        }
Exemple #5
0
        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));
        }