예제 #1
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);
                }
            }
        }
        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);
                }
            }
        }
예제 #3
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);
                }
            }
        }
예제 #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);
                }
            }
        }