public async Task <ActionResult> activate_promo(string p) { string s = System.Configuration.ConfigurationManager.AppSettings["MaxLevel"]; p = p.Replace("$25", "/"); p = p.Replace("$24", "+"); string DecryptId = Cryptoclass.DecryptStringAES(p, s); INISubcriberExtraDetail u = db.INISubcriberExtraDetails.Find(DecryptId); if (u.Promotional_Target_Subscription_Status != "Active") { u.Promotional_Target_Subscription_Status = "Active"; u.Promo_start_date = DateTime.UtcNow; u.Promo_end_date = DateTime.UtcNow.AddDays(30); await db.SaveChangesAsync(); TempData["success"] = "iHealth Networking Group Promo Activation is successful"; } else { TempData["error"] = "ERROR: Your promotional period is still active."; } return(View("UserpanelCarreer")); }
public async Task <ActionResult> ing_pmt_response_status(string txnref, string apprAmt) { try { var input = string.Concat(hc.product_id, txnref, hc.Mac_key); var hash = Cryptoclass.GenerateSHA512String(input); string response_url = hc.interswitchJson + txnref + "&amount=" + apprAmt + ""; ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; var client = new WebClient(); client.Headers.Add("Hash", hash); var content = client.DownloadString(response_url); // Create the Json serializer and parse the response DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(PaymentResponse)); using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(content))) { var pmtData = (PaymentResponse)serializer.ReadObject(ms); if (pmtData.ResponseCode == "00") { INISubcriberExtraDetail iniSubExtDetails = db.INISubcriberExtraDetails.Single(s => s.transaction_Id == txnref); iniSubExtDetails.PaymentStatus = "Paid"; iniSubExtDetails.INI_Status = "ACTIVE"; iniSubExtDetails.BEstatus = "Active"; iniSubExtDetails.Transaction_date = Convert.ToDateTime(pmtData.TransactionDate); iniSubExtDetails.Amounts = Convert.ToInt32(apprAmt); iniSubExtDetails.Amounts /= 100; //check if the new member has a sponsor so that we can give the sponsor bonus if (!string.IsNullOrEmpty(iniSubExtDetails.My_Sponsor_Referral_Code)) { //retrieve the sponsor of this new member details from the users table var sponsor = db.Users.Single(u => u.MyRefferalCode.ToString() == iniSubExtDetails.My_Sponsor_Referral_Code); //check if sponsor is an ihealth networking subscriber, so dt we can give him credit var sp_IN_mlm = db.INISubcriberExtraDetails.Single(sp => sp.User.Id == sponsor.Id); //this check if the sponsor of this new member subscribe for ING promotion target //if yes, we increase the number of downlines within the promo period //ELSE, we will only increase the number of downlines outside the promo period. // still increases./ if (sp_IN_mlm.Promotional_Target_Subscription_Status == "Active") { sp_IN_mlm.promo_dl_size = sp_IN_mlm.promo_dl_size + 1; } else { sp_IN_mlm.Non_promo_dl_size = sp_IN_mlm.Non_promo_dl_size + 1; } sp_IN_mlm.Total_dl_Size = sp_IN_mlm.Total_dl_Size + 1; sp_IN_mlm.Most_recent_DL_Reg_date = DateTime.UtcNow; await db.SaveChangesAsync(); referral_BonusTb refbonus = new referral_BonusTb(); refbonus.user_ID = sponsor.Id; refbonus.Downline_Id = iniSubExtDetails.User.MyRefferalCode; refbonus.Downline_Name = iniSubExtDetails.User.FirstName + " " + iniSubExtDetails.User.LastName; refbonus.Bonus_Type = "Ihealth Networking Referral Bonus"; refbonus.Subscription_Fee = iniSubExtDetails.Amounts; refbonus.Bonus = refbonus.Subscription_Fee * 0.5; // bonus is 50% of the subscription //refbonus.totalBonus = refbonus.totalBonus + refbonus.Bonus; refbonus.Bonus_created_date = DateTime.UtcNow; //check if the sponsor of this new member is currently subscribe to ING promo target if (sp_IN_mlm.Promotional_Target_Subscription_Status == "Active") { refbonus.promo_period_bonus = true; } db.referral_bonus_tb.Add(refbonus); await db.SaveChangesAsync(); sp_IN_mlm.CurrentBonus = sp_IN_mlm.CurrentBonus + (refbonus.Subscription_Fee * 0.5); await db.SaveChangesAsync(); } await db.SaveChangesAsync(); var iswtb = db.InterswtichTransactionsTables.Single(s => s.Transaction_Id == txnref); iswtb.Transaction_ResponseCode = pmtData.ResponseCode; iswtb.Transaction_Response = pmtData.ResponseDescription; await db.SaveChangesAsync(); StringBuilder sb = new StringBuilder(); //Assign user to Role if not already added var UserRole = UserManager.GetRoles(iniSubExtDetails.User.Id); if (!UserRole.Contains("INIsubscribers")) { var addToRole = UserManager.AddToRole(iniSubExtDetails.User.Id, "INIsubscribers"); } await SignInManager.SignInAsync(iniSubExtDetails.User, isPersistent : false, rememberBrowser : false); string code = await UserManager.GenerateEmailConfirmationTokenAsync(iniSubExtDetails.User.Id); var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = iniSubExtDetails.User.Id, code = code }, protocol: Request.Url.Scheme); await UserManager.SendEmailAsync(iniSubExtDetails.User.Id, "Confirm your account", em.Notification_Email_Body_Creator(iniSubExtDetails.User.FullName, "<div><p style=\" font-size: large\">Welcome to iHealth Networking Group, please kindly confirm your account by clicking on this <a href=\"" + callbackUrl + "\"> here.</a><br/><br/>Thanks for registering with us.<br/><br/> Best Regards, <br/><br/>iHealth Nigeria GSFM Team.</p></div>")); ViewBag.tRef = txnref; ViewBag.pRef = pmtData.PaymentReference; ViewBag.Message = sb.Append("<p><span style=\"color:green\">Awesome !!!</span> You have Successfully SIGN UP for <b>iHEALTH NETWORKING INSURANCE</b>. kindly," + "Check your <span style=\"color:Red\">email inbox OR spam folder</span> to confirm your account within 24 hours.<strong> You must be confirmed " + "before you can log in.<strong></p>").ToString(); return(View("payment_Status")); // return PartialView("_PaymentSuccess"); } else { var iswtb = db.InterswtichTransactionsTables.Single(s => s.Transaction_Id == txnref); iswtb.Transaction_Response = pmtData.ResponseDescription; iswtb.Transaction_ResponseCode = pmtData.ResponseCode; await db.SaveChangesAsync(); INISubcriberExtraDetail inidetatils = db.INISubcriberExtraDetails.Single(s => s.transaction_Id == txnref); if (inidetatils.PaymentStatus != "Paid") { //remove about to registered member from community, since they refuse to pay online ApplicationUser newuser = db.Users.Find(inidetatils.User.Id); db.INISubcriberExtraDetails.Remove(inidetatils); db.Users.Remove(newuser); await db.SaveChangesAsync(); ViewBag.responseMsg = pmtData.ResponseDescription; ViewBag.tRef = txnref; ViewBag.pRef = pmtData.PaymentReference; ViewBag.partial = "_PaymentFail"; return(View("payment_Status")); } else { return(RedirectToAction("index", "home")); } } } } catch (Exception ex) { throw ex; } }
public async Task <ActionResult> UgradeForm(UpgradeFormViewModel model, FormCollection f) { string username = Session["Id"].ToString(); var usr = UserManager.FindById(username); if (usr == null) { return(HttpNotFound("Requested user not found")); } #region try { Random rd = new Random(); int trackId = rd.Next(10000000); var response = Request["g-recaptcha-response"]; // const string secret = "6LeP9hETAAAAAPhx2dmOL4eB6euPe_hLvOw1UaBH"; string secret = System.Configuration.ConfigurationManager.AppSettings["recaptchaPrivateKey"]; var client = new WebClient(); var reply = client.DownloadString( string.Format("https://www.google.com/recaptcha/api/siteverify?secret={0}&response={1}", secret, response)); var captchaResponse = JsonConvert.DeserializeObject <reCaptchaClass>(reply); StringBuilder sb = new StringBuilder(); if (ModelState.IsValid) { //int profVal = Convert.ToInt32(f["Profession"]); //var prof = await db.Profession.FindAsync(profVal); if (!captchaResponse.Success) { if (captchaResponse.ErrorCodes.Count <= 0) { return(View()); } ; var error = captchaResponse.ErrorCodes[0].ToLower(); switch (error) { case ("missing-input-secret"): ViewBag.Message = "The secret parameter is missing."; break; case ("invalid-input-secret"): ViewBag.Message = "The secret parameter is invalid or malformed."; break; case ("missing-input-response"): ViewBag.Message = "The response parameter is missing."; break; case ("invalid-input-response"): ViewBag.Message = "The response parameter is invalid or malformed."; break; default: ViewBag.Message = "Error occured. Please try again"; break; } ModelState.AddModelError("", "You did not type the verification word correctly. Please try again."); } else { string Username = usr.UserName; //the REFURL stores the newly registering User Unique URL which he or She can Share with Others to // register on Ihealth Networking Insurance var RefUrl = this.Url.Action("INIRegform", "Account", new { sp = Username }, this.Request.Url.Scheme); //var con3ID = Convert.ToInt32(f["Country"]); //var con3 = await db.country.FindAsync(con3ID); //var st_Id = Convert.ToInt32(f["State"]); //var st = await db.State.FindAsync(st_Id); usr.RegDate = DateTime.UtcNow; usr.NotifyStatus = 0; usr.Gender = model.Gender; //usr.Nationality = con3.CountryName; //usr.State = st.StateName; usr.Refferal_Url = RefUrl; usr.UserType = "INISubcriber"; usr.EmailConfirmed = false; //this method Update Normal user records who is upgrading to ING Subcriber status var result = await UserManager.UpdateAsync(usr); if (result.Succeeded) { INISubcriberExtraDetail iniSubExtDetails = new INISubcriberExtraDetail(); // If Newly registering Subcriber has a sponsor if (f["RefCode"] != "") { int SpCode = Convert.ToInt32(f["RefCode"]); //Retrieve sponsor Tracking ID var Sponsor = db.Users.First(u => u.MyRefferalCode == SpCode); //Add newly registering Subscriber to INISubscriberExtraDetails tb along with sponsor refcode iniSubExtDetails.My_Sponsor_Referral_Code = SpCode.ToString(); ////check if sponsor already exist in d iniSubExtDetails tb, so dt we can give him credit //var sp_IN_mlm = db.INISubcriberExtraDetails.Where(sp => sp.User.Id == Sponsor.Id); //if (sp_IN_mlm.Count() > 0) //{ // try // { // INISubcriberExtraDetail spIniSubExtDetails = db.INISubcriberExtraDetails.First(sp => sp.User.Id == Sponsor.Id); // //this check if the sponsor of this new member subscribe for ING promotion target // //if yes, we give the sponsor a promo credit for his/her referral within the promo // //period, ELSE, nothin is added but noth withstanding the dl size of the sponsor // // still increases./ // if (spIniSubExtDetails.Promotional_Target_Subscription_Status == "Active") // { // spIniSubExtDetails.promo_dl_size = spIniSubExtDetails.promo_dl_size + 1; // } // spIniSubExtDetails.Total_dl_Size = spIniSubExtDetails.Total_dl_Size + 1; // spIniSubExtDetails.Most_recent_DL_Reg_date = DateTime.UtcNow.Date; // await db.SaveChangesAsync(); // } // catch (Exception ex) // { // throw ex; // } //} //// Session["sp"] = null; } // If Newly registering Subcriber does not have sponsor // Newly registering Subscriber is added to INISubcriberExtraDetail tb where sponsor id is null if (f["PaymentOptions"] == "PayToBank") { iniSubExtDetails.UserID = usr.Id; iniSubExtDetails.paymentMethod = f["PaymentOptions"]; iniSubExtDetails.transaction_Id = string.Concat("ING-", rd.Next(999999)); //Payment status is set to pending until the user payment has been confirm from banks. iniSubExtDetails.PaymentStatus = "Pending"; iniSubExtDetails.INI_Status = "InActive"; iniSubExtDetails.BEstatus = "InActive"; //if (f["BenefitCategory"] == "CarreerBenefit") //{ iniSubExtDetails.BenefitCategory = "CarreerBenefit"; // iniSubExtDetails.MaxDT2MtTarget = DateTime.UtcNow.AddDays(90); //} //else //{ // iniSubExtDetails.BenefitCategory = f["BenefitCategory"]; // iniSubExtDetails.CurrentStage = "Starter"; // iniSubExtDetails.Stage1Benefit = "No Benefit"; // iniSubExtDetails.Stage2Benefit = "No Benefit"; // iniSubExtDetails.Stage3Benefit = "No Benefit"; // iniSubExtDetails.Stage4Benefit = "No Benefit"; // iniSubExtDetails.Stage5Benefit = "No Benefit"; //} iniSubExtDetails.CurrentBenefit = "No Benefit"; iniSubExtDetails.Total_dl_Size = 0; db.INISubcriberExtraDetails.Add(iniSubExtDetails); await db.SaveChangesAsync(); // After Payment has been made and confirm by Ihealth official the Payment status is set to Paid //Assign user to Role if not already added var u = UserManager.FindById(usr.Id); //this next lines of code delete the newly upgraded user details from IhealthUserMLM table //Note: the ihealthUserMLM table is the tb that store normal users downlines size IHealthUsersMLM delUserFromThisTable = await db.IHealthUsersMLM.FindAsync(u.Id); db.IHealthUsersMLM.Remove(delUserFromThisTable); await db.SaveChangesAsync(); //this next line of codes modify upgrading user roles from User to INIsubscribers var uOldRoleID = u.Roles.SingleOrDefault().RoleId; var uOldRoleName = db.Roles.SingleOrDefault(r => r.Id == uOldRoleID).Name; if (uOldRoleName != "INIsubscribers") { UserManager.RemoveFromRole(u.Id, uOldRoleName); var addrole = await UserManager.AddToRoleAsync(u.Id, "INIsubscribers"); } await UserManager.SendEmailAsync(usr.Id, "Ihealth Networking Group", em.Notification_Email_Body_Creator(usr.FullName, "<h2>WELCOME TO IHEALTH NETWORKIING GROUP<h2/>" + " <p>Thank you for signing up for IHEALTH NETWORKING GROUP.</p> " + "<p>But you are not yet activated. Kindly, pay into the account below:-<br/>" + "ACCOUNT NUMBER: " + acctno + "<br/>ACCOUNT NAME: " + AcctName + "<br/> BANK:" + bankName + " <br/>" + "</p><p>After payment is made, kindly email the information below to <a href=\"mailto:[email protected]\">[email protected]</a><br/> (a) Name of Depositor <br/>" + "(b)Teller Number <br/>(c)Your Membership ID: " + usr.MyRefferalCode + " <br/> (d) Amount <br/> (e) Date of Payment</p><br/> Thanks for registering with us<br/><br/>Best Regards, <br/><br/> iHealth Nigeria GSFM Team.")); ViewBag.Message = sb.Append("<span style=\"color:green\">Awesome !!!</span> You have Successfully <br/>SIGN UP for <b>iHEALTH NETWORKING <br/> GROUP</b>.kindly," + " Check your <span style=\"color:Red\">email inbox OR <br/> spam folder</span> for more information ").ToString(); AuthenticationManager.SignOut(); Session.Clear(); return(View("Info")); } else { iniSubExtDetails.UserID = usr.Id; iniSubExtDetails.paymentMethod = f["PaymentOptions"]; iniSubExtDetails.transaction_Id = string.Concat("ING-", rd.Next(999999)); iniSubExtDetails.PaymentStatus = "Pending"; iniSubExtDetails.INI_Status = "InActive"; iniSubExtDetails.BEstatus = "InActive"; iniSubExtDetails.paymentMethod = f["PaymentOptions"]; iniSubExtDetails.paymentGateway = "Interswitch"; iniSubExtDetails.CurrentBenefit = "No Benefit"; iniSubExtDetails.Total_dl_Size = 0; iniSubExtDetails.BenefitCategory = "CarreerBenefit"; db.INISubcriberExtraDetails.Add(iniSubExtDetails); await db.SaveChangesAsync(); InterswitchTransactionsTB iswtb = new InterswitchTransactionsTB(); iswtb.Client_Name = usr.FirstName; iswtb.Client_Email = usr.Email; iswtb.Transaction_Amount = amount.ToString(); iswtb.Transaction_date = DateTime.Now.Date; iswtb.Transaction_purpose = "Ihealth Networking Group Subscription"; iswtb.Transaction_Id = iniSubExtDetails.transaction_Id; db.InterswtichTransactionsTables.Add(iswtb); await db.SaveChangesAsync(); TempData["cust_id"] = usr.Id; TempData["Amount"] = amount; TempData["trans_id"] = iniSubExtDetails.transaction_Id; TempData["cust_name"] = usr.FullName; return(Redirect("/PaymentGateways/upgradeGateway")); } } AddErrors(result); } } return(View(new UpgradeFormViewModel { FirstName = usr.FirstName, LastName = usr.LastName, Email = usr.Email, PhoneNumber = usr.PhoneNumber, Username = usr.UserName, })); } catch (Exception ex) { throw ex; } #endregion }