Exemplo n.º 1
0
        public ActionResult AddCard(CustomerUnsecureAddCardViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var options = new StripeCustomerUpdateOptions
            {
                Source = new StripeSourceOptions()
                {
                    Object          = "card",
                    Number          = model.CardNumber,
                    AddressCity     = model.City,
                    AddressLine1    = model.Address,
                    AddressLine2    = model.Address2,
                    AddressState    = model.State.ToString(),
                    AddressZip      = model.Zip,
                    Cvc             = model.Cvc,
                    Name            = model.CardholderName,
                    ExpirationMonth = model.ExpirationMonth.ToString(),
                    ExpirationYear  = model.ExpirationYear.ToString()
                }
            };

            var customerService = new StripeCustomerService();

            customerService.Update(model.CustomerId, options);

            return(RedirectToAction("Details", new { id = model.CustomerId }));
        }
Exemplo n.º 2
0
        public ActionResult AddCard(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var customerService = new StripeCustomerService();
            var stripeCustomer  = customerService.Get(id);

            if (stripeCustomer == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var model = new CustomerUnsecureAddCardViewModel
            {
                CustomerId = id
            };

            return(View(model));
        }