예제 #1
0
        public ActionResult Payment(AcceptedPayment model)
        {
            if (ModelState.IsValid)
            {
                var token    = GetTokenId(model);
                var chargeId = ChargeCustomer(model.PaymentAmount, token);
                var payment  = db.Payments.Single(d => d.Patient_Id == model.PatientId);
                payment.Amount_Paid     = decimal.Parse(model.PaymentAmount.ToString());
                db.Entry(payment).State = EntityState.Modified;
                db.SaveChanges();

                return(RedirectToAction("Index", "Home"));
            }

            return(View(model));
        }
예제 #2
0
        private static string GetTokenId(AcceptedPayment model)
        {
            var myToken = new StripeTokenCreateOptions
            {
                Card = new StripeCreditCardOptions
                {
                    Cvc             = model.CardCvc,
                    ExpirationMonth = model.CardExpirationMonth.ToString(),
                    ExpirationYear  = model.CardExpirationYear.ToString(),
                    Currency        = model.Currency,
                    Number          = model.CardNumber,
                    Name            = model.CardName
                }
            };

            var tokenService = new StripeTokenService();
            var stripeToken  = tokenService.Create(myToken);

            return(stripeToken.Id);
        }