public ActionResult ProceedToPaypal(Student student) { try { string encodemodel = System.Web.Helpers.Json.Encode(student); string data = Uri.EscapeDataString(encodemodel); Context db = new Context(); string subdomain = Request.Url.Host.Split(new char[] { '.' })[0]; var oSetting = (from setting in db.EnrolSetting join company in db.Company on setting.CompanyID equals company.CompanyID where setting.SiteName == subdomain select new { companyid = setting.CompanyID, brand = company.CompanyName, domain = setting.SiteName, logo = setting.LogoUrl, webexperienceid = setting.WebExperienceID, payee = setting.PaypalEmail }).FirstOrDefault(); string WebExperienceProfileID = oSetting.webexperienceid; if (string.IsNullOrWhiteSpace(WebExperienceProfileID)) { WebExperienceProfileID = PaypalService.webexperience(oSetting.domain, oSetting.brand, oSetting.logo); string query = "Update EnrollSettings Set WebExperienceID = '" + WebExperienceProfileID + "' Where CompanyID = " + oSetting.companyid; var QueryResult = db.Database.ExecuteSqlCommand(query); } var payment = PaypalService.CreatePayment(GetBaseUrl(), "sale", (student.TotalClassPrice - student.DiscountPrice).ToString(), oSetting.payee, WebExperienceProfileID, data); string approvlurl = payment.GetApprovalUrl(); return(Redirect(approvlurl)); } catch (Exception ex) { FlashMessage.Warning(ex.Message); return(RedirectToAction("RegistrationError")); } }