Esempio n. 1
0
        public ActionResult SetupStripe(Guid customerId)
        {
            SetupStripeResponse response = _customerService.SetupStripe(customerId);

            if (response.HasError && response.ErrorCode == ErrorCode.StripeSetupError)
            {
                return(RedirectToAction("payments", "customers", new { id = customerId })
                       .AndAlert(AlertType.Danger, "Stripe error.", "Error is thrown during creating stripe customer."));
            }

            return(RedirectToAction("payments", "customers", new { id = customerId })
                   .AndAlert(AlertType.Success, "Stripe customer created.", "Stripe customer was created successfully."));
        }
Esempio n. 2
0
        public SetupStripeResponse SetupStripe(Guid customerId)
        {
            SetupStripeResponse response = new SetupStripeResponse();

            Customer customerObj = _customerRepository.Get(customerId);

            try
            {
                var customer = StripeFactory.GetStripeService().CreateCustomer(customerObj.FullName, customerObj.AdminUser.Email);
                customerObj.UpdateStripe(customer.Id);

                _customerRepository.Update(customerObj);

                _unitOfWork.Commit();
            }
            catch
            {
                response.HasError  = true;
                response.ErrorCode = ErrorCode.StripeSetupError;
            }

            return(response);
        }