Пример #1
0
        public async Task <JsonResult> ApprovePayment(IEnumerable <string> markAsPaidbyId)
        {
            try
            {
                #region
                if (markAsPaidbyId != null)
                {
                    if (markAsPaidbyId.Count() > 0)
                    {
                        foreach (var id in markAsPaidbyId)
                        {
                            var usrpaid = db.premium_user.Single(u => u.premiumUserId == id);
                            //check if the premium client's email already exist in registered users table is an ING member
                            var is_Premium_User_Registered_in_all_user_db = db.Users.Where(u => u.Email.Equals(usrpaid.Email, StringComparison.CurrentCultureIgnoreCase));
                            if (is_Premium_User_Registered_in_all_user_db.Count() <= 0)
                            {
                                Random          rd             = new Random();
                                int             myReferralCode = rd.Next(10000000);
                                var             userManager    = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(db));
                                var             roleManager    = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(db));
                                PasswordHasher  pdH            = new PasswordHasher();
                                AlphaNumGen     anGen          = new AlphaNumGen();
                                string          password       = anGen.GetPassword();
                                string          username       = string.Concat(usrpaid.First_Name.Substring(0, 1), usrpaid.Last_Name);
                                var             RefUrl         = this.Url.Action("Register", "Account", new { sp = username }, this.Request.Url.Scheme);
                                ApplicationUser rgUser         = new ApplicationUser();
                                rgUser.FirstName               = usrpaid.First_Name;
                                rgUser.LastName                = usrpaid.Last_Name;
                                rgUser.Email                   = usrpaid.Email;
                                rgUser.PhoneNumber             = usrpaid.Phone;
                                rgUser.Address                 = usrpaid.Address;
                                rgUser.City                    = usrpaid.City;
                                rgUser.State                   = usrpaid.State;
                                rgUser.Gender                  = usrpaid.Gender;
                                rgUser.Health_Service_Provider = "No";
                                rgUser.isClientBooster         = false;
                                rgUser.UserType                = "BusinessUser";
                                rgUser.NotifyStatus            = 1;
                                rgUser.Nationality             = usrpaid.Nationality;
                                rgUser.MyRefferalCode          = myReferralCode;
                                rgUser.subscriptionType        = "Health_Insurance";
                                rgUser.UserName                = username;
                                rgUser.Refferal_Url            = RefUrl;
                                rgUser.PasswordHash            = pdH.HashPassword(password);
                                rgUser.SecurityStamp           = Guid.NewGuid().ToString();
                                rgUser.RegDate                 = DateTime.UtcNow;
                                rgUser.EmailConfirmed          = true;
                                db.Users.Add(rgUser);
                                await db.SaveChangesAsync();

                                rgUser = userManager.FindByName(rgUser.UserName);
                                if (rgUser != null)
                                {
                                    var addtorole = userManager.AddToRole(rgUser.Id, "Users");
                                }
                                IHealthUsersMLM iHmlm = new IHealthUsersMLM();
                                iHmlm.UserID           = rgUser.Id;
                                iHmlm.MyRefferalCode   = myReferralCode;
                                iHmlm.MySponsorRefCode = usrpaid.sponsorID.ToString();
                                iHmlm.MyDownlineCount  = 0;
                                db.IHealthUsersMLM.Add(iHmlm);
                                await db.SaveChangesAsync();

                                #region //Confirm payment
                                usrpaid.PaymentStatus    = "Paid";
                                usrpaid.Transaction_date = DateTime.UtcNow;
                                usrpaid.SignedBy         = Session["Name"].ToString();
                                usrpaid.NotifyStatus     = 1;
                                //  usrpaid.INISubcriberExtraDetails.MaxDT2MtTarget = DateTime.UtcNow.AddDays(30);
                                await db.SaveChangesAsync();

                                //check if the new member has a sponsor so that we can give the sponsor bonus
                                if (usrpaid.sponsorID != 0)
                                {
                                    //retrieve the sponsor of this new registrant details from the all users table
                                    var sponsor = db.Users.Single(u => u.MyRefferalCode.ToString() == usrpaid.sponsorID.ToString());
                                    //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);
                                    referral_BonusTb refbonus = new referral_BonusTb();
                                    refbonus.user_ID = sponsor.Id;
                                    // refbonus.Downline_Id = usrpaid.INISubcriberExtraDetails.User.MyRefferalCode;
                                    refbonus.Downline_Name      = usrpaid.First_Name + " " + usrpaid.Last_Name;
                                    refbonus.Bonus_Type         = "Premium Referral Bonus";
                                    refbonus.Subscription_Fee   = usrpaid.Amount;
                                    refbonus.Bonus_created_date = DateTime.UtcNow;
                                    refbonus.Bonus = refbonus.Subscription_Fee * 0.05; // bonus is 5% of the subscription
                                    db.referral_bonus_tb.Add(refbonus);
                                    await db.SaveChangesAsync();

                                    sp_IN_mlm.CurrentBonus = sp_IN_mlm.CurrentBonus + (refbonus.Subscription_Fee * 0.05);
                                    await db.SaveChangesAsync();
                                }
                                string mailbody = "<p>We are glad to let you know that your payment for iHealth premium user package has been acknowledged.</p> "
                                                  + "<p>Kindly note that we will batch and forward your details to the assigned HMO to activate your plan.</p>" +
                                                  "<p>We will notify you via email, once your plan becomes active.</p>"
                                                  + "<p>Kindly, note that a user account has also been created for you on our platform. Below are your login credentials;<br/>"
                                                  + "<b> Username: "******" <br/> Password: "******"</b></p>"
                                                  + "<p>Thank you. <br/><br/>Best Regards, <br/><br/>iHealthGSFM Team.</p>";
                                await em.premiumUserPaymentApprovalMail(usrpaid.Email, usrpaid.Last_Name, "Premium Plan Payment Approval", mailbody);

                                TempData["success"] = "Operations Successfull";

                                #endregion
                            }
                            else
                            {
                                #region //confirm payment

                                usrpaid.PaymentStatus    = "Paid";
                                usrpaid.Transaction_date = DateTime.UtcNow;
                                usrpaid.SignedBy         = Session["Name"].ToString();
                                usrpaid.NotifyStatus     = 1;
                                //  usrpaid.INISubcriberExtraDetails.MaxDT2MtTarget = DateTime.UtcNow.AddDays(30);
                                await db.SaveChangesAsync();

                                //check if the new member has a sponsor so that we can give the sponsor bonus

                                if (usrpaid.sponsorID != 0)
                                {
                                    //retrieve the sponsor of this new registrant details from the all users table
                                    var sponsor = db.Users.Single(u => u.MyRefferalCode.ToString() == usrpaid.sponsorID.ToString());
                                    //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);
                                    referral_BonusTb refbonus = new referral_BonusTb();
                                    refbonus.user_ID = sponsor.Id;
                                    // refbonus.Downline_Id = usrpaid.INISubcriberExtraDetails.User.MyRefferalCode;
                                    refbonus.Downline_Name      = usrpaid.First_Name + " " + usrpaid.Last_Name;
                                    refbonus.Bonus_Type         = "Premium Referral Bonus";
                                    refbonus.Subscription_Fee   = usrpaid.Amount;
                                    refbonus.Bonus_created_date = DateTime.UtcNow;
                                    refbonus.Bonus = refbonus.Subscription_Fee * 0.05; // bonus is 5% of the subscription
                                    db.referral_bonus_tb.Add(refbonus);
                                    await db.SaveChangesAsync();

                                    sp_IN_mlm.CurrentBonus = sp_IN_mlm.CurrentBonus + (refbonus.Subscription_Fee * 0.05);
                                    await db.SaveChangesAsync();
                                }

                                string mailbody = "<p>We are glad to let you know that your payment for iHealth premium user package has been acknowledged.</p> "
                                                  + "<p>Kindly note that we will batch and forward your details to the assigned HMO to activate your plan.</p>" +
                                                  "<p>We will notify you via email, once your plan becomes active.</p>"
                                                  + "<p>Thank you. <br/><br/>Best Regards, <br/><br/>iHealthGSFM Team.</p>";
                                await em.premiumUserPaymentApprovalMail(usrpaid.Email, usrpaid.Last_Name, "Premium Plan Payment Approval", mailbody);

                                TempData["success"] = "Operations Successfull";

                                #endregion
                            }
                        }
                        return(Json(true, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        TempData["error"] = "Oops! No Item is selected from the list. ";
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                }
                else
                {
                    TempData["error"] = "Oops! No Item is selected from the list. ";
                    return(Json(false, JsonRequestBehavior.AllowGet));
                }
                #endregion
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #2
0
        public async Task <JsonResult> MarkAsPaid(IEnumerable <string> markAsPaidbyId)
        {
            if (markAsPaidbyId != null)
            {
                if (markAsPaidbyId.Count() > 0)
                {
                    foreach (var id in markAsPaidbyId)
                    {
                        var usrpaid = db.Users.Single(u => u.Id == id);
                        try
                        {
                            usrpaid.INISubcriberExtraDetails.PaymentStatus    = "Paid";
                            usrpaid.INISubcriberExtraDetails.BEstatus         = "Active";
                            usrpaid.INISubcriberExtraDetails.INI_Status       = "Active";
                            usrpaid.INISubcriberExtraDetails.Amounts          = amount;
                            usrpaid.INISubcriberExtraDetails.paymentGateway   = "Bank";
                            usrpaid.INISubcriberExtraDetails.Transaction_date = DateTime.UtcNow;
                            //  usrpaid.INISubcriberExtraDetails.MaxDT2MtTarget = DateTime.UtcNow.AddDays(30);
                            await db.SaveChangesAsync();

                            //check if the new member has a sponsor so that we can give the sponsor bonus
                            if (!string.IsNullOrEmpty(usrpaid.INISubcriberExtraDetails.My_Sponsor_Referral_Code))
                            {
                                //retrieve the sponsor of this new registrant details from the all users table
                                var sponsor = db.Users.Single(u => u.MyRefferalCode.ToString() == usrpaid.INISubcriberExtraDetails.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);
                                try
                                {
                                    //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 (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();
                                }
                                catch (Exception ex)
                                {
                                    throw ex;
                                }

                                referral_BonusTb refbonus = new referral_BonusTb();
                                refbonus.user_ID            = sponsor.Id;
                                refbonus.Downline_Id        = usrpaid.INISubcriberExtraDetails.User.MyRefferalCode;
                                refbonus.Downline_Name      = usrpaid.INISubcriberExtraDetails.User.FirstName + " " + usrpaid.INISubcriberExtraDetails.User.LastName;
                                refbonus.Bonus_Type         = "Ihealth Networking Referral Bonus";
                                refbonus.Subscription_Fee   = usrpaid.INISubcriberExtraDetails.Amounts;
                                refbonus.Bonus_created_date = DateTime.UtcNow;
                                refbonus.Bonus = refbonus.Subscription_Fee * 0.5; // bonus is 50% of the subscription
                                //check if the sponsor of this new member subscribe for ING promo
                                if (sponsor.INISubcriberExtraDetails.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();
                            }
                            string code = await UserManager.GenerateEmailConfirmationTokenAsync(usrpaid.Id);

                            var callbackUrl = Url.Action("ConfirmEmail", "Account",
                                                         new { userId = usrpaid.Id, code = code }, protocol: Request.Url.Scheme);
                            await UserManager.SendEmailAsync(usrpaid.Id,
                                                             "Confirm your account", em.Notification_Email_Body_Creator(usrpaid.FullName, "<p>Welcome to iHealth Networking Group.</p> "
                                                                                                                        + "<p>This is to notify you that your payment information has been confirm and your subscription activated. <br/>Please, confirm your account by clicking <a href=\""
                                                                                                                        + callbackUrl + "\">here</a> in order to login to your dashboard</p><p>Thanks for registering with us. <br/><br/>Best Regards, <br/><br/>iHealth Nigeria GSFM Team.</p>"));

                            TempData["success"] = "Operations Successfull";
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                    }
                    return(Json(true, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    TempData["error"] = "Oops! No Item is selected from the list. ";
                    return(Json(false, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                TempData["error"] = "Oops! No Item is selected from the list. ";
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
Пример #3
0
        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;
            }
        }