示例#1
0
        public GetCustomerResponse GetCustomerInformation(string customerId)
        {
            var response = new GetCustomerResponse();

            var customerService = new StripeCustomerService();

            try
            {
                StripeCustomer stripeCustomer = customerService.Get(customerId);
                MapStripeCustomerTo(stripeCustomer, response);
                response.Success = true;
            }
            catch (StripeException ex)
            {
                response.Success = false;
                response.Message = ex.Message;
                return(response);
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = ex.Message;
            }

            return(response);
        }
示例#2
0
        private void MapStripeCustomerTo(StripeCustomer stripeCustomer, GetCustomerResponse response)
        {
            if (response == null)
            {
                return;
            }

            response.Email       = CleanUpStripeEmail(stripeCustomer.Email);
            response.Id          = stripeCustomer.Id;
            response.Description = stripeCustomer.Description;

            if (stripeCustomer.StripeSubscription != null)
            {
                response.PlanId   = stripeCustomer.StripeSubscription.StripePlan.Id;
                response.PlanName = stripeCustomer.StripeSubscription.StripePlan.Name;
                decimal planAmount = (decimal)stripeCustomer.StripeSubscription.StripePlan.AmountInCents;
                planAmount          = planAmount / 100;
                response.PlanAmount = planAmount;
                response.PlanStatus = stripeCustomer.StripeSubscription.Status;
            }
            if (stripeCustomer.StripeNextRecurringCharge != null)
            {
                decimal nextCharge = (decimal)stripeCustomer.StripeNextRecurringCharge.AmountInCents;
                nextCharge = nextCharge / 100;
                string nextStatus = "Next charge " + nextCharge.ToString("C") + " on " + stripeCustomer.StripeNextRecurringCharge.Date;
                response.NextCharge = nextStatus;
            }
            if (stripeCustomer.StripeCard == null)
            {
                response.HasCard = false;
            }
            else
            {
                response.HasCard = true;
            }
        }
示例#3
0
        private void MapStripeCustomerTo(StripeCustomer stripeCustomer, GetCustomerResponse response)
        {
            if (response == null) return;

            response.Email = CleanUpStripeEmail(stripeCustomer.Email);
            response.Id = stripeCustomer.Id;
            response.Description = stripeCustomer.Description;

            if (stripeCustomer.StripeSubscription != null)
            {
                response.PlanId = stripeCustomer.StripeSubscription.StripePlan.Id;
                response.PlanName = stripeCustomer.StripeSubscription.StripePlan.Name;
                decimal planAmount = (decimal)stripeCustomer.StripeSubscription.StripePlan.AmountInCents;
                planAmount = planAmount / 100;
                response.PlanAmount = planAmount;
                response.PlanStatus = stripeCustomer.StripeSubscription.Status;                                
            }
            if (stripeCustomer.StripeNextRecurringCharge != null)
            {
                decimal nextCharge = (decimal)stripeCustomer.StripeNextRecurringCharge.AmountInCents;
                nextCharge = nextCharge / 100;
                string nextStatus = "Next charge " + nextCharge.ToString("C") + " on " + stripeCustomer.StripeNextRecurringCharge.Date;
                response.NextCharge = nextStatus;
            }
            if (stripeCustomer.StripeCard == null)
            {
                response.HasCard = false;
            }
            else
            {
                response.HasCard = true;
            }
            
        }
示例#4
0
        public GetCustomerResponse GetCustomerInformation(string customerId)
        {
            var response = new GetCustomerResponse();

            var customerService = new StripeCustomerService();
            try
            {
                StripeCustomer stripeCustomer = customerService.Get(customerId);
                MapStripeCustomerTo(stripeCustomer, response);
                response.Success = true;
            }
            catch (StripeException ex)
            {
                response.Success = false;
                response.Message = ex.Message;
                return response;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = ex.Message;
            }

            return response;
        }