示例#1
0
        protected void btnUpdateCreditCard_Click(object sender, EventArgs e)
        {
            UserAccount u = GetCorrectUser();
            MerchantTribe.Billing.Service svc = new MerchantTribe.Billing.Service(MerchantTribe.Commerce.WebAppSettings.ApplicationConnectionString);
            BillingAccount act = svc.Accounts.FindOrCreate(u.Email);

            MerchantTribe.Payment.CardData data = this.CreditCardInput1.GetCardData();
            if (data.CardNumber == "") data.CardNumber = act.CreditCard.CardNumber;
            act.CreditCard = data;
            act.BillingZipCode = this.txtZipCode.Text.Trim();
            svc.Accounts.Update(act);
            this.MessageBox1.ShowOk("Billing Details Updated!");
        }
示例#2
0
 private void LoadBilling(UserAccount u)
 {
     MerchantTribe.Billing.Service svc = new MerchantTribe.Billing.Service(MerchantTribe.Commerce.WebAppSettings.ApplicationConnectionString);
     BillingAccount act = svc.Accounts.FindOrCreate(u.Email);
     if (act != null)
     {
         this.CreditCardInput1.LoadFromCardData(act.CreditCard);
         if (act.CreditCard.CardNumber == "4111111111111111")
         {
             this.CreditCardInput1.CardNumber = "";
         }
         this.txtZipCode.Text = act.BillingZipCode;
     }
 }
示例#3
0
        private void LoadBilling(UserAccount u)
        {
            MerchantTribe.Billing.Service svc = new MerchantTribe.Billing.Service(MerchantTribe.Commerce.WebAppSettings.ApplicationConnectionString);
            BillingAccount act = svc.Accounts.FindOrCreate(u.Email);

            if (act != null)
            {
                this.CreditCardInput1.LoadFromCardData(act.CreditCard);
                if (act.CreditCard.CardNumber == "4111111111111111")
                {
                    this.CreditCardInput1.CardNumber = "";
                }
                this.txtZipCode.Text = act.BillingZipCode;
            }
        }
示例#4
0
        private void LoadBilling(UserAccount u)
        {
            MerchantTribe.Billing.Service svc = new MerchantTribe.Billing.Service(MerchantTribe.Commerce.WebAppSettings.ApplicationConnectionString);
            BillingAccount act = svc.Accounts.FindOrCreate(u.Email);

            if (act != null)
            {
                this.lblCardOnFile.Text  = act.CreditCard.CardTypeName + "-" + act.CreditCard.CardNumberLast4Digits + "<br />";
                this.lblCardOnFile.Text += "Expires: " + act.CreditCard.ExpirationMonth + "/" + act.CreditCard.ExpirationYear + "<br />";
                this.lblCardOnFile.Text += "Billing Zip: " + act.BillingZipCode;

                if (act.CreditCard.CardNumber == "4111111111111111")
                {
                    this.lblCardOnFile.Text = "&nbsp;<br /><b>No Card On File.</b> Add One before choosing a plan!<br />&nbsp;";
                }
            }
        }
示例#5
0
        protected void btnUpdateCreditCard_Click(object sender, EventArgs e)
        {
            UserAccount u = GetCorrectUser();

            MerchantTribe.Billing.Service svc = new MerchantTribe.Billing.Service(MerchantTribe.Commerce.WebAppSettings.ApplicationConnectionString);
            BillingAccount act = svc.Accounts.FindOrCreate(u.Email);

            MerchantTribe.Payment.CardData data = this.CreditCardInput1.GetCardData();
            if (data.CardNumber == "")
            {
                data.CardNumber = act.CreditCard.CardNumber;
            }
            act.CreditCard     = data;
            act.BillingZipCode = this.txtZipCode.Text.Trim();
            svc.Accounts.Update(act);
            this.MessageBox1.ShowOk("Billing Details Updated!");
        }
        public Store CreateAndSetupStore(string storeName,
            long userAccountId,
            string friendlyName,
            int plan,
            decimal rate,
            MerchantTribe.Billing.BillingAccount billingAccount)
        {
            Store s = null;

            if (StoreNameExists(storeName))
                throw new CreateStoreException("That store name is not available. Please choose another name and try again.");

            s = new Store();
            s.StoreName = Text.ForceAlphaNumericOnly(storeName).ToLower();
            s.Status = StoreStatus.Active;
            s.DateCreated = DateTime.UtcNow;
            s.PlanId = plan;
            s.CustomUrl = string.Empty;

            if (!Stores.Create(s))
            {
                throw new CreateStoreException("Unable to create store. Unknown error. Please contact an administrator for assistance.");
            }

            s = Stores.FindByStoreName(s.StoreName);
            if (s != null)
            {
                AddUserToStore(s.Id, userAccountId, StoreAccessMode.Owner);

                s.Settings.FriendlyName = friendlyName;
                s.Settings.MailServer.FromEmail = "*****@*****.**";
                s.Settings.LastOrderNumber = 0;
                s.Settings.LogoImage = "[[default]]";
                s.Settings.LogoRevision = 0;
                s.Settings.UseLogoImage = false;
                s.Settings.LogoText = s.StoreName;
                s.Settings.MinumumOrderAmount = 0;

                // Send Reminder of account information to new user
                Accounts.UserAccount u = AdminUsers.FindById(userAccountId);

                s.Settings.MailServer.EmailForGeneral = u.Email;
                s.Settings.MailServer.EmailForNewOrder = u.Email;
                s.Settings.MailServer.UseCustomMailServer = false;
                s.Settings.ProductReviewCount = 3;
                s.Settings.ProductReviewModerate = true;
                s.Settings.ProductReviewShowRating = true;
                s.Settings.PayPal.FastSignupEmail = u.Email;
                s.Settings.PayPal.Currency = "USD";
                s.Settings.MaxItemsPerOrder = 999;
                s.Settings.MaxWeightPerOrder = 9999;
                s.Settings.MaxOrderMessage = "That's a really big order! Call us instead of ordering online.";

                s.CurrentPlanRate = rate;
                s.CurrentPlanDayOfMonth = DateTime.Now.Day;
                if (s.CurrentPlanDayOfMonth > 28)
                {
                    s.CurrentPlanDayOfMonth = 28;
                }
                HostedPlan thePlan = HostedPlan.FindById(s.PlanId);
                if (thePlan != null)
                {
                    s.CurrentPlanPercent = thePlan.PercentageOfSales;
                }
                else
                {
                    if (plan == 0)
                    {
                        s.CurrentPlanPercent = 0;
                    }
                    else
                    {
                        s.CurrentPlanPercent = 0;
                    }
                }

                // Save data to store
                Stores.Update(s);

                // Create Billing Accout
                MerchantTribe.Billing.Service svc = new MerchantTribe.Billing.Service(WebAppSettings.ApplicationConnectionString);
                BillingAccount act = svc.Accounts.FindOrCreate(billingAccount);

                Utilities.MailServices.SendLeadAlert(u, s);
                Utilities.MailServices.SendAccountInformation(u, s);

            }

            return s;
        }
        // working with local dates and times
        public static void GenerateInvoiceForStore(Store s, DateTime invoiceDateLocal, MerchantTribeApplication app)
        {
            // Create an Order
            Orders.Order o = new Orders.Order();
            o.StoreId = WebAppSettings.BillingStoreId;
            app.OrderServices.Orders.Create(o);

            o.Notes.Add(new Orders.OrderNote() { IsPublic = false, Note = "Auto Generated By Invoicing System" });

            // Base Rate
            Orders.LineItem li = new Orders.LineItem();
            li.BasePricePerItem = s.CurrentPlanRate;
            li.ProductName = "BV Commerce Hosted: " + s.PlanName;
            li.ProductSku = "BVH" + s.PlanId;
            li.Quantity = 1;
            li.QuantityShipped = 1;
            li.ShippingSchedule = -1;
            o.Items.Add(li);

            // need to add Percent of sales
            decimal lastMonthSales = 0;
            // End date should be immediately before bill not, not on the bill date
            DateTime localEnd = Dates.MaxOutTime(invoiceDateLocal);
            localEnd = localEnd.AddDays(-1);
            DateTime localStart = Dates.ZeroOutTime(invoiceDateLocal).AddMonths(-1);
            lastMonthSales = app.OrderServices.Transactions.FindBillableTransactionTotal(localStart.ToUniversalTime(),
                                                                        localEnd.ToUniversalTime(),
                                                                        s.Id);
            Orders.LineItem li2 = new Orders.LineItem();
            Decimal multiplier = s.CurrentPlanPercent / 100;
            Decimal transFees = Math.Round(multiplier * lastMonthSales, 2, MidpointRounding.AwayFromZero);
            li2.BasePricePerItem = transFees;
            li2.ProductName = "Transaction Fees:";
            li2.ProductShortDescription = s.CurrentPlanPercent + "% of " + lastMonthSales.ToString("c");
            li2.ProductShortDescription += " " + localStart.ToShortDateString() + " to " + localEnd.ToShortDateString();
            li2.ProductSku = "BVHTF";
            li2.Quantity = 1;
            li2.QuantityShipped = 1;
            li2.ShippingSchedule = -1;
            o.Items.Add(li2);

            List<UserAccount> users = app.AccountServices.FindAdminUsersByStoreId(s.Id);
            if (users != null)
            {
                if (users.Count > 0)
                {
                    UserAccount u = users[0];
                    o.UserEmail = u.Email;

                    Service svc = new Service(WebAppSettings.ApplicationConnectionString);
                    BillingAccount act = svc.Accounts.FindOrCreate(u.Email);
                    if (act != null)
                    {
                        o.BillingAddress.RegionData.Abbreviation = string.Empty;
                        o.BillingAddress.RegionName = string.Empty;
                        o.BillingAddress.PostalCode = act.BillingZipCode;
                        o.BillingAddress.FirstName = act.CreditCard.CardHolderName;
                        o.BillingAddress.Company = s.StoreName;

                        app.CalculateOrder(o);

                        Orders.OrderPaymentManager payManager = new Orders.OrderPaymentManager(o, app);
                        payManager.CreditCardAddInfo(act.CreditCard, o.TotalGrand);

                        o.OrderNumber = app.OrderServices.GenerateNewOrderNumber(WebAppSettings.BillingStoreId).ToString();
                        o.StatusCode = Orders.OrderStatusCode.Received;
                        o.IsPlaced = true;
                        o.TimeOfOrderUtc = DateTime.UtcNow;
                        o.EvaluateCurrentShippingStatus();

                        app.OrderServices.Orders.Update(o);
                    }
                }
            }
        }
示例#8
0
        public Store CreateAndSetupStore(string storeName,
                                         long userAccountId,
                                         string friendlyName,
                                         int plan,
                                         decimal rate,
                                         MerchantTribe.Billing.BillingAccount billingAccount)
        {
            Store s = null;

            if (StoreNameExists(storeName))
            {
                throw new CreateStoreException("That store name is not available. Please choose another name and try again.");
            }

            s             = new Store();
            s.StoreName   = Text.ForceAlphaNumericOnly(storeName).ToLower();
            s.Status      = StoreStatus.Active;
            s.DateCreated = DateTime.UtcNow;
            s.PlanId      = plan;
            s.CustomUrl   = string.Empty;

            if (!Stores.Create(s))
            {
                throw new CreateStoreException("Unable to create store. Unknown error. Please contact an administrator for assistance.");
            }

            s = Stores.FindByStoreName(s.StoreName);
            if (s != null)
            {
                AddUserToStore(s.Id, userAccountId, StoreAccessMode.Owner);

                s.Settings.FriendlyName         = friendlyName;
                s.Settings.MailServer.FromEmail = "*****@*****.**";
                s.Settings.LastOrderNumber      = 0;
                s.Settings.LogoImage            = "[[default]]";
                s.Settings.LogoRevision         = 0;
                s.Settings.UseLogoImage         = false;
                s.Settings.LogoText             = s.StoreName;
                s.Settings.MinumumOrderAmount   = 0;

                // Send Reminder of account information to new user
                Accounts.UserAccount u = AdminUsers.FindById(userAccountId);

                s.Settings.MailServer.EmailForGeneral     = u.Email;
                s.Settings.MailServer.EmailForNewOrder    = u.Email;
                s.Settings.MailServer.UseCustomMailServer = false;
                s.Settings.ProductReviewCount             = 3;
                s.Settings.ProductReviewModerate          = true;
                s.Settings.ProductReviewShowRating        = true;
                s.Settings.PayPal.FastSignupEmail         = u.Email;
                s.Settings.PayPal.Currency   = "USD";
                s.Settings.MaxItemsPerOrder  = 999;
                s.Settings.MaxWeightPerOrder = 9999;
                s.Settings.MaxOrderMessage   = "That's a really big order! Call us instead of ordering online.";

                s.CurrentPlanRate       = rate;
                s.CurrentPlanDayOfMonth = DateTime.Now.Day;
                if (s.CurrentPlanDayOfMonth > 28)
                {
                    s.CurrentPlanDayOfMonth = 28;
                }
                HostedPlan thePlan = HostedPlan.FindById(s.PlanId);
                if (thePlan != null)
                {
                    s.CurrentPlanPercent = thePlan.PercentageOfSales;
                }
                else
                {
                    if (plan == 0)
                    {
                        s.CurrentPlanPercent = 0;
                    }
                    else
                    {
                        s.CurrentPlanPercent = 0;
                    }
                }

                // Save data to store
                Stores.Update(s);

                // Create Billing Accout
                MerchantTribe.Billing.Service svc = new MerchantTribe.Billing.Service(WebAppSettings.ApplicationConnectionString);
                BillingAccount act = svc.Accounts.FindOrCreate(billingAccount);


                Utilities.MailServices.SendLeadAlert(u, s);
                Utilities.MailServices.SendAccountInformation(u, s);
            }

            return(s);
        }
        private void LoadBilling(UserAccount u)
        {
            MerchantTribe.Billing.Service svc = new MerchantTribe.Billing.Service(MerchantTribe.Commerce.WebAppSettings.ApplicationConnectionString);
            BillingAccount act = svc.Accounts.FindOrCreate(u.Email);
            if (act != null)
            {

                this.lblCardOnFile.Text = act.CreditCard.CardTypeName + "-" + act.CreditCard.CardNumberLast4Digits + "<br />";
                this.lblCardOnFile.Text += "Expires: " + act.CreditCard.ExpirationMonth + "/" + act.CreditCard.ExpirationYear + "<br />";
                this.lblCardOnFile.Text += "Billing Zip: " + act.BillingZipCode;

                if (act.CreditCard.CardNumber == "4111111111111111") this.lblCardOnFile.Text = "&nbsp;<br /><b>No Card On File.</b> Add One before choosing a plan!<br />&nbsp;";
            }
        }