public ActionResult BillingOnboard(OnboardToken token) { OnboardToken retrievedToken = RepoFactory.GetOnboardTokenRepo().Get(token.VerificationString); Customer cust = RepoFactory.GetCustomerRepo().GetWithID(retrievedToken.CustomerID); // hardcode stripe for now, sucka StripeClient client = new StripeClient("LB3kUwdhiUlPlNl1UYW52NLn4q88QsFT"); Stripe.CreditCardToken ccToken = new Stripe.CreditCardToken(token.BillingID); var stripeCustomer = client.CreateCustomer(ccToken, email: cust.EmailAddress); cust.BillingType = (int)BillingSystem.BillingProcessorFactory.SupportedBillingProcessor.Stripe; cust.BillingID = stripeCustomer.GetProperty("ID").ToString(); RepoFactory.GetCustomerRepo().Update(cust); CustomerController.CustomerSignupResult result = new CustomerController.CustomerSignupResult(); result.Result = CustomerController.CustomerSignupResult.ResultCode.Success; result.Customer = cust; if (retrievedToken.ChallengeID != 0) { Security s = new Security(); Authorization a=s.AuthorizeCustomer(new Login { EmailAddress = cust.EmailAddress, Password = cust.Password }); return Redirect("http://dareme.to/authorize?id="+a.CustomerID.ToString()+"&session_token="+a.Token+"&dare=" + retrievedToken.ChallengeID.ToString()); } else { return View("SignupComplete", result); } }
public void Update(OnboardToken token) { OnboardTokenDb d = new OnboardTokenDb(token); context.AttachTo(TableName, d, null); context.UpdateObject(d); context.SaveChangesWithRetries(); }
public void Remove(OnboardToken token) { OnboardTokenDb d = new OnboardTokenDb(token); context.AttachTo(TableName, d); context.DeleteObject(d); context.SaveChangesWithRetries(); }
public bool Complete(OnboardToken t) { ICustomerRepository custRepo = RepoFactory.GetCustomerRepo(); Customer c = custRepo.GetWithID(t.CustomerID); Customer custCheck = custRepo.GetWithEmailAddress(t.EmailAddress.ToLower().Trim()); c.Type = (int)Customer.TypeCodes.Default; // check for email address in use if (custCheck != null && custCheck.Type != (int)Customer.TypeCodes.Unclaimed) { Security s = new Security(); Authorization a = s.AuthorizeCustomer(new Login { EmailAddress = t.EmailAddress, Password = t.Password }); if (a != null && a.Valid) { System.Diagnostics.Trace.WriteLine("Moving challenges from " + c.ID.ToString() + " to " + a.CustomerID.ToString()); // zomg u're real custRepo.AddForeignNetworkForCustomer(a.CustomerID, t.ForeignUserID, (Customer.ForeignUserTypes)t.AccountType); // we need to collapse the unclaimed account into the one we just found. RepoFactory.GetChallengeRepo().MoveChallengesToCustomer(c.ID, a.CustomerID); RepoFactory.GetChallengeStatusRepo().MoveStatusesToNewCustomer(c.ID, a.CustomerID); // now that we've moved the challenges, delete the original customer custRepo.Remove(c.ID); return true; } else return false; } else if (custCheck != null && custCheck.Type == (int)Customer.TypeCodes.Unclaimed) { c = custCheck; c.Type = (int)Customer.TypeCodes.IncompleteOnboard; } c.EmailAddress = t.EmailAddress.ToLower().Trim(); c.FirstName = t.FirstName; c.LastName = t.LastName; c.Password = t.Password; custRepo.Update(c); custRepo.AddForeignNetworkForCustomer(c.ID, t.ForeignUserID, (Customer.ForeignUserTypes)t.AccountType); if (t.ChallengeID != 0) { DareManager dmgr = new DareManager(); dmgr.Accept(t.ChallengeID, c.ID); } return true; }
public OnboardToken Get(string VerificationString) { OnboardTokenDb d=(from e in context.CreateQuery<OnboardTokenDb>(TableName) where e.PartitionKey==VerificationString select e).FirstOrDefault(); OnboardToken t = new OnboardToken(); t.AccountType = d.AccountType; t.ChallengeID = d.ChallengeID; t.ChallengeStatusUniqueKey = d.ChallengeStatusUniqueKey; t.CustomerID = d.CustomerID; t.EmailAddress = d.EmailAddress; t.Token = d.Token; t.Secret = d.Secret; t.VerificationString = d.VerificationString; t.FirstName = d.FirstName; t.LastName = d.LastName; t.Password = d.Password; t.AvatarURL = d.AvatarURL; t.ForeignUserID = d.ForeignUserID; return t; }
public OnboardTokenDb(OnboardToken t) { this.PartitionKey = t.VerificationString; this.RowKey = "Cust" + t.CustomerID; this.AccountType = t.AccountType; this.CustomerID = t.CustomerID; this.VerificationString = t.VerificationString; this.ForeignUserID = t.ForeignUserID; this.Token = t.Token; this.Secret = t.Secret; this.ChallengeID = t.ChallengeID; this.ChallengeStatusUniqueKey = t.ChallengeStatusUniqueKey; this.EmailAddress = t.EmailAddress; this.FirstName = t.FirstName; this.LastName = t.LastName; this.Password = t.Password; this.AvatarURL = t.AvatarURL; }
private void SafeUpdateOnboardToken(OnboardToken tok) { // only allows the updating of the email address, first name and last name fields OnboardToken updateToken = new OnboardToken(); updateToken.CustomerID = tok.CustomerID; updateToken.VerificationString = tok.VerificationString; updateToken.FirstName = tok.FirstName; updateToken.LastName = tok.LastName; updateToken.EmailAddress = tok.EmailAddress; RepoFactory.GetOnboardTokenRepo().Update(updateToken); }
public ActionResult StartSignup(long ChallengeID=0, int DoBilling=0) { OnboardToken token = new OnboardToken(); token.ChallengeID = ChallengeID; if (DoBilling == 1) token.AccountType = 1; return View("StartSignup", token); }
public ActionResult Signup(SignupCustomer newCustomer) { CustomerController custCtl = new CustomerController(); CustomerController.CustomerSignupResult result = custCtl.HandleCredentialSignup(newCustomer); if (result.Result != CustomerController.CustomerSignupResult.ResultCode.Success) return View("SignupFailed"); if (newCustomer.AccountType == 1) { OnboardToken newToken = new OnboardToken() { CustomerID = result.Customer.ID, VerificationString = System.Guid.NewGuid().ToString(), ChallengeID=newCustomer.ChallengeID }; RepoFactory.GetOnboardTokenRepo().Add(newToken); return View("BillingOnboard", newToken); } else return View("SignupComplete", result); }
public ActionResult Complete(OnboardToken t) { OnboardToken origToken = RepoFactory.GetOnboardTokenRepo().Get(t.VerificationString); if (origToken == null) return new HttpStatusCodeResult(System.Net.HttpStatusCode.Forbidden); origToken.EmailAddress = t.EmailAddress; origToken.Password = t.Password; origToken.FirstName = t.FirstName; origToken.LastName = t.LastName; if (_obm.Complete(origToken)) { return View(); } else return new HttpStatusCodeResult(System.Net.HttpStatusCode.Forbidden); }
public OnboardResult CompleteFirstStepForeignUserOnboard(string handle, Customer.ForeignUserTypes type, string token = null, string tokenSecret = null) { OnboardResult r = new OnboardResult(); Customer c = RepoFactory.GetCustomerRepo().GetWithForeignUserID(handle, type); if (c == null) { Customer newCust = new Customer() { ForeignUserID = handle, ForeignUserType = (int)type, Type = (int)Customer.TypeCodes.Unclaimed, BillingType = (int)BillingSystem.BillingProcessorFactory.SupportedBillingProcessor.None }; newCust.ID = RepoFactory.GetCustomerRepo().Add(newCust); RepoFactory.GetCustomerRepo().AddForeignNetworkForCustomer(newCust.ID, handle, type); r.Customer = newCust; } else { // we don't put this in the repo, we're just // using it as a DTO to get the token and secret // back to the controller r.Customer = c; } OnboardToken newToken = new OnboardToken() { CustomerID = r.Customer.ID, VerificationString = System.Guid.NewGuid().ToString(), Token = token, Secret = tokenSecret, AccountType = (int)type, ForeignUserID = handle }; RepoFactory.GetOnboardTokenRepo().Add(newToken); r.OnboardToken = newToken; return r; }