Beispiel #1
0
        private void AddPlanDetails(RegisterViewModel model)
        {
            string   PlanDescription = "You are signing up for the <strong>{0}</strong> plan. {2}Your card will be charged <strong>{1}</strong> today and each month after on this day until you cancel.";
            DateTime expires         = MerchantTribe.Web.Dates.MaxOutTime(DateTime.Now).AddMonths(1);

            HostedPlan thePlan = HostedPlan.FindById(model.RegistrationData.plan);

            if (thePlan != null)
            {
                string PayPalLead = string.Empty;
                PayPalLead = MerchantTribe.Commerce.SessionManager.GetCookieString("PayPalLead", MTApp.CurrentStore);

                if (thePlan.Id == 0)
                {
                    model.RegistrationData.plandetails = String.Format(PlanDescription, "Free Plan", "$0", "Free plans are never charged. ");
                }
                else
                {
                    if (PayPalLead != string.Empty)
                    {
                        model.RegistrationData.plandetails = String.Format(PlanDescription, thePlan.Name, 49.ToString("c"), "");
                    }
                    else
                    {
                        model.RegistrationData.plandetails = String.Format(PlanDescription, thePlan.Name, thePlan.Rate.ToString("c"), "");
                    }
                }
            }
        }
Beispiel #2
0
        private bool CheckMax(int newPlan)
        {
            int        current = MTApp.CatalogServices.Products.FindAllCount();
            HostedPlan p       = HostedPlan.FindById(newPlan);

            if (current > p.MaxProducts)
            {
                this.MessageBox1.ShowWarning("You have too many products to downgrade to that plan. Remove some products first.");
                return(false);
            }

            return(true);
        }
Beispiel #3
0
        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 &raquo; Choose a Theme</a>";
                        //this.pnlComplete.Visible = true;
                        //this.pnlMain.Visible = false;
                    }
                }
                catch (MerchantTribe.Commerce.Accounts.CreateStoreException cex)
                {
                    RenderError("storename", cex.Message, model);
                }
            }
        }
Beispiel #4
0
        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);
                }
            }
        }