public StoreSettings(Store s) { this._Store = s; AllSettings = new List<StoreSetting>(); Acumatica = new StoreSettingsAcumatica(this); Analytics = new StoreSettingsAnalytics(this); MailServer = new StoreSettingsMailServer(this); PayPal = new StoreSettingsPayPal(this); FaceBook = new StoreSettingsFaceBook(this); Twitter = new StoreSettingsTwitter(this); GooglePlus = new StoreSettingsGooglePlus(this); }
public SuperStoreViewModel(Store s) : base() { this.Users = new List<UserAccount>(); this.CurrentPlanDayOfMonth = s.CurrentPlanDayOfMonth; this.CurrentPlanPercent = s.CurrentPlanPercent; this.CurrentPlanRate = s.CurrentPlanRate; this.CustomUrl = s.CustomUrl; this.Id = s.Id; this.PlanId = s.PlanId; this.Settings = s.Settings; this.Status = s.Status; this.StoreName = s.StoreName; }
public RequestContext() { CurrentStore = new Accounts.Store(); ConnectionString = WebAppSettings.ApplicationConnectionString; ConnectionStringForEntityFramework = WebAppSettings.ApplicationConnectionStringForEntityFramework; IntegrationEvents = new Integration(); RoutingContext = null; this.MetaAdditionalText = string.Empty; this.MetaKeywords = string.Empty; this.MetaDescription = string.Empty; this.PageTitle = string.Empty; this.TempMessages = new List<string>(); this.CartItemCount = string.Empty; this.CartSubtotal = string.Empty; }
public RequestContext() { CurrentStore = new Accounts.Store(); ConnectionString = WebAppSettings.ApplicationConnectionString; ConnectionStringForEntityFramework = WebAppSettings.ApplicationConnectionStringForEntityFramework; IntegrationEvents = new Integration(); RoutingContext = null; this.MetaAdditionalText = string.Empty; this.MetaKeywords = string.Empty; this.MetaDescription = string.Empty; this.PageTitle = string.Empty; this.TempMessages = new List <string>(); this.CartItemCount = string.Empty; this.CartSubtotal = string.Empty; }
private bool UpgradePlan(Store s, UserAccount a, HostedPlan newPlan) { s.CurrentPlanRate = newPlan.Rate; s.CurrentPlanPercent = newPlan.PercentageOfSales; s.CurrentPlanDayOfMonth = DateTime.Now.Day; if (s.CurrentPlanDayOfMonth > 28) s.CurrentPlanDayOfMonth = 28; s.PlanId = newPlan.Id; bool result = Stores.Update(s); if (result) { // Charge Card // Notify Admin of Change Utilities.MailServices.SendPlanUpgradeAlert(a, s); } return result; }
private Store CreateIndividualStore() { Store s = null; string storeName = "www"; s = new Store(); s.StoreName = Text.ForceAlphaNumericOnly(storeName).ToLower(); s.Status = StoreStatus.Active; s.DateCreated = DateTime.UtcNow; s.PlanId = 99; 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) { UserAccount mainAccount = new UserAccount(); mainAccount.Email = "*****@*****.**"; mainAccount.HashedPassword = "******"; mainAccount.Status = UserAccountStatus.Active; AdminUsers.Create(mainAccount); mainAccount = AdminUsers.FindByEmail(mainAccount.Email); AddUserToStore(s.Id, mainAccount.Id, StoreAccessMode.Owner); s.Settings.FriendlyName = "My MerchantTribe Store"; 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; s.Settings.MailServer.EmailForGeneral = mainAccount.Email; s.Settings.MailServer.EmailForNewOrder = mainAccount.Email; s.Settings.MailServer.UseCustomMailServer = false; s.Settings.ProductReviewCount = 3; s.Settings.ProductReviewModerate = true; s.Settings.ProductReviewShowRating = true; s.Settings.PayPal.FastSignupEmail = mainAccount.Email; s.Settings.PayPal.Currency = "USD"; s.Settings.MaxItemsPerOrder = 999; s.CurrentPlanRate = 0; s.CurrentPlanDayOfMonth = DateTime.Now.Day; s.CurrentPlanPercent = 0; // Save data to store Stores.Update(s); // No longer need to redirect because home controller handles this //System.Web.HttpContext.Current.Response.Redirect("~/adminaccount/login?wizard=1"); // Force this store into the request context so // non-repository datalayer will read in the correct // store id //RequestContext demoContext = new RequestContext(); //demoContext.CurrentStore = s; //RequestContext.ForceCurrentRequestContext(demoContext); //// Add Sample Data //AddSampleProductsToStore(demoContext); //// Set a default theme //Content.ThemeManager m = new Content.ThemeManager(demoContext); //m.InstallTheme("cf09d318-3792-47b8-a207-a9502f96f0f9"); } return s; }
public static void SetCurrentPaymentPendingCartId(Store currentStore, string value) { SetCookieString(WebAppSettings.CookieNameCartIdPaymentPending(currentStore.Id), value, currentStore, DateTime.Now.AddDays(14), true); }
public static void SetCurrentAffiliateId(long id, DateTime expirationDate, Store currentStore) { SetCookieString(WebAppSettings.CustomerIdCookieName + "Referrer", id.ToString(), currentStore, expirationDate, false); }
public static void SaveOrderCookies(Orders.Order o, Store currentStore) { if (o.IsPlaced) { // Clear Cookies SetCookieString(WebAppSettings.CookieNameCartId(currentStore.Id), string.Empty, currentStore); SetCookieString(WebAppSettings.CookieNameCartItemCount(currentStore.Id), "0", currentStore); SetCookieString(WebAppSettings.CookieNameCartSubTotal(currentStore.Id), "0", currentStore); } else { // Save Cart Cookie SetCookieString(WebAppSettings.CookieNameCartId(currentStore.Id), o.bvin, currentStore); SetCookieString(WebAppSettings.CookieNameCartItemCount(currentStore.Id), Math.Round(o.TotalQuantity, 0).ToString(), currentStore); SetCookieString(WebAppSettings.CookieNameCartSubTotal(currentStore.Id), o.TotalOrderAfterDiscounts.ToString("c"), currentStore); } }
public static bool UploadStoreImage(Store s, HttpPostedFile file) { bool result = true; if (!ValidateImageType(System.IO.Path.GetExtension(file.FileName))) { return false; } if (s != null) { int newRevision = s.Settings.LogoRevision + 1; string saveLocation = WebAppSettings.BaseImagePhysicalPath; saveLocation += s.Id.ToString() + "/storelogo/" + newRevision + "/"; saveLocation += System.IO.Path.GetFileName(MerchantTribe.Web.Text.CleanFileName(file.FileName)); result = WriteFileToPath(saveLocation, file); if (result) { s.Settings.LogoRevision = newRevision; result = Utilities.ImageProcessing.ShrinkToLogo(saveLocation); } } return result; }
// 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); } } } }
private void DoSignUp(RegisterViewModel model) { bool storeOkay = false; if (model.RegistrationData.plan == 0) { // Fake CC information so that signup is easier model.RegistrationData.cardholder = model.RegistrationData.email; model.RegistrationData.cardnumber = "4111111111111111"; model.RegistrationData.billingzipcode = "00000"; model.RegistrationData.expyear = DateTime.Now.AddYears(1).Year; model.RegistrationData.expmonth = DateTime.Now.Month; } MerchantTribe.Commerce.Accounts.Store testStore = new MerchantTribe.Commerce.Accounts.Store(); testStore.StoreName = model.RegistrationData.storename; if (!testStore.IsValid()) { foreach (MerchantTribe.Web.Validation.RuleViolation v in testStore.GetRuleViolations()) { RenderError(v, model); } } else { if (MTApp.AccountServices.StoreNameExists(testStore.StoreName)) { RenderError("storename", "A store with that name already exists. Choose another name and try again.", model); } else { storeOkay = true; } } // Check credit card number bool cardOkay = true; if (!MerchantTribe.Payment.CardValidator.IsCardNumberValid(model.RegistrationData.cardnumber)) { cardOkay = false; RenderError("cardnumber", "Please enter a valid credit card number", model); } if (model.RegistrationData.cardholder.Trim().Length < 1) { cardOkay = false; RenderError("cardholder", "Please enter the name on your credit card.", model); } if (model.RegistrationData.billingzipcode.Trim().Length < 5) { cardOkay = false; RenderError("billingzipcode", "Please enter the billing zip code for your credit card.", model); } UserAccount u = MTApp.AccountServices.AdminUsers.FindByEmail(model.RegistrationData.email); if (u == null) { u = new MerchantTribe.Commerce.Accounts.UserAccount(); } bool userOk = false; if (u.IsValid() && (u.Email == model.RegistrationData.email)) { if (u.DoesPasswordMatch(model.RegistrationData.password)) { userOk = true; } else { RenderError("email", "A user account with that email address already exists. If it's your account make sure you enter the exact same password as you usually use.", model); } } else { u = new MerchantTribe.Commerce.Accounts.UserAccount(); u.Email = model.RegistrationData.email; u.HashedPassword = model.RegistrationData.password; if (u.IsValid()) { u.Status = MerchantTribe.Commerce.Accounts.UserAccountStatus.Active; u.DateCreated = DateTime.UtcNow; userOk = MTApp.AccountServices.AdminUsers.Create(u); u = MTApp.AccountServices.AdminUsers.FindByEmail(u.Email); } else { foreach (MerchantTribe.Web.Validation.RuleViolation v in u.GetRuleViolations()) { RenderError(v.ControlName, v.ErrorMessage, model); } } } if (userOk && storeOkay && cardOkay) { try { MerchantTribe.Billing.BillingAccount billingAccount = new MerchantTribe.Billing.BillingAccount(); billingAccount.Email = u.Email; billingAccount.BillingZipCode = model.RegistrationData.billingzipcode; billingAccount.CreditCard.CardNumber = model.RegistrationData.cardnumber; billingAccount.CreditCard.ExpirationMonth = model.RegistrationData.expmonth; billingAccount.CreditCard.ExpirationYear = model.RegistrationData.expyear; billingAccount.CreditCard.CardHolderName = model.RegistrationData.cardholder; bool isPayPalLead = false; if (MerchantTribe.Commerce.SessionManager.GetCookieString("PayPalLead", MTApp.CurrentStore) != string.Empty) { isPayPalLead = true; } decimal rate = 0; HostedPlan thePlan = HostedPlan.FindById(model.RegistrationData.plan); if (thePlan != null) { rate = thePlan.Rate; if (isPayPalLead) { rate = 49; } } MerchantTribe.Commerce.Accounts.Store s = MTApp.AccountServices.CreateAndSetupStore(model.RegistrationData.storename, u.Id, model.RegistrationData.storename + " store for " + model.RegistrationData.email, model.RegistrationData.plan, rate, billingAccount); if (s != null) { string e = MerchantTribe.Web.Cryptography.Base64.ConvertStringToBase64(u.Email); string st = MerchantTribe.Web.Cryptography.Base64.ConvertStringToBase64(s.StoreName); Response.Redirect("~/signup/ProcessSignUp?e=" + e + "&s=" + st); //this.completeemail.Text = u.Email; //this.completestorelink.Text = "<a href=\"" + s.RootUrl() + "\">" + s.RootUrl() + "</a>"; //this.completestorelinkadmin.Text = "<a href=\"" + s.RootUrlSecure() + "bvadmin\">" + s.RootUrlSecure() + "bvadmin</a>"; //this.completebiglogin.Text = "<a href=\"" + s.RootUrlSecure() + "adminaccount/login?wizard=1&username="******"\">Next Step » Choose a Theme</a>"; //this.pnlComplete.Visible = true; //this.pnlMain.Visible = false; } } catch (MerchantTribe.Commerce.Accounts.CreateStoreException cex) { RenderError("storename", cex.Message, model); } } }
private void RenderStore(Store s, StringBuilder sb) { bool isIndividual = MerchantTribe.Commerce.WebAppSettings.IsIndividualMode; if (s != null) { sb.Append("<tr>"); sb.Append("<td>" + s.Settings.FriendlyName + "</td>"); if (!isIndividual) { if (s.DateCancelled.HasValue) { sb.Append("<td>Cancelled " + s.DateCancelled.Value.ToShortDateString() + "</td>"); } else { sb.Append("<td>" + s.PlanName + " " + s.CurrentPlanRate.ToString("c") + "/month + " + s.CurrentPlanPercent + "%<br />"); sb.Append("<a href=\"" + s.RootUrlSecure() + "bvadmin/ChangePlan.aspx\">Change Plans</a>"); sb.Append("</td>"); } sb.Append("<td><a href=\"CancelStore.aspx?id=" + s.Id + "\">Cancel</a></td>"); } sb.Append("<td><a target=\"_blank\" href=\"" + s.RootUrl() + "\">View Store</a></td>"); sb.Append("<td><a target=\"_blank\" href=\"" + s.RootUrlSecure() + "bvadmin\">Admin</a></td>"); sb.Append("</tr>"); } }
private void DoSignUp(RegisterViewModel model) { bool storeOkay = false; MerchantTribe.Commerce.Accounts.Store testStore = new MerchantTribe.Commerce.Accounts.Store(); testStore.StoreName = model.RegistrationData.storename; if (!testStore.IsValid()) { foreach (MerchantTribe.Web.Validation.RuleViolation v in testStore.GetRuleViolations()) { RenderError(v, model); } } else { if (MTApp.AccountServices.StoreNameExists(testStore.StoreName)) { RenderError("storename", "A store with that name already exists. Choose another name and try again.", model); } else { storeOkay = true; } } UserAccount u = MTApp.AccountServices.AdminUsers.FindByEmail(model.RegistrationData.email); if (u == null) { u = new MerchantTribe.Commerce.Accounts.UserAccount(); } bool userOk = false; if (u.IsValid() && (u.Email == model.RegistrationData.email)) { if (u.DoesPasswordMatch(model.RegistrationData.password)) { userOk = true; } else { RenderError("email", "A user account with that email address already exists. If it's your account make sure you enter the exact same password as you usually use.", model); } } else { u = new MerchantTribe.Commerce.Accounts.UserAccount(); u.Email = model.RegistrationData.email; u.HashedPassword = model.RegistrationData.password; if (u.IsValid()) { u.Status = MerchantTribe.Commerce.Accounts.UserAccountStatus.Active; u.DateCreated = DateTime.UtcNow; userOk = MTApp.AccountServices.AdminUsers.Create(u); u = MTApp.AccountServices.AdminUsers.FindByEmail(u.Email); } else { foreach (MerchantTribe.Web.Validation.RuleViolation v in u.GetRuleViolations()) { RenderError(v.ControlName, v.ErrorMessage, model); } } } if (userOk && storeOkay) { try { bool isPayPalLead = false; if (MerchantTribe.Commerce.SessionManager.GetCookieString("PayPalLead", MTApp.CurrentStore) != string.Empty) { isPayPalLead = true; } decimal rate = 0; HostedPlan thePlan = HostedPlan.FindById(model.RegistrationData.plan); if (thePlan != null) { rate = thePlan.Rate; if (isPayPalLead) { rate = 49; } } MerchantTribe.Commerce.Accounts.Store s = MTApp.AccountServices.CreateAndSetupStore(model.RegistrationData.storename, u.Id, model.RegistrationData.storename + " store for " + model.RegistrationData.email, model.RegistrationData.plan, rate); if (s != null) { string e = MerchantTribe.Web.Cryptography.Base64.ConvertStringToBase64(u.Email); string st = MerchantTribe.Web.Cryptography.Base64.ConvertStringToBase64(s.StoreName); Response.Redirect("~/signup/ProcessSignUp?e=" + e + "&s=" + st); } } catch (MerchantTribe.Commerce.Accounts.CreateStoreException cex) { RenderError("storename", cex.Message, model); } } }
private Store CreateIndividualStore() { Store s = null; string storeName = "www"; s = new Store(); s.StoreName = Text.ForceAlphaNumericOnly(storeName).ToLower(); s.Status = StoreStatus.Active; s.DateCreated = DateTime.UtcNow; s.PlanId = 99; 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) { UserAccount mainAccount = new UserAccount(); mainAccount.Email = "*****@*****.**"; mainAccount.HashedPassword = "******"; mainAccount.Status = UserAccountStatus.Active; AdminUsers.Create(mainAccount); mainAccount = AdminUsers.FindByEmail(mainAccount.Email); AddUserToStore(s.Id, mainAccount.Id, StoreAccessMode.Owner); s.Settings.FriendlyName = "My MerchantTribe Store"; 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; s.Settings.MailServer.EmailForGeneral = mainAccount.Email; s.Settings.MailServer.EmailForNewOrder = mainAccount.Email; s.Settings.MailServer.UseCustomMailServer = false; s.Settings.ProductReviewCount = 3; s.Settings.ProductReviewModerate = true; s.Settings.ProductReviewShowRating = true; s.Settings.PayPal.FastSignupEmail = mainAccount.Email; s.Settings.PayPal.Currency = "USD"; s.Settings.MaxItemsPerOrder = 999; s.CurrentPlanRate = 0; s.CurrentPlanDayOfMonth = DateTime.Now.Day; s.CurrentPlanPercent = 0; // Save data to store Stores.Update(s); // No longer need to redirect because home controller handles this //System.Web.HttpContext.Current.Response.Redirect("~/adminaccount/login?wizard=1"); // Force this store into the request context so // non-repository datalayer will read in the correct // store id //RequestContext demoContext = new RequestContext(); //demoContext.CurrentStore = s; //RequestContext.ForceCurrentRequestContext(demoContext); //// Add Sample Data //AddSampleProductsToStore(demoContext); //// Set a default theme //Content.ThemeManager m = new Content.ThemeManager(demoContext); //m.InstallTheme("cf09d318-3792-47b8-a207-a9502f96f0f9"); } return(s); }
public static string GetCurrentUserId(Store currentStore, HttpCookieCollection cookies) { string result = string.Empty; result = GetCookieString(WebAppSettings.CookieNameAuthenticationTokenCustomer(currentStore.Id), currentStore, cookies); return result; }
public static void SetCookieString(string cookieName, string value, Store currentStore, DateTime expirationDate, bool secure) { if (HttpContext.Current != null) { if (HttpContext.Current.Request.Browser.Cookies == true) { try { if (currentStore.Settings.CookieDomain.Trim() != string.Empty) { string domain = System.Text.RegularExpressions.Regex.Replace(currentStore.Settings.CookieDomain, "[^A-Za-z0-9]", ""); cookieName = cookieName + domain; } if (currentStore.Settings.CookiePath != string.Empty) { string path = System.Text.RegularExpressions.Regex.Replace(currentStore.Settings.CookiePath, "[^A-Za-z0-9]", ""); cookieName = cookieName + path; } System.Web.HttpCookie saveCookie = new System.Web.HttpCookie(cookieName, value); if (currentStore.Settings.CookieDomain.Trim() != string.Empty) { saveCookie.Domain = currentStore.Settings.CookieDomain; } if (currentStore.Settings.CookiePath.Trim() != string.Empty) { saveCookie.Path = currentStore.Settings.CookiePath; } saveCookie.Expires = expirationDate; saveCookie.Secure = secure; HttpContext.Current.Response.Cookies.Add(saveCookie); } catch (Exception Ex) { EventLog.LogEvent(Ex); } } } }
public static long CurrentAffiliateID(Store currentStore) { string temp = GetCookieString(WebAppSettings.CustomerIdCookieName + "Referrer", currentStore); long result = 0; long.TryParse(temp, out result); return result; }
public static void SetCurrentCartId(Store currentStore, string value) { SetCookieString(WebAppSettings.CookieNameCartId(currentStore.Id), value, currentStore); }
public static Orders.Order CurrentShoppingCart(Orders.OrderService svc, Store currentStore) { Orders.Order result = null; if (CurrentUserHasCart(currentStore)) { Orders.Order cachedCart = SessionManager.CachedShoppingCart; if (cachedCart != null) { return cachedCart; } else { result = svc.Orders.FindForCurrentStore(GetCurrentCartID(currentStore)); if (result != null) { if (!result.IsPlaced) { if (result.bvin != string.Empty) { SessionManager.CachedShoppingCart = result; return result; } } } } } result = new Orders.Order(); svc.Orders.Upsert(result); SetCurrentCartId(currentStore, result.bvin); SessionManager.CachedShoppingCart = result; return result; }
public static bool CurrentUserHasCart(Store currentStore) { bool result = false; if (GetCurrentCartID(currentStore) == string.Empty) { result = false; } else { result = true; } return result; }
// Store public static void AddStore(Accounts.Store store) { StoreItem <Accounts.Store>("store-" + store.Id, store, 60); }
public static string GetCookieString(string cookieName, Store currentStore) { try { if (HttpContext.Current != null) { if (HttpContext.Current.Request != null) { if (HttpContext.Current.Request.Browser.Cookies == true) { var cookies = HttpContext.Current.Request.Cookies; return GetCookieString(cookieName, currentStore, cookies); } } } } catch { return string.Empty; } return string.Empty; }
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; }
public static string GetCookieString(string cookieName, Store currentStore, HttpCookieCollection cookies) { string result = string.Empty; if (cookies == null) return string.Empty; try { if (currentStore.Settings.CookieDomain.Trim() != string.Empty) { string domain = System.Text.RegularExpressions.Regex.Replace(currentStore.Settings.CookieDomain, "[^A-Za-z0-9]", ""); cookieName = cookieName + domain; } if (currentStore.Settings.CookiePath != string.Empty) { string path = System.Text.RegularExpressions.Regex.Replace(currentStore.Settings.CookiePath, "[^A-Za-z0-9]", ""); cookieName = cookieName + path; } HttpCookie checkCookie; checkCookie = cookies[cookieName]; if (checkCookie != null) { result = checkCookie.Value; } checkCookie = null; } catch { result = string.Empty; } return result; }
private bool DowngradePlan(Store s, UserAccount a, HostedPlan newPlan, MerchantTribeApplication app) { int currentProductCount = app.CatalogServices.Products.FindAllCount(s.Id); if (currentProductCount > newPlan.MaxProducts) return false; s.CurrentPlanRate = newPlan.Rate; s.CurrentPlanPercent = newPlan.PercentageOfSales; //s.CurrentPlanDayOfMonth = DateTime.Now.Day; //if (s.CurrentPlanDayOfMonth > 28) s.CurrentPlanDayOfMonth = 28; s.PlanId = newPlan.Id; bool result = Stores.Update(s); if (result) { // Charge Card // Notify Admin of Change Utilities.MailServices.SendPlanDowngradeAlert(a, s); } return result; }
public static string GetCurrentCartID(Store currentStore) { string result = string.Empty; result = GetCookieString(WebAppSettings.CookieNameCartId(currentStore.Id), currentStore); return result; }
public static string GetCurrentPaymentPendingCartId(Store currentStore) { return GetCookieString(WebAppSettings.CookieNameCartIdPaymentPending(currentStore.Id), currentStore); }
public Store CreateAndSetupStore(string storeName, long userAccountId, string friendlyName, int plan, decimal rate ) { 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); Utilities.MailServices.SendLeadAlert(u, s); Utilities.MailServices.SendAccountInformation(u, s); } return(s); }