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)); }
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); }