public async Task <ActionResult> AddFbPage(string code)
        {
            string accessToken = string.Empty;

            try
            {
                accessToken = Socioboard.Facebook.Auth.Authentication.GetAccessToken(_appSettings.FacebookClientId, _appSettings.FacebookRedirectUrl, _appSettings.FacebookClientSecretKey, code);
            }
            catch (Exception ex)
            {
                _logger.LogInformation(ex.Message);
                _logger.LogError(ex.StackTrace);
                TempData["Error"] = "Issue with Token";
                return(RedirectToAction("Index", "Home"));
            }
            Domain.Socioboard.Models.User user = HttpContext.Session.GetObjectFromJson <Domain.Socioboard.Models.User>("User");
            string groupId = HttpContext.Session.GetObjectFromJson <string>("selectedGroupId");
            List <KeyValuePair <string, string> > Parameters = new List <KeyValuePair <string, string> >();

            Parameters.Add(new KeyValuePair <string, string>("accesstoken", accessToken));
            Parameters.Add(new KeyValuePair <string, string>("groupId", groupId));
            HttpResponseMessage response = await WebApiReq.PostReq("/api/Facebook/GetFacebookPages", Parameters, "", "", _appSettings.ApiDomain);

            if (response.IsSuccessStatusCode)
            {
                List <Domain.Socioboard.Models.Facebookpage> lstpages = await response.Content.ReadAsAsync <List <Domain.Socioboard.Models.Facebookpage> >();

                if (lstpages.Count > 0)
                {
                    TempData["fbPages"] = Newtonsoft.Json.JsonConvert.SerializeObject(lstpages);
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    TempData["Error"] = "No page linked with this account";
                    return(RedirectToAction("Index", "Home"));
                }
            }
            else
            {
                TempData["Error"] = "Error while hitting api.";
                return(RedirectToAction("Index", "Home"));
            }
        }
        public async Task <ActionResult> ReConnectAcc(string code)
        {
            string accessToken = string.Empty;

            try
            {
                accessToken = Socioboard.Facebook.Auth.Authentication.getAccessToken(_appSettings.FacebookClientId, _appSettings.FacebookRedirectUrl, _appSettings.FacebookClientSecretKey, code);
            }
            catch (Exception ex)
            {
                _logger.LogInformation(ex.Message);
                _logger.LogError(ex.StackTrace);
                TempData["Error"] = "Issue with Token";
                return(RedirectToAction("Index", "Home"));
            }
            Domain.Socioboard.Models.User user = HttpContext.Session.GetObjectFromJson <Domain.Socioboard.Models.User>("User");
            string groupId = HttpContext.Session.GetObjectFromJson <string>("selectedGroupId");

            List <KeyValuePair <string, string> > RecParameters = new List <KeyValuePair <string, string> >();
            string profileId   = HttpContext.Session.GetObjectFromJson <string>("profileId"); //profileId
            string fbreconnect = HttpContext.Session.GetObjectFromJson <string>("fbSocial");  //fbSocial

            RecParameters.Add(new KeyValuePair <string, string>("accessToken", accessToken));
            RecParameters.Add(new KeyValuePair <string, string>("groupId", groupId));
            RecParameters.Add(new KeyValuePair <string, string>("userId", user.Id.ToString()));
            RecParameters.Add(new KeyValuePair <string, string>("reconnect", fbreconnect));
            RecParameters.Add(new KeyValuePair <string, string>("profileId", profileId));



            HttpResponseMessage response = await WebApiReq.PostReq("/api/Facebook/ReconnectFbAccount", RecParameters, "", "", _appSettings.ApiDomain);

            if (response.IsSuccessStatusCode)
            {
                TempData["Success"] = await response.Content.ReadAsStringAsync();

                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                TempData["Error"] = "Error while hitting api.";
                return(RedirectToAction("Index", "Home"));
            }
        }
        public async Task <IActionResult> paymentWithPayUMoney(bool contesnt)
        {
            Domain.Socioboard.Models.User         user       = HttpContext.Session.GetObjectFromJson <Domain.Socioboard.Models.User>("User");
            Domain.Socioboard.Models.Package      _Package   = HttpContext.Session.GetObjectFromJson <Domain.Socioboard.Models.Package>("Package");
            List <KeyValuePair <string, string> > Parameters = new List <KeyValuePair <string, string> >();

            Parameters.Add(new KeyValuePair <string, string>("key", _appSettings.key));
            string amount = (Convert.ToDouble(_Package.amount) * Convert.ToDouble(_appSettings.moneyconvertion)).ToString();
            string txnid  = Generatetxnid();

            Parameters.Add(new KeyValuePair <string, string>("txnid", txnid));
            Parameters.Add(new KeyValuePair <string, string>("amount", amount));
            Parameters.Add(new KeyValuePair <string, string>("productinfo", _Package.packagename));
            Parameters.Add(new KeyValuePair <string, string>("firstname", user.FirstName));
            Parameters.Add(new KeyValuePair <string, string>("email", user.EmailId));
            Parameters.Add(new KeyValuePair <string, string>("phone", user.PhoneNumber));
            Parameters.Add(new KeyValuePair <string, string>("surl", _appSettings.surl));
            Parameters.Add(new KeyValuePair <string, string>("furl", _appSettings.failUrl));
            string hashString = _appSettings.key.ToString() + "|" + txnid + "|" + amount + "|" + _Package.packagename.ToString() + "|" + user.FirstName.ToString() + "|" + user.EmailId.ToString() + "|||||||||||" + _appSettings.salt.ToString();
            string hash       = Generatehash512(hashString);

            Parameters.Add(new KeyValuePair <string, string>("hash", hash));
            Parameters.Add(new KeyValuePair <string, string>("service_provider", "payu_paisa"));
            HttpResponseMessage response = await WebApiReq.PostReq("/_payment", Parameters, "", "", "https://secure.payu.in");

            if (response.IsSuccessStatusCode)
            {
                // string data = await response.Content.ReadAsStringAsync();
                if (contesnt != false)
                {
                    return(Content(response.RequestMessage.RequestUri.OriginalString));
                }
                else
                {
                    //return Redirect(response.RequestMessage.RequestUri.OriginalString);
                    //return Redirect(response.RequestMessage.RequestUri.OriginalString);
                    return(Content(response.RequestMessage.RequestUri.OriginalString));
                }
            }
            else
            {
                return(null);
            }
        }
        public async Task <IActionResult> PluginSignUp()
        {
            string output   = "";
            string name     = Request.Form["name"].ToString();
            string email    = Request.Form["email"].ToString();
            string password = Request.Form["password"].ToString();
            List <KeyValuePair <string, string> > Parameters = new List <KeyValuePair <string, string> >();

            Parameters.Add(new KeyValuePair <string, string>("FirstName", name));
            Parameters.Add(new KeyValuePair <string, string>("EmailId", email));
            Parameters.Add(new KeyValuePair <string, string>("Password", password));
            HttpResponseMessage response = await WebApiReq.PostReq("/api/User/Register", Parameters, "", "", _appSettings.ApiDomain);

            if (response.IsSuccessStatusCode)
            {
                output = await response.Content.ReadAsStringAsync();
            }
            return(Content(output));
        }
Esempio n. 5
0
        public async Task <ActionResult> Pinterest(string code, string state)
        {
            if (state == "None")
            {
                TempData["Error"] = "You did not authorized your account for our app.";
                return(RedirectToAction("Index", "Home"));
            }
            string pinterestSession = HttpContext.Session.GetObjectFromJson <string>("Pinterest");
            string groupId          = HttpContext.Session.GetObjectFromJson <string>("selectedGroupId");

            if (pinterestSession.Equals("Pinterest_Account"))
            {
                HttpContext.Session.SetObjectAsJson("Pinterest", null);
                Domain.Socioboard.Models.User         user       = HttpContext.Session.GetObjectFromJson <Domain.Socioboard.Models.User>("User");
                List <KeyValuePair <string, string> > Parameters = new List <KeyValuePair <string, string> >();
                Parameters.Add(new KeyValuePair <string, string>("code", code));
                Parameters.Add(new KeyValuePair <string, string>("groupId", groupId));
                Parameters.Add(new KeyValuePair <string, string>("userId", user.Id.ToString()));
                HttpResponseMessage response = await WebApiReq.PostReq("/api/Pinterest/AddPinterestAccount", Parameters, "", "", _appSettings.ApiDomain);

                if (response.IsSuccessStatusCode)
                {
                    TempData["Success"] = await response.Content.ReadAsStringAsync();

                    if (TempData["Success"].ToString() == "Something went wrong while fetching accessToken Please try again")
                    {
                        HttpContext.Session.SetObjectAsJson("Pinterest", "Pinterest_Account");
                        string authUrl = Authentication.GetPinterestRedirectLink(_appSettings.PinterestAuthUrl, _appSettings.pinterestConsumerKey, _appSettings.pinterestRedirectionUrl);
                        return(Redirect(authUrl));
                    }
                    else
                    {
                        return(RedirectToAction("Index", "Home"));
                    }
                }
                else
                {
                    TempData["Error"] = "Error while hitting api.";
                    return(RedirectToAction("Index", "Home"));
                }
            }
            return(View());
        }
        public async Task <ActionResult> ForgotPassword(string emailId, string token)
        {
            string res = string.Empty;
            List <KeyValuePair <string, string> > Parameters = new List <KeyValuePair <string, string> >();

            Parameters.Add(new KeyValuePair <string, string>("emailId", emailId));
            Parameters.Add(new KeyValuePair <string, string>("accessToken", token));
            HttpResponseMessage response = await WebApiReq.PostReq("/api/User/validateforgotpwdToken", Parameters, "", "", _appSettings.ApiDomain);

            if (response.IsSuccessStatusCode)
            {
                res = await response.Content.ReadAsStringAsync();

                if (res.Equals("You can change the password"))
                {
                    TempData["res"]     = res;
                    TempData["EmailId"] = emailId;
                    TempData["token"]   = token;
                    return(RedirectToAction("ResetPassword", "Index"));
                }
                else if (res.Equals("Link Expired."))
                {
                    TempData["Error"] = res;
                    return(RedirectToAction("Index", "Index"));
                }
                else if (res.Equals("Wrong Link"))
                {
                    TempData["Wrong Link"] = res;
                    return(RedirectToAction("Index", "Index"));
                }
                else
                {
                    TempData["EmailId does not exist"] = "Email id does not exist";
                    return(RedirectToAction("Index", "Index"));
                }
            }
            else
            {
                TempData["Error"] = "Error while hiting api";
                return(RedirectToAction("Index", "Index"));
            }
        }
Esempio n. 7
0
        public async Task <ActionResult> Edit(ShareathonViewModel shareathon)
        {
            string id = "";

            for (int i = 0; i < shareathon.FacebookPageId.Length; i++)
            {
                string dataid = shareathon.FacebookPageId[i];
                id = dataid + "," + id;
            }
            User objUser = (User)Session["User"];
            List <KeyValuePair <string, string> > Parameters = new List <KeyValuePair <string, string> >();

            Parameters.Add(new KeyValuePair <string, string>("Id", shareathon.Id.ToString()));
            Parameters.Add(new KeyValuePair <string, string>("Facebookaccountid", shareathon.Facebookaccountid.ToString()));
            Parameters.Add(new KeyValuePair <string, string>("Userid", objUser.Id.ToString()));
            Parameters.Add(new KeyValuePair <string, string>("Facebookpageid", id.TrimEnd(',')));
            Parameters.Add(new KeyValuePair <string, string>("Timeintervalminutes", shareathon.Timeintervalminutes.ToString()));
            string accesstoken = string.Empty;
            string UserId      = objUser.Id.ToString();

            if (Session["access_token"] != null)
            {
                accesstoken = Session["access_token"].ToString();
            }

            HttpResponseMessage response = await WebApiReq.PostReq("api/ApiShareathon/EditShareathon", Parameters, "Bearer", accesstoken);

            if (response.IsSuccessStatusCode)
            {
                return(RedirectToAction("Index"));
            }

            Api.FacebookAccount.FacebookAccount ApiobjFacebookAccount = new Api.FacebookAccount.FacebookAccount();
            List <FacebookAccount> facebookaccounts = (List <FacebookAccount>)(new JavaScriptSerializer().Deserialize(ApiobjFacebookAccount.GetAllFacebookAccountsByUserIdAndGroupId(objUser.Id.ToString(), System.Web.HttpContext.Current.Session["group"].ToString()), typeof(List <FacebookAccount>)));
            List <FacebookAccount> facebookpages    = (List <FacebookAccount>)(new JavaScriptSerializer().Deserialize(ApiobjFacebookAccount.GetAllFacebookPageByUserIdAndGroupId(objUser.Id.ToString(), System.Web.HttpContext.Current.Session["group"].ToString()), typeof(List <FacebookAccount>)));

            ViewBag.FbPages    = facebookpages;
            Session["FbPages"] = ViewBag.FbPages;
            ViewBag.FbAccounts = facebookaccounts;
            ViewBag.UserId     = objUser.Id;
            return(View());
        }
        private async Task LogoutSession()
        {
            var session = HttpContext.Session.GetObjectFromJson <Domain.Socioboard.Models.SessionHistory>("revokedata");

            if (session != null)
            {
                var param = new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string>("systemId", session.systemId),
                    new KeyValuePair <string, string>("sessionId", session.id.ToString())
                };

                var response = await WebApiReq.PostReq("/api/User/RevokeSession", param, "", "", _appSettings.ApiDomain);

                if (response.IsSuccessStatusCode)
                {
                    HttpContext.Session.Remove("revokedata");
                }
            }
        }
Esempio n. 9
0
        public async void PaymentNotify(string code)
        {
            string media          = Request.Form["charset"];
            string subscr_date    = Request.Form["subscr_date"];
            string ipn_track_id   = Request.Form["ipn_track_id"];
            string payer_email    = Request.Form["payer_email"];
            string amount         = Request.Form["amount3"];
            string mc_currency    = Request.Form["mc_currency"];
            var    Payername      = Request.Form["first_name"] + " " + Request.Form["last_name"];
            string txn_type       = Request.Form["txn_type"];
            string item_name      = Request.Form["item_name"];
            string subscr_id      = Request.Form["subscr_id"];
            string payment_status = Request.Form["payment_status"];

            if (string.IsNullOrEmpty(payment_status))
            {
                payment_status = "Completed";
            }
            string txn_id = Request.Form["txn_id"];

            if (payment_status == "Completed")
            {
                var Parameters = new List <KeyValuePair <string, string> >();
                Parameters.Add(new KeyValuePair <string, string>("subscr_id", subscr_id));
                Parameters.Add(new KeyValuePair <string, string>("txn_id", txn_id));
                Parameters.Add(new KeyValuePair <string, string>("subscr_date",
                                                                 subscr_date.Replace("PDT", "").Replace("PST", "")));
                Parameters.Add(new KeyValuePair <string, string>("payer_email", payer_email));
                Parameters.Add(new KeyValuePair <string, string>("Payername", Payername));
                Parameters.Add(new KeyValuePair <string, string>("payment_status", payment_status));
                Parameters.Add(new KeyValuePair <string, string>("item_name", item_name));
                Parameters.Add(new KeyValuePair <string, string>("amount", amount));
                Parameters.Add(new KeyValuePair <string, string>("media", media));
                var response = await WebApiReq.PostReq("/api/PaymentTransaction/UpdateRecurringUser", Parameters, "",
                                                       "", _appSettings.ApiDomain);

                if (response.IsSuccessStatusCode)
                {
                }
            }
        }
        public async Task <IActionResult> Twitter(string oauth_token, string oauth_verifier)
        {
            string groupId        = HttpContext.Session.GetObjectFromJson <string>("selectedGroupId");
            string requestSecret  = HttpContext.Session.GetObjectFromJson <string>("requestSecret");
            string twitterSession = HttpContext.Session.GetObjectFromJson <string>("Twitter");

            if (twitterSession.Equals("Twitter_Account") || twitterSession.Equals("Twitter_Account_Follow"))
            {
                Domain.Socioboard.Models.User         user       = HttpContext.Session.GetObjectFromJson <Domain.Socioboard.Models.User>("User");
                List <KeyValuePair <string, string> > Parameters = new List <KeyValuePair <string, string> >();
                Parameters.Add(new KeyValuePair <string, string>("requestToken", oauth_token));
                Parameters.Add(new KeyValuePair <string, string>("requestSecret", requestSecret));
                Parameters.Add(new KeyValuePair <string, string>("requestVerifier", oauth_verifier));
                Parameters.Add(new KeyValuePair <string, string>("groupId", groupId));
                Parameters.Add(new KeyValuePair <string, string>("userId", user.Id.ToString()));
                if (twitterSession.Equals("Twitter_Account_Follow"))
                {
                    Parameters.Add(new KeyValuePair <string, string>("follow", "true"));
                }
                HttpContext.Session.SetObjectAsJson("Twitter", null);


                HttpResponseMessage response = await WebApiReq.PostReq("/api/Twitter/AddTwitterAccount", Parameters, "", "", _appSettings.ApiDomain);

                if (response.IsSuccessStatusCode)
                {
                    TempData["Success"] = await response.Content.ReadAsStringAsync();

                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    TempData["Error"] = await response.Content.ReadAsStringAsync();

                    return(RedirectToAction("Index", "Home"));
                }
            }
            return(View());
        }
Esempio n. 11
0
        public async Task <ActionResult> AddLinAcc(string code)
        {
            Domain.Socioboard.Models.User user = HttpContext.Session.GetObjectFromJson <Domain.Socioboard.Models.User>("User");
            string groupId = HttpContext.Session.GetObjectFromJson <string>("selectedGroupId");
            List <KeyValuePair <string, string> > Parameters = new List <KeyValuePair <string, string> >();

            Parameters.Add(new KeyValuePair <string, string>("Code", code));
            Parameters.Add(new KeyValuePair <string, string>("groupId", groupId));
            Parameters.Add(new KeyValuePair <string, string>("userId", user.Id.ToString()));
            HttpResponseMessage response = await WebApiReq.PostReq("/api/LinkedIn/AddLinkedInAccount", Parameters, "", "", _appSettings.ApiDomain);

            if (response.IsSuccessStatusCode)
            {
                TempData["Success"] = await response.Content.ReadAsStringAsync();

                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                TempData["Error"] = "Error while hitting api.";
                return(RedirectToAction("Index", "Home"));
            }
        }
        public async Task <IActionResult> Twitter(string oauth_token, string oauth_verifier)
        {
            var groupId        = HttpContext.Session.GetObjectFromJson <string>("selectedGroupId");
            var requestSecret  = HttpContext.Session.GetObjectFromJson <string>("requestSecret");
            var twitterSession = HttpContext.Session.GetObjectFromJson <string>("Twitter");

            if (!twitterSession.Equals("Twitter_Account") && !twitterSession.Equals("Twitter_Account_Follow"))
            {
                return(View());
            }

            var user       = HttpContext.Session.GetObjectFromJson <Domain.Socioboard.Models.User>("User");
            var parameters = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("requestToken", oauth_token),
                new KeyValuePair <string, string>("requestSecret", requestSecret),
                new KeyValuePair <string, string>("requestVerifier", oauth_verifier),
                new KeyValuePair <string, string>("groupId", groupId),
                new KeyValuePair <string, string>("userId", user.Id.ToString())
            };

            if (twitterSession.Equals("Twitter_Account_Follow"))
            {
                parameters.Add(new KeyValuePair <string, string>("follow", "true"));
            }

            HttpContext.Session.SetObjectAsJson("Twitter", null);


            var response = await WebApiReq.PostReq("/api/Twitter/AddTwitterAccount", parameters, "", "", _appSettings.ApiDomain);

            var action = response.IsSuccessStatusCode ? "Success" : "Error";

            TempData[action] = await response.Content.ReadAsStringAsync();

            return(RedirectToAction("Index", "Home"));
        }
        public async Task <ActionResult> ReconnectGoogleAnalyticsAcc(string code)
        {
            Domain.Socioboard.Models.User user = HttpContext.Session.GetObjectFromJson <Domain.Socioboard.Models.User>("User");

            var Parameters = new List <KeyValuePair <string, string> >();

            Parameters.Add(new KeyValuePair <string, string>("code", code));

            Parameters.Add(new KeyValuePair <string, string>("userId", user.Id.ToString()));

            var response = await WebApiReq.PostReq("/api/Google/ReconnectGoogleAnalyticsAccount", Parameters, "", "", _appSettings.ApiDomain);

            if (response.IsSuccessStatusCode)
            {
                TempData["Success"] = await response.Content.ReadAsStringAsync();

                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                TempData["Error"] = "Error while hitting api.";
                return(RedirectToAction("Index", "Home"));
            }
        }
Esempio n. 14
0
        public async Task <ActionResult> EditGroup(ShareathonGroupViewModel shareathon)
        {
            string groupId = "";
            string nameId  = "";

            for (int i = 0; i < shareathon.FacebookGroupId.Length; i++)
            {
                string   dataid = shareathon.FacebookGroupId[i];
                string[] grpid  = Regex.Split(dataid, "###");
                groupId = grpid[0] + "," + groupId;
                nameId  = shareathon.FacebookGroupId[i] + "," + nameId;
            }
            User objUser = (User)Session["User"];
            List <KeyValuePair <string, string> > Parameters = new List <KeyValuePair <string, string> >();

            Parameters.Add(new KeyValuePair <string, string>("Facebookaccountid", shareathon.Facebookaccountid.ToString()));
            Parameters.Add(new KeyValuePair <string, string>("Id", shareathon.Id.ToString()));
            Parameters.Add(new KeyValuePair <string, string>("Userid", objUser.Id.ToString()));
            Parameters.Add(new KeyValuePair <string, string>("FacebookPageUrl", shareathon.FacebookPageUrl));
            Parameters.Add(new KeyValuePair <string, string>("FacebookGroupId", groupId));
            Parameters.Add(new KeyValuePair <string, string>("Facebooknameid", nameId));
            Parameters.Add(new KeyValuePair <string, string>("Timeintervalminutes", shareathon.Timeintervalminutes.ToString()));
            string accesstoken = string.Empty;
            string UserId      = objUser.Id.ToString();

            if (Session["access_token"] != null)
            {
                accesstoken = Session["access_token"].ToString();
            }

            HttpResponseMessage response = await WebApiReq.PostReq("api/ApiShareathon/EditShareathonGroup", Parameters, "Bearer", accesstoken);

            if (response.IsSuccessStatusCode)
            {
                return(RedirectToAction("GroupIndex"));
            }
            List <FacebookAccount> lstFacebookAccount = new List <FacebookAccount>();

            Api.FacebookAccount.FacebookAccount ApiobjFacebookAccount = new Api.FacebookAccount.FacebookAccount();
            List <FacebookAccount> facebookaccounts = (List <FacebookAccount>)(new JavaScriptSerializer().Deserialize(ApiobjFacebookAccount.GetAllFacebookAccountsByUserIdAndGroupId(objUser.Id.ToString(), System.Web.HttpContext.Current.Session["group"].ToString()), typeof(List <FacebookAccount>)));
            List <FacebookAccount> facebookpages    = (List <FacebookAccount>)(new JavaScriptSerializer().Deserialize(ApiobjFacebookAccount.GetAllFacebookPageByUserIdAndGroupId(objUser.Id.ToString(), System.Web.HttpContext.Current.Session["group"].ToString()), typeof(List <FacebookAccount>)));

            foreach (FacebookAccount item in facebookpages)
            {
                if (item != null)
                {
                    lstFacebookAccount.Add(item);
                }
            }
            if (lstFacebookAccount.Count > 0)
            {
                ViewBag.FbPages    = lstFacebookAccount;
                Session["FbPages"] = ViewBag.FbPages;
            }
            else
            {
                ViewBag.FbPages = null;
            }
            ViewBag.FbAccounts = facebookaccounts.Where(t => t.FbUserId != "").ToList();
            ViewBag.UserId     = objUser.Id;
            return(View());
        }
        public async Task <IActionResult> UpgradeAccount(string packagename)
        {
            Domain.Socioboard.Models.User user = HttpContext.Session.GetObjectFromJson <Domain.Socioboard.Models.User>("User");
            if (user == null)
            {
                return(RedirectToAction("Index", "Index"));
            }
            if (packagename != "Free")
            {
                List <KeyValuePair <string, string> > Parameters = new List <KeyValuePair <string, string> >();
                Parameters.Add(new KeyValuePair <string, string>("packagename", packagename));
                HttpResponseMessage response = await WebApiReq.PostReq("/api/PaymentTransaction/GetPackage", Parameters, "", "", _appSettings.ApiDomain);

                if (response.IsSuccessStatusCode)
                {
                    try
                    {
                        Domain.Socioboard.Models.Package _Package = await response.Content.ReadAsAsync <Domain.Socioboard.Models.Package>();

                        HttpContext.Session.SetObjectAsJson("Package", _Package);

                        if (user.CreateDate.AddDays(29) <= DateTime.UtcNow)
                        {
                            if (user.PaymentType == Domain.Socioboard.Enum.PaymentType.paypal)
                            {
                                return(Content(Helpers.Payment.RecurringPaymentWithPayPalUpgrade(_Package.amount, _Package.packagename, user.FirstName + " " + user.LastName, user.PhoneNumber, user.EmailId, "USD", _appSettings.paypalemail, _appSettings.callBackUrl, _appSettings.failUrl, _appSettings.callBackUrl, _appSettings.cancelurl, _appSettings.notifyUrl, "", _appSettings.PaypalURL)));
                            }
                            else
                            {
                                return(RedirectToAction("paymentWithPayUMoney", "Index"));
                            }
                        }
                        else
                        {
                            if (user.PaymentType == Domain.Socioboard.Enum.PaymentType.paypal)
                            {
                                return(Content(Helpers.Payment.RecurringPaymentWithPayPalUpgrade(_Package.amount, _Package.packagename, user.FirstName + " " + user.LastName, user.PhoneNumber, user.EmailId, "USD", _appSettings.paypalemail, _appSettings.callBackUrl, _appSettings.failUrl, _appSettings.callBackUrl, _appSettings.cancelurl, _appSettings.notifyUrl, "", _appSettings.PaypalURL)));
                            }
                            else
                            {
                                return(RedirectToAction("paymentWithPayUMoney", "Index"));
                            }
                        }
                    }
                    catch { }
                }
            }
            else
            {
                List <KeyValuePair <string, string> > _Parameters = new List <KeyValuePair <string, string> >();
                _Parameters.Add(new KeyValuePair <string, string>("userId", user.Id.ToString()));
                HttpResponseMessage _response = await WebApiReq.PostReq("/api/User/UpdateFreeUser", _Parameters, "", "", _appSettings.ApiDomain);

                if (_response.IsSuccessStatusCode)
                {
                    try
                    {
                        Domain.Socioboard.Models.User _user = await _response.Content.ReadAsAsync <Domain.Socioboard.Models.User>();

                        HttpContext.Session.SetObjectAsJson("User", _user);
                        return(Content(""));
                    }
                    catch { }
                }
            }
            return(RedirectToAction("Index", "Index"));
        }
        public async Task <IActionResult> Index()
        {
            Domain.Socioboard.Models.User user = HttpContext.Session.GetObjectFromJson <Domain.Socioboard.Models.User>("User");

            if (user == null)
            {
                return(RedirectToAction("Index", "Index"));
            }

            try
            {
                if (user.AccountType == Domain.Socioboard.Enum.SBAccountType.Free)
                {
                    ViewBag.AccountType = "Free";
                }
                else if (user.AccountType == Domain.Socioboard.Enum.SBAccountType.Deluxe)
                {
                    ViewBag.AccountType = "Deluxe";
                }
                else if (user.AccountType == Domain.Socioboard.Enum.SBAccountType.Premium)
                {
                    ViewBag.AccountType = "Premium";
                }
                else if (user.AccountType == Domain.Socioboard.Enum.SBAccountType.Topaz)
                {
                    ViewBag.AccountType = "Topaz";
                }
                else if (user.AccountType == Domain.Socioboard.Enum.SBAccountType.Platinum)
                {
                    ViewBag.AccountType = "Platinum";
                }
                else if (user.AccountType == Domain.Socioboard.Enum.SBAccountType.Gold)
                {
                    ViewBag.AccountType = "Gold";
                }
                else if (user.AccountType == Domain.Socioboard.Enum.SBAccountType.Ruby)
                {
                    ViewBag.AccountType = "Ruby";
                }
                else if (user.AccountType == Domain.Socioboard.Enum.SBAccountType.Standard)
                {
                    ViewBag.AccountType = "Standard";
                }
                if (user.ExpiryDate < DateTime.UtcNow)
                {
                    //return RedirectToAction("UpgradePlans", "Index");
                    if (user.TrailStatus != Domain.Socioboard.Enum.UserTrailStatus.inactive)
                    {
                        List <KeyValuePair <string, string> > Param = new List <KeyValuePair <string, string> >();
                        Param.Add(new KeyValuePair <string, string>("Id", user.Id.ToString()));
                        HttpResponseMessage respon = await WebApiReq.PostReq("/api/User/UpdateTrialStatus", Param, "", "", _appSettings.ApiDomain);

                        if (respon.IsSuccessStatusCode)
                        {
                            Domain.Socioboard.Models.User _user = await respon.Content.ReadAsAsync <Domain.Socioboard.Models.User>();

                            HttpContext.Session.SetObjectAsJson("User", _user);
                            user = _user;
                        }
                    }
                }
                else if ((user.PayPalAccountStatus == Domain.Socioboard.Enum.PayPalAccountStatus.notadded || user.PayPalAccountStatus == Domain.Socioboard.Enum.PayPalAccountStatus.inprogress) && (user.AccountType != Domain.Socioboard.Enum.SBAccountType.Free))
                {
                    HttpContext.Session.SetObjectAsJson("paymentsession", true);
                    return(RedirectToAction("PayPalAccount", "Home", new { emailId = user.EmailId, IsLogin = true }));
                }
            }
            catch (Exception)
            {
                return(RedirectToAction("Index", "Index"));
            }
            HttpResponseMessage response = await WebApiReq.GetReq("/api/Groups/GetUserGroups?userId=" + user.Id, "", "", _appSettings.ApiDomain);

            if (response.IsSuccessStatusCode)
            {
                try
                {
                    List <Domain.Socioboard.Models.Groups> groups = await response.Content.ReadAsAsync <List <Domain.Socioboard.Models.Groups> >();

                    ViewBag.groups = Newtonsoft.Json.JsonConvert.SerializeObject(groups);
                    string sessionSelectedGroupId = HttpContext.Session.GetObjectFromJson <string>("selectedGroupId");
                    if (!string.IsNullOrEmpty(sessionSelectedGroupId))
                    {
                        ViewBag.selectedGroupId = sessionSelectedGroupId;
                        HttpResponseMessage groupProfilesResponse = await WebApiReq.GetReq("/api/GroupProfiles/GetGroupProfiles?groupId=" + sessionSelectedGroupId, "", "", _appSettings.ApiDomain);

                        if (groupProfilesResponse.IsSuccessStatusCode)
                        {
                            List <Domain.Socioboard.Models.Groupprofiles> groupProfiles = await groupProfilesResponse.Content.ReadAsAsync <List <Domain.Socioboard.Models.Groupprofiles> >();

                            ViewBag.groupProfiles = Newtonsoft.Json.JsonConvert.SerializeObject(groupProfiles);
                            // string profileCount = await ProfilesHelper.GetUserProfileCount(user.Id, _appSettings, _logger);
                            // int count = Convert.ToInt32(profileCount);
                            int count    = groupProfiles.Count;
                            int MaxCount = Domain.Socioboard.Helpers.SBHelper.GetMaxProfileCount(user.AccountType);
                            ViewBag.profileCount = count;
                            ViewBag.MaxCount     = MaxCount;
                            ViewBag.AccountType  = user.AccountType;
                            if (count > MaxCount)
                            {
                                ViewBag.downgrade = "true";
                            }
                            else
                            {
                                ViewBag.downgrade = "false";
                            }
                        }
                    }
                    else
                    {
                        long selectedGroupId = groups.FirstOrDefault(t => t.groupName == Domain.Socioboard.Consatants.SocioboardConsts.DefaultGroupName).id;
                        HttpContext.Session.SetObjectAsJson("selectedGroupId", selectedGroupId);
                        ViewBag.selectedGroupId = selectedGroupId;
                        HttpResponseMessage groupProfilesResponse = await WebApiReq.GetReq("/api/GroupProfiles/GetGroupProfiles?groupId=" + selectedGroupId, "", "", _appSettings.ApiDomain);

                        if (groupProfilesResponse.IsSuccessStatusCode)
                        {
                            List <Domain.Socioboard.Models.Groupprofiles> groupProfiles = await groupProfilesResponse.Content.ReadAsAsync <List <Domain.Socioboard.Models.Groupprofiles> >();

                            ViewBag.groupProfiles = Newtonsoft.Json.JsonConvert.SerializeObject(groupProfiles);
                            //string profileCount = await ProfilesHelper.GetUserProfileCount(user.Id, _appSettings, _logger);
                            // int count = Convert.ToInt32(profileCount);
                            int count    = groupProfiles.Count;
                            int MaxCount = Domain.Socioboard.Helpers.SBHelper.GetMaxProfileCount(user.AccountType);
                            ViewBag.profileCount = count;
                            ViewBag.MaxCount     = MaxCount;
                            if (count > MaxCount)
                            {
                                ViewBag.downgrade = "true";
                            }
                            else
                            {
                                ViewBag.downgrade = "false";
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    HttpContext.Session.Remove("User");
                    HttpContext.Session.Remove("selectedGroupId");
                    HttpContext.Session.Clear();
                    ViewBag.user            = null;
                    ViewBag.selectedGroupId = null;
                    ViewBag.groupProfiles   = null;
                    TempData["Error"]       = "Some thing went wrong.";
                    return(RedirectToAction("Index", "Index"));
                }
            }
            else
            {
                return(RedirectToAction("Index", "Index"));
            }
            ViewBag.user = Newtonsoft.Json.JsonConvert.SerializeObject(user);
            return(View());
        }
        public async Task <IActionResult> PaymentSuccessful()
        {
            string output = "false";
            string plan   = "";

            Domain.Socioboard.Models.User    user     = HttpContext.Session.GetObjectFromJson <Domain.Socioboard.Models.User>("User");
            Domain.Socioboard.Models.Package _Package = HttpContext.Session.GetObjectFromJson <Domain.Socioboard.Models.Package>("Package");
            string trasactionId = Generatetxnid();
            string paymentId    = Request.Form["subscr_id"];

            if (_Package.packagename == "Free")
            {
                plan = "Free";
            }
            else if (_Package.packagename == "Deluxe")
            {
                plan = "Deluxe";
            }
            else if (_Package.packagename == "Premium")
            {
                plan = "Premium";
            }
            else if (_Package.packagename == "Topaz")
            {
                plan = "Topaz";
            }
            else if (_Package.packagename == "Platinum")
            {
                plan = "Platinum";
            }
            else if (_Package.packagename == "Gold")
            {
                plan = "Gold";
            }
            else if (_Package.packagename == "Ruby")
            {
                plan = "Ruby";
            }
            else if (_Package.packagename == "Standard")
            {
                plan = "Standard";
            }
            List <KeyValuePair <string, string> > Parameters = new List <KeyValuePair <string, string> >();

            Parameters.Add(new KeyValuePair <string, string>("userId", user.Id.ToString()));
            Parameters.Add(new KeyValuePair <string, string>("UserName", user.FirstName + " " + user.LastName));
            Parameters.Add(new KeyValuePair <string, string>("email", user.EmailId));
            Parameters.Add(new KeyValuePair <string, string>("amount", _Package.amount));
            Parameters.Add(new KeyValuePair <string, string>("PaymentType", user.PaymentType.ToString()));
            Parameters.Add(new KeyValuePair <string, string>("trasactionId", trasactionId));
            Parameters.Add(new KeyValuePair <string, string>("paymentId", paymentId));
            Parameters.Add(new KeyValuePair <string, string>("accType", plan));
            HttpResponseMessage response = await WebApiReq.PostReq("/api/PaymentTransaction/UpgradeAccount", Parameters, "", "", _appSettings.ApiDomain);

            if (response.IsSuccessStatusCode)
            {
                try
                {
                    string data = await response.Content.ReadAsStringAsync();

                    if (data == "payment done")
                    {
                        List <KeyValuePair <string, string> > _Parameters = new List <KeyValuePair <string, string> >();
                        //_Parameters.Add(new KeyValuePair<string, string>("Id", user.Id.ToString()));
                        HttpResponseMessage _response = await WebApiReq.GetReq("/api/User/GetUser?Id=" + user.Id.ToString(), "", "", _appSettings.ApiDomain);

                        if (response.IsSuccessStatusCode)
                        {
                            try
                            {
                                Domain.Socioboard.Models.User _user = await _response.Content.ReadAsAsync <Domain.Socioboard.Models.User>();

                                HttpContext.Session.SetObjectAsJson("User", _user);
                                return(RedirectToAction("Index", "Index"));
                            }
                            catch { }
                        }
                    }
                }
                catch (Exception e)
                {
                    return(RedirectToAction("Index", "Index"));
                }
            }
            return(Content(output));
        }
        public async Task <IActionResult> SBApp(string profileType, string url, string content, string imageUrl, string name, string userImage, string screenName, string tweet, string tweetId, string type, string EmailId)
        {
            var password = "";

            var pluginData = new Domain.Socioboard.Helpers.PluginData
            {
                profileType = profileType,
                content     = content,
                imageUrl    = imageUrl,
                name        = name,
                screenName  = screenName,
                tweet       = tweet,
                tweetId     = tweetId,
                url         = url,
                userImage   = userImage,
                type        = type
            };

            if (!string.IsNullOrEmpty(imageUrl))
            {
                if (imageUrl.Equals(url))
                {
                    if (type == "timeline-image")
                    {
                        pluginData.url = string.Empty;
                    }

                    if (profileType == "image")
                    {
                        pluginData.url = string.Empty;
                    }
                }
            }

            if (profileType == "website")
            {
                if (url.Contains(".jpg") || url.Contains(".png"))
                {
                    pluginData.imageUrl = url;
                    pluginData.url      = string.Empty;
                }
            }

            var user = HttpContext.Session.GetObjectFromJson <Domain.Socioboard.Models.User>("User");

            if (user == null)
            {
                if (Request.Cookies["socioboardpluginemailId"] != null)
                {
                    EmailId = Request.Cookies["socioboardpluginemailId"];
                    EmailId = PluginHelper.Base64Decode(EmailId);
                }

                if (Request.Cookies["socioboardpluginToken"] != null)
                {
                    password = Request.Cookies["socioboardpluginToken"];
                    password = PluginHelper.Base64Decode(password);
                }

                if (!string.IsNullOrEmpty(EmailId) && !string.IsNullOrEmpty(password))
                {
                    var parameters = new List <KeyValuePair <string, string> >
                    {
                        new KeyValuePair <string, string>("UserName", EmailId),
                        new KeyValuePair <string, string>("Password", password)
                    };

                    var loginResponse = await WebApiReq.PostReq("/api/User/CheckUserLogin", parameters, "", "", _appSettings.ApiDomain);

                    if (loginResponse.IsSuccessStatusCode)
                    {
                        try
                        {
                            user = await loginResponse.Content.ReadAsAsync <Domain.Socioboard.Models.User>();

                            HttpContext.Session.SetObjectAsJson("User", user);
                        }
                        catch (Exception e) { _logger.LogError(e.Message); }
                    }
                    else
                    {
                        ViewBag.User = "******";
                        return(View("Rlogin"));
                    }
                }
            }

            if (user == null)
            {
                return(View("Rlogin"));
            }

            if (!string.IsNullOrEmpty(url) && profileType != "pinterest")
            {
                var plugindata = PluginHelper.CreateThumbnail(url);
                pluginData._ThumbnailDetails = plugindata;
            }

            ViewBag.plugin   = pluginData;
            ViewBag.emailId  = user.EmailId;
            ViewBag.password = user.Password;
            ViewBag.userId   = user.Id.ToString();

            var response = await WebApiReq.GetReq("/api/Groups/GetUserGroups?userId=" + user.Id, "", "", _appSettings.ApiDomain);

            if (!response.IsSuccessStatusCode)
            {
                return(View("Rlogin"));
            }

            try
            {
                var groups = await response.Content.ReadAsAsync <List <Domain.Socioboard.Models.Groups> >();

                var selectedGroupId = groups.FirstOrDefault(t => t.groupName == Domain.Socioboard.Consatants.SocioboardConsts.DefaultGroupName)?.id;

                if (selectedGroupId != null)
                {
                    var pluginProfileResponse = await WebApiReq.GetReq("/api/GroupProfiles/GetPluginProfile?groupId=" + selectedGroupId, "", "", _appSettings.ApiDomain);

                    if (pluginProfileResponse.IsSuccessStatusCode)
                    {
                        try
                        {
                            var pluginProfiles = await pluginProfileResponse.Content.ReadAsAsync <List <Domain.Socioboard.Helpers.PluginProfile> >();

                            return(View("RMain", pluginProfiles));
                        }
                        catch (Exception e) { _logger.LogError(e.Message); }
                    }
                }
            }
            catch (Exception e) { _logger.LogError(e.Message); }

            return(View("Rlogin"));
        }
        public async Task <IActionResult> AjaxPluginLogin()
        {
            string output = string.Empty;
            string uname  = Request.Form["email"].ToString();
            string pass   = Request.Form["password"].ToString();
            List <KeyValuePair <string, string> > Parameters = new List <KeyValuePair <string, string> >();

            Parameters.Add(new KeyValuePair <string, string>("UserName", uname));
            Parameters.Add(new KeyValuePair <string, string>("Password", pass));
            HttpResponseMessage response = await WebApiReq.PostReq("/api/User/Login", Parameters, "", "", _appSettings.ApiDomain);

            if (response.IsSuccessStatusCode)
            {
                try
                {
                    var user = await response.Content.ReadAsAsync <Domain.Socioboard.Models.User>();

                    HttpContext.Session.SetObjectAsJson("User", user);


                    if (user.UserType == "SuperAdmin")
                    {
                        return(Content("SuperAdmin"));
                    }

                    if (user.ExpiryDate >= DateTime.UtcNow)
                    {
                        return(Content(user.TwostepEnable ? "TwoStepLogin" : "Success"));
                    }

                    var param = new List <KeyValuePair <string, string> >
                    {
                        new KeyValuePair <string, string>("Id", user.Id.ToString())
                    };

                    HttpContext.Session.Remove("User");

                    var trialStatus = await WebApiReq.PostReq("/api/User/UpdateTrialStatus", param, "", "", _appSettings.ApiDomain);

                    if (!trialStatus.IsSuccessStatusCode)
                    {
                        return(Content("Payment not Confirmed"));
                    }

                    var userDetails = await trialStatus.Content.ReadAsAsync <Domain.Socioboard.Models.User>();

                    HttpContext.Session.SetObjectAsJson("User", userDetails);
                    return(Content("Trail Expire"));
                }
                catch (Exception e)
                {
                    try
                    {
                        output = await response.Content.ReadAsStringAsync();
                    }
                    catch (Exception ex)
                    {
                        _logger.LogError(ex.StackTrace);
                    }
                    return(Content(output));
                }
            }
            return(Content(output));
        }
        public async Task <ActionResult> Facebook(string code)
        {
            var fbLogin  = HttpContext.Session.GetObjectFromJson <string>("fblogin");
            var fbSocial = HttpContext.Session.GetObjectFromJson <string>("fbSocial");
            var plan     = HttpContext.Session.GetObjectFromJson <string>("RegisterPlan");


            if (!string.IsNullOrEmpty(fbLogin) && fbLogin.Equals("Fb_Login"))
            {
                HttpContext.Session.SetObjectAsJson("fblogin", null);

                var accessToken = string.Empty;
                try
                {
                    accessToken = Socioboard.Facebook.Auth.Authentication.GetAccessToken(_appSettings.FacebookClientId, _appSettings.FacebookRedirectUrl, _appSettings.FacebookClientSecretKey, code);
                }
                catch (Exception ex)
                {
                    _logger.LogInformation(ex.Message);
                    _logger.LogError(ex.StackTrace);
                    return(Content(ex.Message));
                }

                var parameters = new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string>("accessToken", accessToken),
                    new KeyValuePair <string, string>("accType", plan)
                };

                var response = await WebApiReq.PostReq("/api/User/FacebookLogin", parameters, "", "", _appSettings.ApiDomain);

                if (!response.IsSuccessStatusCode)
                {
                    return(RedirectToAction("Index", "Index"));
                }

                try
                {
                    var user = await response.Content.ReadAsAsync <Domain.Socioboard.Models.User>();

                    // If expired, make user to use free plan
                    if (user.ExpiryDate < DateTime.UtcNow)
                    {
                        HttpContext.Session.Remove("User");

                        var param = new List <KeyValuePair <string, string> >
                        {
                            new KeyValuePair <string, string>("Id", user.Id.ToString())
                        };

                        var trialStatus = await WebApiReq.PostReq("/api/User/UpdateTrialStatus", param, "", "", _appSettings.ApiDomain);

                        if (!trialStatus.IsSuccessStatusCode)
                        {
                            return(RedirectToAction("Index", "Payment"));
                        }

                        var userDetails = await trialStatus.Content.ReadAsAsync <Domain.Socioboard.Models.User>();

                        HttpContext.Session.SetObjectAsJson("User", userDetails);
                        return(RedirectToAction("Index", "Home"));
                    }

                    HttpContext.Session.SetObjectAsJson("User", user);
                }
                catch (Exception)
                {
                    try
                    {
                        HttpContext.Session.Remove("User");
                        TempData["Error"] = await response.Content.ReadAsStringAsync();

                        return(RedirectToAction("Index", "Index"));
                    }
                    catch (Exception ex)
                    {
                        HttpContext.Session.Remove("User");
                        _logger.LogError(ex.StackTrace);
                        return(RedirectToAction("Index", "Index"));
                    }
                }
                return(RedirectToAction("Index", "Home"));
            }

            if (fbSocial.Equals("Fb_Account"))
            {
                HttpContext.Session.SetObjectAsJson("fbSocial", null);
                return(RedirectToAction("AddFbAcc", "FacebookManager", new { code = code }));
            }

            if (fbSocial.Equals("Fb_Page"))
            {
                HttpContext.Session.SetObjectAsJson("fbSocial", null);
                return(RedirectToAction("AddFbPage", "FacebookManager", new { code = code }));
            }

            if (fbSocial.Equals("0"))
            {
                HttpContext.Session.SetObjectAsJson("fbSocial", fbSocial);
                return(RedirectToAction("ReConnectAcc", "FacebookManager", new { code = code }));
            }

            if (fbSocial.Equals("null"))
            {
                HttpContext.Session.SetObjectAsJson("fbSocial", fbSocial);
                return(RedirectToAction("ReConnectfbpage", "FacebookManager", new { code = code }));
            }

            return(RedirectToAction("Index", "Index"));
        }
        public async Task <IActionResult> UpgradeAccount(string packagename)
        {
            var user = HttpContext.Session.GetObjectFromJson <Domain.Socioboard.Models.User>("User");

            if (user == null)
            {
                return(RedirectToAction("Index", "Index"));
            }

            if (packagename != "Free")
            {
                var parameters = new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string>("packagename", packagename)
                };

                var response = await WebApiReq.PostReq("/api/PaymentTransaction/GetPackage", parameters, "", "", _appSettings.ApiDomain);

                if (!response.IsSuccessStatusCode)
                {
                    return(RedirectToAction("Index", "Index"));
                }

                try
                {
                    var package = await response.Content.ReadAsAsync <Domain.Socioboard.Models.Package>();

                    HttpContext.Session.SetObjectAsJson("Package", package);

                    if (user.CreateDate.AddDays(29) > DateTime.UtcNow)
                    {
                        return(user.PaymentType == Domain.Socioboard.Enum.PaymentType.paypal
                            ? (IActionResult)Content(Payment.PaypalRecurringPayment(package.amount,
                                                                                    package.packagename,
                                                                                    user.FirstName + " " + user.LastName, user.PhoneNumber, user.EmailId, "USD",
                                                                                    _appSettings.paypalemail, _appSettings.callBackUrl, _appSettings.failUrl,
                                                                                    _appSettings.callBackUrl, _appSettings.cancelurl, _appSettings.notifyUrl, "",
                                                                                    _appSettings.PaypalURL, user.Id))
                            : RedirectToAction("paymentWithPayUMoney", "Index"));
                    }


                    if (user.PaymentType == Domain.Socioboard.Enum.PaymentType.paypal)
                    {
                        return(Content(Payment.PaypalRecurringPayment(package.amount, package.packagename, user.FirstName + " " + user.LastName, user.PhoneNumber, user.EmailId, "USD", _appSettings.paypalemail, _appSettings.callBackUrl, _appSettings.failUrl, _appSettings.callBackUrl, _appSettings.cancelurl, _appSettings.notifyUrl, "", _appSettings.PaypalURL, user.Id)));
                    }

                    return(RedirectToAction("paymentWithPayUMoney", "Index"));
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
            }
            else
            {
                try
                {
                    var parameters = new List <KeyValuePair <string, string> >
                    {
                        new KeyValuePair <string, string>("userId", user.Id.ToString())
                    };

                    var response = await WebApiReq.PostReq("/api/User/UpdateFreeUser", parameters, "", "", _appSettings.ApiDomain);

                    if (!response.IsSuccessStatusCode)
                    {
                        return(RedirectToAction("Index", "Index"));
                    }

                    var userCurrentDetails = await response.Content.ReadAsAsync <Domain.Socioboard.Models.User>();

                    HttpContext.Session.SetObjectAsJson("User", userCurrentDetails);

                    return(Content(""));
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
            }
            return(RedirectToAction("Index", "Index"));
        }
        public async Task <IActionResult> PaymentSuccessful()
        {
            var authToken = _appSettings.PaypalPdtToken;
            var txToken   = Utils.GetBetween(Request.QueryString + "<:>$", "&tx=", "<:>$");

            //Post back to either sandbox or live
            var paypalUrl = $"{_appSettings.PaypalURL}/cgi-bin/webscr";

            var successResult = VerifyPdt(authToken, "99X63908G1498834B", paypalUrl);

            // var successResult = VerifyPdt(authToken, txToken, paypalUrl);

            if (successResult.Count > 0)
            {
                var user    = HttpContext.Session.GetObjectFromJson <Domain.Socioboard.Models.User>("User");
                var package = HttpContext.Session.GetObjectFromJson <Domain.Socioboard.Models.Package>("Package");

                #region Fetching the details from Paypal

                #endregion

                var plan = package.packagename;

                var paidAmount = successResult["payment_gross"];

                var paidDate      = successResult["payment_date"];
                var paymentDate   = DateTime.Parse(paidDate.Replace(" PDT", "").Replace(" PST", ""));
                var payerEmail    = successResult["payer_email"];
                var payerName     = $"{successResult["first_name"]} {successResult["last_name"]}";
                var paymentStatus = successResult["payment_status"];
                var itemName      = successResult["item_name"];
                var charset       = successResult["charset"];

                var subscriptionId = string.Empty;

                if (successResult.ContainsKey("subscr_id"))
                {
                    subscriptionId = successResult["subscr_id"];
                }


                var parameters = new List <KeyValuePair <string, string> > {
                    new KeyValuePair <string, string>("userId", user.Id.ToString()),
                    new KeyValuePair <string, string>("UserName", user.FirstName + " " + user.LastName),
                    new KeyValuePair <string, string>("email", user.EmailId),
                    new KeyValuePair <string, string>("amount", paidAmount),
                    new KeyValuePair <string, string>("PaymentType", user.PaymentType.ToString()),
                    new KeyValuePair <string, string>("trasactionId", txToken),
                    new KeyValuePair <string, string>("paymentId", subscriptionId),
                    new KeyValuePair <string, string>("accType", plan),
                    new KeyValuePair <string, string>("subscr_date", paymentDate.ToString(CultureInfo.InvariantCulture)),
                    new KeyValuePair <string, string>("payer_email", payerEmail),
                    new KeyValuePair <string, string>("Payername", payerName),
                    new KeyValuePair <string, string>("payment_status", paymentStatus),
                    new KeyValuePair <string, string>("item_name", itemName),
                    new KeyValuePair <string, string>("media", charset)
                };

                var response = await WebApiReq.PostReq("/api/PaymentTransaction/UpgradeAccount", parameters, "", "", _appSettings.ApiDomain);

                if (response.IsSuccessStatusCode)
                {
                    try
                    {
                        var data = await response.Content.ReadAsStringAsync();

                        if (data == "payment done")
                        {
                            var responseMessage = await WebApiReq.GetReq("/api/User/GetUser?Id=" + user.Id, "", "", _appSettings.ApiDomain);

                            if (response.IsSuccessStatusCode)
                            {
                                try
                                {
                                    var userCurrentDetails = await responseMessage.Content.ReadAsAsync <Domain.Socioboard.Models.User>();

                                    if (user.ReferralStatus == "InActive" && user.ReferdBy != null)
                                    {
                                        await WebApiReq.PostReq("/api/User/UpdateRefrralStatus", parameters, "", "", _appSettings.ApiDomain);
                                    }

                                    HttpContext.Session.SetObjectAsJson("User", userCurrentDetails);

                                    return(RedirectToAction("Index", "Index"));
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.StackTrace);
                                }
                            }
                        }
                    }
                    catch (Exception)
                    {
                        return(RedirectToAction("Index", "Index"));
                    }
                }
            }

            var output = "false";

            return(Content(output));
        }
Esempio n. 23
0
        public async Task <ActionResult> Facebook(string code)
        {
            string fbLogin  = HttpContext.Session.GetObjectFromJson <string>("fblogin");
            string fbSocial = HttpContext.Session.GetObjectFromJson <string>("fbSocial");
            string plan     = HttpContext.Session.GetObjectFromJson <string>("RegisterPlan");

            if (!string.IsNullOrEmpty(fbLogin) && fbLogin.Equals("Fb_Login"))
            {
                HttpContext.Session.SetObjectAsJson("fblogin", null);
                string accessToken = string.Empty;
                try
                {
                    accessToken = Socioboard.Facebook.Auth.Authentication.getAccessToken(_appSettings.FacebookClientId, _appSettings.FacebookRedirectUrl, _appSettings.FacebookClientSecretKey, code);
                }
                catch (Exception ex)
                {
                    _logger.LogInformation(ex.Message);
                    _logger.LogError(ex.StackTrace);
                    return(Content(ex.Message));
                }

                Domain.Socioboard.Models.User         user       = null;
                List <KeyValuePair <string, string> > Parameters = new List <KeyValuePair <string, string> >();
                Parameters.Add(new KeyValuePair <string, string>("AccessToken", accessToken));
                Parameters.Add(new KeyValuePair <string, string>("accType", plan));
                HttpResponseMessage response = await WebApiReq.PostReq("/api/User/FacebookLogin", Parameters, "", "", _appSettings.ApiDomain);

                if (response.IsSuccessStatusCode)
                {
                    try
                    {
                        user = await response.Content.ReadAsAsync <Domain.Socioboard.Models.User>();

                        HttpContext.Session.SetObjectAsJson("User", user);
                        if (user.ExpiryDate < DateTime.UtcNow && user.AccountType == Domain.Socioboard.Enum.SBAccountType.Free)
                        {
                            return(RedirectToAction("Index", "Home"));
                        }
                        else if ((user.PayPalAccountStatus == Domain.Socioboard.Enum.PayPalAccountStatus.notadded || user.PayPalAccountStatus == Domain.Socioboard.Enum.PayPalAccountStatus.inprogress) && (user.AccountType != Domain.Socioboard.Enum.SBAccountType.Free))
                        {
                            if (user.PaymentType == Domain.Socioboard.Enum.PaymentType.paypal)
                            {
                                return(RedirectToAction("PayPalAccount", "Home", new { emailId = user.EmailId, IsLogin = true }));
                            }
                            else
                            {
                                return(RedirectToAction("paymentWithPayUMoney", "Index"));
                            }
                            //return RedirectToAction("PayPalAccount", "Home", new { emailId = user.EmailId, IsLogin = true });
                        }
                    }
                    catch (Exception ex)
                    {
                        try
                        {
                            TempData["Error"] = await response.Content.ReadAsStringAsync();

                            return(RedirectToAction("Index", "Index"));
                        }
                        catch (Exception exe) { }
                    }
                }
                return(RedirectToAction("Index", "Home"));
            }
            else if (fbSocial.Equals("Fb_Account"))
            {
                HttpContext.Session.SetObjectAsJson("fbSocial", null);
                return(RedirectToAction("AddFbAcc", "FacebookManager", new { code = code }));
            }
            else if (fbSocial.Equals("Fb_Page"))
            {
                HttpContext.Session.SetObjectAsJson("fbSocial", null);
                return(RedirectToAction("AddFbPage", "FacebookManager", new { code = code }));
            }
            return(RedirectToAction("Index", "Index"));
        }
        public async Task <ActionResult> Active(string id, string Token)
        {
            string res = string.Empty;
            List <KeyValuePair <string, string> > Parameters = new List <KeyValuePair <string, string> >();

            Parameters.Add(new KeyValuePair <string, string>("Id", id));
            Parameters.Add(new KeyValuePair <string, string>("Token", Token));
            HttpResponseMessage response = await WebApiReq.PostReq("/api/User/VerifyEmail", Parameters, "", "", _appSettings.ApiDomain);

            HttpResponseMessage userresponse = await WebApiReq.GetReq("/api/User/GetUser?Id=" + id, "", "", _appSettings.ApiDomain);

            try
            {
                if (response.IsSuccessStatusCode)
                {
                    //res = await response.Content.ReadAsStringAsync();
                    //TempData["Error"] = res;
                    //return RedirectToAction("index", "index");
                    if (userresponse.IsSuccessStatusCode)
                    {
                        string package = string.Empty;
                        User   user    = await userresponse.Content.ReadAsAsync <User>();

                        if (user != null)
                        {
                            HttpContext.Session.SetObjectAsJson("User", user);
                        }
                        else
                        {
                            return(RedirectToAction("index", "index"));
                        }


                        List <KeyValuePair <string, string> > Parameter = new List <KeyValuePair <string, string> >();
                        if (user.AccountType == Domain.Socioboard.Enum.SBAccountType.Free)
                        {
                            package = "Free";
                        }
                        else if (user.AccountType == Domain.Socioboard.Enum.SBAccountType.Deluxe)
                        {
                            package = "Deluxe";
                        }
                        else if (user.AccountType == Domain.Socioboard.Enum.SBAccountType.Premium)
                        {
                            package = "Premium";
                        }
                        else if (user.AccountType == Domain.Socioboard.Enum.SBAccountType.Topaz)
                        {
                            package = "Topaz";
                        }
                        else if (user.AccountType == Domain.Socioboard.Enum.SBAccountType.Platinum)
                        {
                            package = "Platinum";
                        }
                        else if (user.AccountType == Domain.Socioboard.Enum.SBAccountType.Gold)
                        {
                            package = "Gold";
                        }
                        else if (user.AccountType == Domain.Socioboard.Enum.SBAccountType.Ruby)
                        {
                            package = "Ruby";
                        }
                        else if (user.AccountType == Domain.Socioboard.Enum.SBAccountType.Standard)
                        {
                            package = "Standard";
                        }

                        if (package != "Free")
                        {
                            Parameter.Add(new KeyValuePair <string, string>("packagename", package));
                            HttpResponseMessage respons = await WebApiReq.PostReq("/api/PaymentTransaction/GetPackage", Parameter, "", "", _appSettings.ApiDomain);

                            if (respons.IsSuccessStatusCode)
                            {
                                try
                                {
                                    if ((user.PayPalAccountStatus == Domain.Socioboard.Enum.PayPalAccountStatus.notadded || user.PayPalAccountStatus == Domain.Socioboard.Enum.PayPalAccountStatus.inprogress) && (user.AccountType != Domain.Socioboard.Enum.SBAccountType.Free))
                                    {
                                        Domain.Socioboard.Models.Package _Package = await respons.Content.ReadAsAsync <Domain.Socioboard.Models.Package>();

                                        HttpContext.Session.SetObjectAsJson("Package", _Package);
                                        if (user.PaymentType == Domain.Socioboard.Enum.PaymentType.paypal)
                                        {
                                            HttpContext.Session.SetObjectAsJson("paymentsession", true);
                                            return(Redirect(Helpers.Payment.RecurringPaymentWithPayPal(_Package.amount, _Package.packagename, user.FirstName + " " + user.LastName, user.PhoneNumber, user.EmailId, "USD", _appSettings.paypalemail, _appSettings.callBackUrl, _appSettings.failUrl, _appSettings.callBackUrl, _appSettings.cancelurl, _appSettings.notifyUrl, "", _appSettings.PaypalURL)));
                                        }
                                        else
                                        {
                                            HttpContext.Session.SetObjectAsJson("paymentsession", true);
                                            return(RedirectToAction("paymentWithPayUMoney", "Index", new { contesnt = false }));
                                        }
                                    }
                                    else
                                    {
                                        return(RedirectToAction("Index", "Home"));
                                    }
                                }
                                catch (Exception ex) { }
                            }
                        }
                        else
                        {
                            List <KeyValuePair <string, string> > _Parameters = new List <KeyValuePair <string, string> >();
                            _Parameters.Add(new KeyValuePair <string, string>("userId", user.Id.ToString()));
                            HttpResponseMessage _response = await WebApiReq.PostReq("/api/User/UpdateFreeUser", _Parameters, "", "", _appSettings.ApiDomain);

                            if (response.IsSuccessStatusCode)
                            {
                                try
                                {
                                    Domain.Socioboard.Models.User _user = await _response.Content.ReadAsAsync <Domain.Socioboard.Models.User>();

                                    HttpContext.Session.SetObjectAsJson("User", _user);
                                    return(RedirectToAction("Index", "Home"));
                                }
                                catch { }
                            }
                        }
                        return(RedirectToAction("index", "index"));
                    }
                }
                else
                {
                    TempData["Error"] = "Error while hiting api";
                    return(RedirectToAction("index", "index"));
                }
                return(RedirectToAction("index", "index"));
            }
            catch (Exception ex)
            {
                return(RedirectToAction("index", "index"));
            }
        }
Esempio n. 25
0
        private async void ProcessVerificationResponseTest(string ipnContext)
        {
            #region Sample Response

            //mc_gross=19.99&
            //protection_eligibility=Eligible
            //&address_status=confirmed
            //&payer_id=J9VSKE27GQU6S
            //&address_street=1+Main+St
            //&payment_date=22%3A40%3A17+Dec+06%2C+2018+PST
            //&payment_status=Completed
            //&charset=windows-1252
            //&address_zip=95131
            //&first_name=Raushan
            //&mc_fee=0.88
            //&address_country_code=US
            //&address_name=Raushan+Kumar
            //&notify_version=3.9
            //&subscr_id=I-KU5HKAR9DHJ9
            //&custom=satishkumar%40globussoft.in_Socioboard
            //&payer_status=verified
            //&business=dina%40merchent.com
            //&address_country=United+States
            //&address_city=San+Jose
            //&verify_sign=AEG1gtsEQXalp1rIUipNGZfVSdbnApglfmb4V-KKjhy0JdI7U4uSbQYh
            //&payer_email=satishbuyer%40globussoft.in
            //&txn_id=31P59983HU0109310
            //&payment_type=instant
            //&last_name=Kumar
            //&address_state=CA
            //&receiver_email=dina%40merchent.com
            //&payment_fee=0.88
            //&receiver_id=WEZW9GMYEZM3L
            //&txn_type=subscr_payment
            //&item_name=Socioboard_Deluxe
            //&mc_currency=USD
            //&residence_country=US
            //&test_ipn=1
            //&transaction_subject=Socioboard_Deluxe
            //&payment_gross=19.99
            //&ipn_track_id=9d8b4603f06e2

            #endregion


            var transactionType = Utils.GetBetween(ipnContext, "txn_type=", "&");

            if (!transactionType.Equals("subscr_payment"))
            {
                return;
            }

            var subscriptionId   = Utils.GetBetween(ipnContext, "subscr_id=", "&");
            var transactionId    = Utils.GetBetween(ipnContext, "txn_id=", "&");
            var customValue      = Utils.GetBetween(ipnContext, "custom=", "&");
            var emailInformation = Uri.UnescapeDataString(Utils.GetBetween(ipnContext, "custom=", "_Socioboard"));
            var userId           = Utils.GetBetween(customValue + "<:>", "Id_", "<:>");
            var amount           = Utils.GetBetween(ipnContext, "payment_gross=", "&");
            var payerEmail       = Uri.UnescapeDataString(Utils.GetBetween(ipnContext, "payer_email=", "&"));
            var payerName        = $"{Utils.GetBetween(ipnContext, "first_name=", "&")} {Utils.GetBetween(ipnContext, "last_name=", "&")}";;
            var paymentStatus    = Utils.GetBetween(ipnContext, "payment_status=", "&");
            var itemName         = Utils.GetBetween(ipnContext, "item_name=", "&");
            var charset          = Utils.GetBetween(ipnContext, "charset=", "&");
            var subscriptionDate = Uri.UnescapeDataString(Utils.GetBetween(ipnContext, "payment_date=", "&").Replace("+", " "));



            var paymentTransaction = new PaymentTransaction
            {
                amount        = amount,
                email         = emailInformation,
                paymentdate   = DateTime.UtcNow,
                userid        = long.Parse(userId),
                PaymentType   = PaymentType.paypal,
                trasactionId  = transactionId,
                paymentId     = subscriptionId,
                payeremail    = payerEmail,
                Payername     = payerName,
                paymentstatus = paymentStatus,
                itemname      = itemName,
                media         = charset,
                subscrdate    = DateTime.Parse(subscriptionDate.Replace(" PDT", "").Replace(" PST", ""))
            };

            var passingData = Newtonsoft.Json.JsonConvert.SerializeObject(paymentTransaction);

            var param = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("information", passingData)
            };

            await WebApiReq.PostReq("/api/PaymentTransaction/UpdatePaypalTransactions", param, "", "", _appSettings.ApiDomain);

            // check that Payment_status=Completed
            // check that Txn_id has not been previously processed
            // check that Receiver_email is your Primary PayPal email
            // check that Payment_amount/Payment_currency are correct
            // process payment
        }
Esempio n. 26
0
        public async Task <IActionResult> UpgradeAccount(string packagename)
        {
            var user = HttpContext.Session.GetObjectFromJson <User>("User");

            if (user == null)
            {
                return(RedirectToAction("Index", "Index"));
            }

            if (packagename != "Free")
            {
                var parameters = new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string>("packagename", packagename)
                };

                var response = await WebApiReq.PostReq("/api/PaymentTransaction/GetPackage", parameters, "", "",
                                                       _appSettings.ApiDomain);

                if (!response.IsSuccessStatusCode)
                {
                    return(RedirectToAction("Index", "Index"));
                }

                try
                {
                    var package = await response.Content.ReadAsAsync <Package>();

                    HttpContext.Session.SetObjectAsJson("Package", package);

                    if (user.CreateDate.AddDays(29) > DateTime.UtcNow)
                    {
                        if (user.PaymentType == PaymentType.paypal)
                        {
                            var payment   = new Payment(_appSettings);
                            var paypalUrl = await payment.PaypalExpressPayment(package.amount, "USD", package.packagename, user.EmailId, user.Id,
                                                                               Guid.NewGuid().ToString());

                            return(Content(paypalUrl));
                        }
                        else
                        {
                            return(RedirectToAction("paymentWithPayUMoney", "Index"));
                        }
                    }

                    if (user.PaymentType == PaymentType.paypal)
                    {
                        var payment   = new Payment(_appSettings);
                        var paypalUrl = await payment.PaypalExpressPayment(package.amount, "USD", package.packagename, user.EmailId, user.Id,
                                                                           Guid.NewGuid().ToString());

                        return(Content(paypalUrl));
                    }

                    return(RedirectToAction("paymentWithPayUMoney", "Index"));
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
            }
            else
            {
                try
                {
                    var parameters = new List <KeyValuePair <string, string> >
                    {
                        new KeyValuePair <string, string>("userId", user.Id.ToString())
                    };

                    var response = await WebApiReq.PostReq("/api/User/UpdateFreeUser", parameters, "", "",
                                                           _appSettings.ApiDomain);

                    if (!response.IsSuccessStatusCode)
                    {
                        return(RedirectToAction("Index", "Index"));
                    }

                    var userCurrentDetails = await response.Content.ReadAsAsync <User>();

                    HttpContext.Session.SetObjectAsJson("User", userCurrentDetails);

                    return(Content(""));
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
            }

            return(RedirectToAction("Index", "Index"));
        }
        public async Task <ActionResult> Google(string code)
        {
            var googleLogin  = HttpContext.Session.GetObjectFromJson <string>("googlepluslogin");
            var googleSocial = HttpContext.Session.GetObjectFromJson <string>("Google");
            var plan         = HttpContext.Session.GetObjectFromJson <string>("RegisterPlan");

            if (googleSocial == "Youtube_Account" || googleSocial == "ReconGplusAccount" || googleSocial == "Gplus_Account" || googleSocial == "Ganalytics_Account" || googleSocial == "ReconnectYTAcc" || googleSocial == "ReConnectGoogleAnalytics")
            {
                googleLogin = null;
            }


            if (googleLogin != null && googleLogin.Equals("Google_Login"))
            {
                try
                {
                    var parameters = new List <KeyValuePair <string, string> >
                    {
                        new KeyValuePair <string, string>("code", code),
                        new KeyValuePair <string, string>("accType", plan)
                    };

                    var response = await WebApiReq.PostReq("/api/Google/GoogleLogin", parameters, "", "", _appSettings.ApiDomain);

                    if (!response.IsSuccessStatusCode)
                    {
                        return(RedirectToAction("Index", "Home"));
                    }

                    try
                    {
                        var user = await response.Content.ReadAsAsync <Domain.Socioboard.Models.User>();

                        // If expired, make user to use free plan
                        if (user.ExpiryDate < DateTime.UtcNow)
                        {
                            HttpContext.Session.Remove("User");

                            var param = new List <KeyValuePair <string, string> >
                            {
                                new KeyValuePair <string, string>("Id", user.Id.ToString())
                            };

                            var trialStatus = await WebApiReq.PostReq("/api/User/UpdateTrialStatus", param, "", "", _appSettings.ApiDomain);

                            if (!trialStatus.IsSuccessStatusCode)
                            {
                                return(RedirectToAction("Index", "Payment"));
                            }

                            var userDetails = await trialStatus.Content.ReadAsAsync <Domain.Socioboard.Models.User>();

                            HttpContext.Session.SetObjectAsJson("User", userDetails);
                            return(RedirectToAction("Index", "Home"));
                        }

                        HttpContext.Session.SetObjectAsJson("User", user);
                    }
                    catch (Exception)
                    {
                        try
                        {
                            HttpContext.Session.Remove("User");
                            TempData["Error"] = await response.Content.ReadAsStringAsync();

                            return(RedirectToAction("Index", "Index"));
                        }
                        catch (Exception ex)
                        {
                            _logger.LogError(ex.StackTrace);
                        }
                    }
                    return(RedirectToAction("Index", "Home"));
                }
                catch (Exception ex)
                {
                    _logger.LogError(ex.StackTrace);
                    HttpContext.Session.Remove("User");
                    return(RedirectToAction("Index", "Index"));
                }
            }


            if (googleSocial.Equals("Gplus_Account"))
            {
                HttpContext.Session.SetObjectAsJson("Google", null);
                return(RedirectToAction("AddGoogleAcc", "GoogleManager", new { code = code }));
            }
            if (googleSocial.Equals("Ganalytics_Account"))
            {
                HttpContext.Session.SetObjectAsJson("Google", null);
                return(RedirectToAction("AddGanalyticsAcc", "GoogleManager", new { code = code }));
            }
            if (googleSocial.Equals("ReconGplusAccount"))
            {
                HttpContext.Session.SetObjectAsJson("Google", null);
                return(RedirectToAction("ReconnectGplusAcc", "GoogleManager", new { code = code }));
            }
            if (googleSocial.Equals("ReconnectYTAcc"))
            {
                HttpContext.Session.SetObjectAsJson("Google", null);
                return(RedirectToAction("ReconnectYTAcc", "GoogleManager", new { code = code }));
            }
            if (googleSocial.Equals("Youtube_Account"))
            {
                HttpContext.Session.SetObjectAsJson("Google", null);
                return(RedirectToAction("AddYoutubeAcc", "GoogleManager", new { code = code }));
            }

            if (googleSocial.Equals("ReConnectGoogleAnalytics"))
            {
                HttpContext.Session.SetObjectAsJson("Google", null);
                return(RedirectToAction("ReconnectGoogleAnalyticsAcc", "GoogleManager", new { code = code }));
            }

            return(View());
        }
        public async Task <ActionResult> Google(string code)
        {
            string googleLogin  = HttpContext.Session.GetObjectFromJson <string>("googlepluslogin");
            string googleSocial = HttpContext.Session.GetObjectFromJson <string>("Google");
            string plan         = HttpContext.Session.GetObjectFromJson <string>("RegisterPlan");

            if (googleLogin != null && googleLogin.Equals("Google_Login"))
            {
                Domain.Socioboard.Models.User         user       = null;
                List <KeyValuePair <string, string> > Parameters = new List <KeyValuePair <string, string> >();
                Parameters.Add(new KeyValuePair <string, string>("code", code));
                Parameters.Add(new KeyValuePair <string, string>("accType", plan));
                HttpResponseMessage response = await WebApiReq.PostReq("/api/Google/GoogleLogin", Parameters, "", "", _appSettings.ApiDomain);

                if (response.IsSuccessStatusCode)
                {
                    try
                    {
                        user = await response.Content.ReadAsAsync <Domain.Socioboard.Models.User>();

                        HttpContext.Session.SetObjectAsJson("User", user);
                        if (user.ExpiryDate < DateTime.UtcNow && user.AccountType == Domain.Socioboard.Enum.SBAccountType.Free)
                        {
                            return(RedirectToAction("Index", "Home"));
                        }
                        else if ((user.PayPalAccountStatus == Domain.Socioboard.Enum.PayPalAccountStatus.notadded || user.PayPalAccountStatus == Domain.Socioboard.Enum.PayPalAccountStatus.inprogress) && (user.AccountType != Domain.Socioboard.Enum.SBAccountType.Free))
                        {
                            if (user.PaymentType == Domain.Socioboard.Enum.PaymentType.paypal)
                            {
                                return(RedirectToAction("PayPalAccount", "Home", new { emailId = user.EmailId, IsLogin = true }));
                            }
                            else
                            {
                                return(RedirectToAction("paymentWithPayUMoney", "Index"));
                            }
                            // return RedirectToAction("PayPalAccount", "Home", new { emailId = user.EmailId, IsLogin = true });
                        }
                    }
                    catch (Exception ex)
                    {
                        try
                        {
                            TempData["Error"] = await response.Content.ReadAsStringAsync();

                            return(RedirectToAction("Index", "Index"));
                        }
                        catch (Exception exe) { }
                    }
                }
                return(RedirectToAction("Index", "Home"));
            }
            else if (googleSocial.Equals("Gplus_Account"))
            {
                HttpContext.Session.SetObjectAsJson("Google", null);
                return(RedirectToAction("AddGoogleAcc", "GoogleManager", new { code = code }));
            }
            else if (googleSocial.Equals("Ganalytics_Account"))
            {
                HttpContext.Session.SetObjectAsJson("Google", null);
                return(RedirectToAction("AddGanalyticsAcc", "GoogleManager", new { code = code }));
            }
            else if (googleSocial.Equals("Youtube_Account"))
            {
                HttpContext.Session.SetObjectAsJson("Google", null);
                return(RedirectToAction("AddYoutubeAcc", "GoogleManager", new { code = code }));
            }
            return(View());
        }
        public async Task <IActionResult> PayUMoneySuccessful(FormCollection form)
        {
            string status = Request.Form["status"].ToString();
            string plan   = string.Empty;
            string output = "false";

            Domain.Socioboard.Models.Package _Package = HttpContext.Session.GetObjectFromJson <Domain.Socioboard.Models.Package>("Package");
            if (status == "success")
            {
                if (_Package.packagename == "Free")
                {
                    plan = "Free";
                }
                else if (_Package.packagename == "Deluxe")
                {
                    plan = "Deluxe";
                }
                else if (_Package.packagename == "Premium")
                {
                    plan = "Premium";
                }
                else if (_Package.packagename == "Topaz")
                {
                    plan = "Topaz";
                }
                else if (_Package.packagename == "Platinum")
                {
                    plan = "Platinum";
                }
                else if (_Package.packagename == "Gold")
                {
                    plan = "Gold";
                }
                else if (_Package.packagename == "Ruby")
                {
                    plan = "Ruby";
                }
                else if (_Package.packagename == "Standard")
                {
                    plan = "Standard";
                }
                string payuMoneyId = Request.Form["payuMoneyId"].ToString();
                string PG_TYPE     = Request.Form["PG_TYPE"].ToString();
                string txnid       = Request.Form["txnid"].ToString();
                string amount      = Request.Form["amount"].ToString();
                string productinfo = Request.Form["productinfo"].ToString();
                Domain.Socioboard.Models.User user = HttpContext.Session.GetObjectFromJson <Domain.Socioboard.Models.User>("User");

                List <KeyValuePair <string, string> > Parameters = new List <KeyValuePair <string, string> >();
                Parameters.Add(new KeyValuePair <string, string>("userId", user.Id.ToString()));
                Parameters.Add(new KeyValuePair <string, string>("UserName", user.FirstName + " " + user.LastName));
                Parameters.Add(new KeyValuePair <string, string>("email", user.EmailId));
                Parameters.Add(new KeyValuePair <string, string>("amount", amount));
                Parameters.Add(new KeyValuePair <string, string>("PaymentType", user.PaymentType.ToString()));
                Parameters.Add(new KeyValuePair <string, string>("trasactionId", txnid));
                Parameters.Add(new KeyValuePair <string, string>("paymentId", payuMoneyId));
                Parameters.Add(new KeyValuePair <string, string>("accType", plan));
                HttpResponseMessage response = await WebApiReq.PostReq("/api/PaymentTransaction/UpgradeAccount", Parameters, "", "", _appSettings.ApiDomain);

                if (response.IsSuccessStatusCode)
                {
                    try
                    {
                        string data = await response.Content.ReadAsStringAsync();

                        if (data == "payment done")
                        {
                            List <KeyValuePair <string, string> > _Parameters = new List <KeyValuePair <string, string> >();
                            // _Parameters.Add(new KeyValuePair<string, string>("Id", user.Id.ToString()));
                            HttpResponseMessage _response = await WebApiReq.GetReq("/api/User/GetUser?Id=" + user.Id.ToString(), "", "", _appSettings.ApiDomain);

                            if (response.IsSuccessStatusCode)
                            {
                                try
                                {
                                    Domain.Socioboard.Models.User _user = await _response.Content.ReadAsAsync <Domain.Socioboard.Models.User>();

                                    HttpContext.Session.SetObjectAsJson("User", _user);
                                    //SendInvoiceMerchant(_user.PhoneNumber, _user.EmailId, _user.FirstName, amount, productinfo, txnid, _appSettings.PayUMoneyURL);
                                    // output = "true";
                                    return(RedirectToAction("Index", "Home"));
                                }
                                catch { }
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        return(RedirectToAction("Index", "Index"));
                    }
                }
            }
            return(RedirectToAction("Index", "Index"));
        }
        public async Task <ActionResult> PayPalAccount(string emailId, bool IsLogin)
        {
            HttpResponseMessage userresponse = await WebApiReq.GetReq("/api/User/GetUserData?emailId=" + emailId, "", "", _appSettings.ApiDomain);

            if (userresponse.IsSuccessStatusCode)
            {
                string package = string.Empty;
                User   user    = await userresponse.Content.ReadAsAsync <User>();

                HttpContext.Session.SetObjectAsJson("User", user);
                if (user.AccountType == Domain.Socioboard.Enum.SBAccountType.Free)
                {
                    package = "Free";
                }
                else if (user.AccountType == Domain.Socioboard.Enum.SBAccountType.Deluxe)
                {
                    package = "Deluxe";
                }
                else if (user.AccountType == Domain.Socioboard.Enum.SBAccountType.Premium)
                {
                    package = "Premium";
                }
                else if (user.AccountType == Domain.Socioboard.Enum.SBAccountType.Topaz)
                {
                    package = "Topaz";
                }
                else if (user.AccountType == Domain.Socioboard.Enum.SBAccountType.Platinum)
                {
                    package = "Platinum";
                }
                else if (user.AccountType == Domain.Socioboard.Enum.SBAccountType.Gold)
                {
                    package = "Gold";
                }
                else if (user.AccountType == Domain.Socioboard.Enum.SBAccountType.Ruby)
                {
                    package = "Ruby";
                }
                else if (user.AccountType == Domain.Socioboard.Enum.SBAccountType.Standard)
                {
                    package = "Standard";
                }
                List <KeyValuePair <string, string> > Parameter = new List <KeyValuePair <string, string> >();
                Parameter.Add(new KeyValuePair <string, string>("packagename", package));
                HttpResponseMessage respons = await WebApiReq.PostReq("/api/PaymentTransaction/GetPackage", Parameter, "", "", _appSettings.ApiDomain);

                if (respons.IsSuccessStatusCode)
                {
                    try
                    {
                        Domain.Socioboard.Models.Package _Package = await respons.Content.ReadAsAsync <Domain.Socioboard.Models.Package>();

                        HttpContext.Session.SetObjectAsJson("Package", _Package);
                        if (!IsLogin)
                        {
                            if (user.PaymentType == Domain.Socioboard.Enum.PaymentType.paypal)
                            {
                                HttpContext.Session.SetObjectAsJson("paymentsession", true);
                                string paypalUrl = Helpers.Payment.RecurringPaymentWithPayPal(_Package.amount, _Package.packagename, user.FirstName + " " + user.LastName, user.PhoneNumber, user.EmailId, "USD", _appSettings.paypalemail, _appSettings.callBackUrl, _appSettings.failUrl, _appSettings.callBackUrl, _appSettings.cancelurl, _appSettings.notifyUrl, "", _appSettings.PaypalURL);
                                return(Content(paypalUrl));
                            }
                            else
                            {
                                HttpContext.Session.SetObjectAsJson("paymentsession", true);
                                return(RedirectToAction("paymentWithPayUMoney", "Index"));
                            }
                        }
                        else
                        {
                            if (user.PaymentType == Domain.Socioboard.Enum.PaymentType.paypal)
                            {
                                HttpContext.Session.SetObjectAsJson("paymentsession", true);
                                return(Redirect(Helpers.Payment.RecurringPaymentWithPayPal(_Package.amount, _Package.packagename, user.FirstName + " " + user.LastName, user.PhoneNumber, user.EmailId, "USD", _appSettings.paypalemail, _appSettings.callBackUrl, _appSettings.failUrl, _appSettings.callBackUrl, _appSettings.cancelurl, _appSettings.notifyUrl, "", _appSettings.PaypalURL)));
                            }
                            else
                            {
                                HttpContext.Session.SetObjectAsJson("paymentsession", true);
                                return(RedirectToAction("paymentWithPayUMoney", "Index", new { contesnt = false }));
                            }
                        }
                    }
                    catch (Exception ex) { }
                }
            }
            return(Content(""));
        }