Exemple #1
0
        public static void UpdateBillingPeriod(String CustId)
        {
            String couponid = null;
            double discount = 0;
            var    invoices = StripeHelper.GetInvoices(CustId);

            if (invoices != null)
            {
                foreach (var invoice in invoices)
                {
                    var startperiod     = invoice.StripeInvoiceLineItems.Data.First().StripePeriod.Start.Value.ToString();
                    var endperiod       = invoice.StripeInvoiceLineItems.Data.First().StripePeriod.End.Value.ToString();
                    var stripe_discount = invoice.StripeDiscount;
                    if (stripe_discount != null)
                    {
                        couponid = stripe_discount.StripeCoupon.Id;
                    }
                    var amount_off = (double)invoice.AmountDue / 100;
                    var total      = (double)invoice.Total / 100; //after discount
                    var amount     = ((double)invoice.StripeInvoiceLineItems.Data.First().Amount) / 100;
                    discount = Math.Round(amount - total, 2, MidpointRounding.AwayFromZero);
                    var paid = invoice.Paid;
                    ServicesData.UpdatePaymentStatus(CustId, amount, amount_off, couponid, discount, startperiod, endperiod, paid);
                }
            }
        }
        //GET: Statements
        public ActionResult Statements()
        {
            //StripeServices.RenewTrailPlan();
            var invoices = StripeHelper.GetInvoices(SessionData.StripeCustId);
            //var customer = StripeHelper.GetStripeCustomer(SessionData.StripeCustId);
            List <StatementViewModel> statements = new List <StatementViewModel>();
            //var charges = StripeHelper.GetCharges(SessionData.StripeCustId);
            var timeZone = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time");

            if (invoices != null && invoices.Count > 0)
            {
                foreach (var item in invoices)
                {
                    if (item.StripeInvoiceLineItems.Data.First().Plan != null)
                    {
                        statements.Add(new StatementViewModel
                        {
                            Date        = item.Date.Value.ToShortDateString(),
                            Period      = TimeZoneInfo.ConvertTimeFromUtc(Convert.ToDateTime(item.StripeInvoiceLineItems.Data.First().StripePeriod.Start.Value.ToString()), timeZone).ToShortDateString() + "-" + TimeZoneInfo.ConvertTimeFromUtc(Convert.ToDateTime(item.StripeInvoiceLineItems.Data.First().StripePeriod.End.Value.ToString()), timeZone).AddDays(-1).ToShortDateString(),
                            Price       = ((double)(item.AmountDue / 100)).ToString(),
                            Description = item.StripeInvoiceLineItems.Data.First().Plan.Name,
                            Id          = item.Id
                        });
                    }
                }
            }
            return(View(statements));
        }
        //GET: Statements
        public ActionResult Statements()
        {
            List <StatementViewModel> statements = new List <StatementViewModel>();

            // To check user exist or not if exist then check codition is user active/IsArchive/profileAccess i.e expire/deleted/not access By Tarun 29-8-2018
            Boolean IsAllowToDowload = true;
            var     userData         = AccountData.GetUserDetails(SessionData.UserID);

            if (userData.Rows.Count > 0)
            {
                DataRow dr = userData.Rows[0];
                if (Convert.ToBoolean(dr["Active"]) == false)
                {
                    IsAllowToDowload = false;
                }
                else if (Convert.ToBoolean(dr["IsArchive"]) == true)
                {
                    IsAllowToDowload = false;
                }
                else if (Convert.ToInt32(dr["ProfileAccess"]) == 0)
                {
                    IsAllowToDowload = false;
                }
                else if (Convert.ToBoolean(dr["IsAccountLocked"]) == true)
                {
                    IsAllowToDowload = false;
                }
            }
            else
            {
                IsAllowToDowload = false;
            }


            if (!IsAllowToDowload)
            {
                return(View(statements));
            }
            //End 29-8-2018

            //StripeServices.RenewTrailPlan();
            var invoices = StripeHelper.GetInvoices(SessionData.StripeCustId);
            //var customer = StripeHelper.GetStripeCustomer(SessionData.StripeCustId);

            //var charges = StripeHelper.GetCharges(SessionData.StripeCustId);
            var timeZone = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time");

            if (invoices != null && invoices.Count > 0)
            {
                foreach (var item in invoices)
                {
                    if (item.StripeInvoiceLineItems.Data.First().Plan != null)
                    {
                        statements.Add(new StatementViewModel
                        {
                            Date        = item.Date.Value.ToShortDateString(),
                            Period      = TimeZoneInfo.ConvertTimeFromUtc(Convert.ToDateTime(item.StripeInvoiceLineItems.Data.First().StripePeriod.Start.Value.ToString()), timeZone).ToShortDateString() + "-" + TimeZoneInfo.ConvertTimeFromUtc(Convert.ToDateTime(item.StripeInvoiceLineItems.Data.First().StripePeriod.End.Value.ToString()), timeZone).AddDays(-1).ToShortDateString(),
                            Price       = ((double)(item.AmountDue / 100)).ToString(),
                            Description = item.StripeInvoiceLineItems.Data.First().Plan.Name,
                            Id          = item.Id
                        });
                    }
                }
            }
            return(View(statements));
        }