protected void Page_Load(object sender, EventArgs e) { int.TryParse("" + Request.QueryString["id_content"], out id_content); if (id_content > 0) { content = DataMapping.GetContent_by_ID(id_content); if (content != null && content.id > 0) { Session["type"] = content.type; //if (contenu.type == "Annonce" && contenu.id_user == UserInfo.UserID) //{ // Panel2.Visible = true; // Panel1.Visible = false; // Binding_Panel2(); //} //else if (contenu.type == "PagePro" && contenu.id_user == UserInfo.UserID) //{ // Panel2.Visible = false; // Panel1.Visible = true; // membre = DataMapping.GetMemberByUserID(contenu.id_user); // if (membre != null && membre.id != null && membre.id > 0 && membre.nim > 0) // { // affectation = DataMapping.GetAffectation(membre.nim, DateTime.Now.Year); // Binding_Panel1(); // } //} if (DataMapping.Sub_Active_by_id_content(content.id, content.type) == false && content.id_user == UserInfo.UserID) { Panel3.Visible = true; if (content.type == "Annonce") { item_name = "Paiement pour l'annonce " + content.title; item_value = content.id.ToString(); amount = Const.Price_Announcement; } else if (content.type == "PagePro") { member = DataMapping.GetMemberByUserID(content.id_user); string nameMember = ""; if (member != null) { if (!string.IsNullOrEmpty(member.surname)) { nameMember += member.surname; } if (!string.IsNullOrEmpty(member.name)) { nameMember += " " + member.name; } } item_name = "Paiement pour la présentation de " + nameMember.Trim(); item_value = content.id.ToString(); amount = Const.Price_Presentation; } string url = Globals.NavigateURL(abonnementtabid); //data-notify_url=\"http://www.rotary1730.org/EspaceProfessionnel/RetourPaypal.aspx\" //A commenter pour passer en PROD //LTL_Paypal.Text = "<script src=\"https://www.paypalobjects.com/js/external/[email protected]\" data-tax=\"0\" data-shipping=\"0\" data-currency=\"EUR\" data-amount=\"" + amount + "\" data-quantity=\"1\" data-name=\"" + item_name + "\" data-number=\"" + item_value + "\" data-lc=\"fr_FR\" data-button=\"donate\" data-env=\"sandbox\" data-return=" + url + " data-cancel=\"http://www.rotary1730.org\" ></script>"; //A decommenter pour passer en PROD LTL_Paypal.Text = "<script src=\"https://www.paypalobjects.com/js/external/[email protected]\" data-tax=\"0\" data-shipping=\"0\" data-currency=\"EUR\" data-amount=\"" + amount + "\" data-quantity=\"1\" data-name=\"" + item_name + "\" data-number=\"" + item_value + "\" data-lc=\"fr_FR\" data-button=\"donate\" data-return=" + url + " data-cancel=\"http://www.rotary1730.org\" ></script>"; } else { Panel3.Visible = false; } if (UserInfo.IsSuperUser) { //Panel2.Visible = true; //Panel1.Visible = true; Panel3.Visible = true; //Binding_Panel2(); //Binding_Panel1(); } } else if (UserInfo.IsSuperUser) { //Panel2.Visible = true; //Panel1.Visible = true; Panel3.Visible = true; } else { if (PortalSettings.HomeTabId > 0) { Response.Redirect(Globals.NavigateURL(PortalSettings.HomeTabId), true); } else { Response.Redirect(Globals.GetPortalDomainName(PortalSettings.PortalAlias.HTTPAlias, Request, true), true); } } } else if (UserInfo.IsSuperUser) { //Panel2.Visible = true; //Panel1.Visible = true; Panel3.Visible = true; } else { if (PortalSettings.HomeTabId > 0) { Response.Redirect(Globals.NavigateURL(PortalSettings.HomeTabId), true); } else { Response.Redirect(Globals.GetPortalDomainName(PortalSettings.PortalAlias.HTTPAlias, Request, true), true); } } }
protected void Page_Load(object sender, EventArgs e) { if (UserInfo.IsInRole(Const.ROLE_MEMBERS) || UserInfo.IsSuperUser) { int.TryParse("" + Request.QueryString["id_contenu"], out id_contenu); if (id_contenu > 0) { contenu = DataMapping.GetContent_by_ID(id_contenu); if (contenu != null) { if ((contenu.id > 0 && UserInfo.UserID == contenu.id_user) || UserInfo.IsSuperUser)// seul le super user et le propriétaire de la page peut accéder à cette page de modif { DirectoryInfo d = new DirectoryInfo(Server.MapPath(PortalSettings.Current.HomeDirectory + Const.CONTENT_ANNOUNCEMENT_PREFIX + contenu.id + "/")); if (!d.Exists) { d.Create(); } TXT_Editor.ImageManager.UploadPaths = new string[] { PortalSettings.Current.HomeDirectory + Const.CONTENT_ANNOUNCEMENT_PREFIX + contenu.id + "/" }; TXT_Editor.DocumentManager.UploadPaths = new string[] { PortalSettings.Current.HomeDirectory + Const.CONTENT_ANNOUNCEMENT_PREFIX + contenu.id + "/" }; if (IsPostBack == false) { Binding_Panel1(); } //if (IsPostBack == false) } //if (UserIdQuery > 0 && UserInfo.UserID == UserIdQuery) || UserInfo.IsSuperUser) else { if (PortalSettings.HomeTabId > 0) { Response.Redirect(Globals.NavigateURL(PortalSettings.HomeTabId), true); } else { Response.Redirect(Globals.GetPortalDomainName(PortalSettings.PortalAlias.HTTPAlias, Request, true), true); } } }//if (contenu != null && contenu.id > 0) else { if (PortalSettings.HomeTabId > 0) { Response.Redirect(Globals.NavigateURL(PortalSettings.HomeTabId), true); } else { Response.Redirect(Globals.GetPortalDomainName(PortalSettings.PortalAlias.HTTPAlias, Request, true), true); } } }//if (id_contenu > 0) else if (UserInfo.IsSuperUser || UserInfo.IsInRole(Const.ROLE_MEMBERS)) { if (IsPostBack == false && !UserInfo.IsSuperUser) { Session["Insert"] = "o"; Binding_Panel2(); }//if (IsPostBack == false) else if (UserInfo.IsSuperUser) { Binding_Panel1(); } } else { if (PortalSettings.HomeTabId > 0) { Response.Redirect(Globals.NavigateURL(PortalSettings.HomeTabId), true); } else { Response.Redirect(Globals.GetPortalDomainName(PortalSettings.PortalAlias.HTTPAlias, Request, true), true); } } }//if (UserInfo.IsInRole(Const.ROLE_MEMBRES) || UserInfo.IsSuperUser) else { if (PortalSettings.HomeTabId > 0) { Response.Redirect(Globals.NavigateURL(PortalSettings.HomeTabId), true); } else { Response.Redirect(Globals.GetPortalDomainName(PortalSettings.PortalAlias.HTTPAlias, Request, true), true); } } }
protected void Page_Load(object sender, EventArgs e) { //Post back to either sandbox or live //string strSandbox = "https://www.sandbox.paypal.com/cgi-bin/webscr"; string strLive = "https://www.paypal.com/cgi-bin/webscr"; //Pour la prod, passer HttpWebRequest req = (HttpWebRequest)WebRequest.Create(strLive); en decommenté et l'autre en commenter //HttpWebRequest req = (HttpWebRequest)WebRequest.Create(strSandbox); HttpWebRequest req = (HttpWebRequest)WebRequest.Create(strLive); //Set values for the request back req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; byte[] param = Request.BinaryRead(HttpContext.Current.Request.ContentLength); string strRequest = Encoding.ASCII.GetString(param); string strResponse_copy = strRequest; //Save a copy of the initial info sent by PayPal strRequest += "&cmd=_notify-validate"; req.ContentLength = strRequest.Length; //for proxy //WebProxy proxy = new WebProxy(new Uri("http://url:port#")); //req.Proxy = proxy; //Send the request to PayPal and get the response StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII); streamOut.Write(strRequest); streamOut.Close(); StreamReader streamIn = new StreamReader(req.GetResponse().GetResponseStream()); string strResponse = streamIn.ReadToEnd(); streamIn.Close(); if (strResponse.ToLower() == "verified") { //check the payment_status is 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 // pull the values passed on the initial message from PayPal NameValueCollection these_argies = HttpUtility.ParseQueryString(strResponse_copy); string user_email = "" + these_argies["payer_email"]; string pay_stat = "" + these_argies["payment_status"]; string Item_name = "" + these_argies["item_name"]; string Item_number = "" + these_argies["item_number"]; string Payment_amount = "" + these_argies["mc_gross"]; string Payment_currency = "" + these_argies["mc_currency"]; string Txn_id = "" + these_argies["txn_id"]; Txn_id = Txn_id.Trim(); string Receiver_email = "" + these_argies["receiver_email"]; if (pay_stat.ToLower().Equals("completed")) { if (!string.IsNullOrEmpty(Item_number) && !string.IsNullOrEmpty(Txn_id)) { int id_contenu = 0; int.TryParse(Item_number, out id_contenu); double montant = 0; double.TryParse(Payment_amount, System.Globalization.NumberStyles.Number, CultureInfo.InvariantCulture, out montant); if (id_contenu > 0 && !string.IsNullOrEmpty(Txn_id) && montant > 0) { AIS.Content c = DataMapping.GetContent_by_ID(id_contenu); if (c != null) { DateTime fin = DateTime.Now; if (c.type == "PagePro") { fin = fin.AddMonths(Const.Duration_Presentation); } else if (c.type == "Annonce") { fin = fin.AddMonths(Const.Duration_Announcement); } bool?test = DataMapping.IdOrder_Exist(Txn_id); if (test != null && test == false) { if (DataMapping.Insert_Subscription(c.id_user, Txn_id, c.id, c.type, DateTime.Now, fin, "o", montant) == true) { if (DataMapping.Update_Publish("o", c.id) == true) { Member m = DataMapping.GetMemberByUserID(c.id_user); string message = "Un paiement a été effectué.<br/>"; if (c.type == "Annonce") { message += "Il concerne l'annonce: <a href=\"" + Functions.UrlAddParam(Globals.NavigateURL(annoncetabid), "id_contenu", "" + c.id) + "\">" + c.title + "</a> <br/>"; } else { message += "Il concerne la présentation du membre: <a href=\"" + Functions.UrlAddParam(Globals.NavigateURL(presentationtabid), "UserId", "" + c.id_user) + "\">" + m.surname + " " + m.name + "</a> <br/>"; } PortalSettings ps = Globals.GetPortalSettings(); Functions.SendMail(ps.Email, "Paiement effectué", message); } else { Exception ee = new Exception("Erreur après paiement lors de la mise à publication du contenu : " + c.id); Functions.Error(ee); } } else { Exception ee = new Exception("Erreur lors de l'insert de l'abonnement pour le contenu : " + c.id + " pour la commande : " + Txn_id); Functions.Error(ee); } } else if (test != null && test == true) { //Exception ee = new Exception("La transaction: " + id_commande + " existe!"); //Functions.Error(ee); } else if (test == null) { Exception ee = new Exception("Impossible de vérifier si la transaction: " + Txn_id + " existe!"); Functions.Error(ee); } } else { Exception ee = new Exception("Content: " + id_contenu + " non récupéré!"); Functions.Error(ee); } } else { Exception ee = new Exception("PB Conversion de " + Item_number + " en id_contenu = " + id_contenu + " et/ou de " + Payment_amount + " en montant = " + montant + " et/ou le numéro de commande est vide ou null "); Functions.Error(ee); } } else { Exception ee = new Exception("Le retour paiement : Item_number et/ou Txn_id vide ou null."); Functions.Error(ee); } } else { Exception ee = new Exception("Le retour paiement du contenu : " + Item_number + " ayant l'id transaction paypal : " + Txn_id + " n'est pas completed. Il est a l'état : " + pay_stat); Functions.Error(ee); } } else if (strResponse.ToLower() == "invalid") { Exception ee = new Exception("Le retour paiement est revenu Invalid"); Functions.Error(ee); } else { Exception ee = new Exception("Le retour paiement n'est pas revenu Invalid ou Verified"); Functions.Error(ee); } }
protected void Page_Load(object sender, EventArgs e) { int.TryParse("" + Request.QueryString["id_content"], out id_content); if (id_content > 0) { content = DataMapping.GetContent_by_ID(id_content); if (content.id_user == UserInfo.UserID) { BTN_Edit.Visible = true; } else if (UserInfo.IsSuperUser) { BTN_Edit.Visible = true; } else { BTN_Edit.Visible = false; } if (DataMapping.Sub_Active_by_id_content(id_content, "Annonce") == true || UserInfo.IsSuperUser || UserInfo.UserID == content.id_user) //La page est accessible par superuser, par le membre propriétaire même si l'abonnement est inactif { Binding_Panel2(); } else { if (PortalSettings.HomeTabId > 0) { Response.Redirect(Globals.NavigateURL(PortalSettings.HomeTabId), true); } else { Response.Redirect(Globals.GetPortalDomainName(PortalSettings.PortalAlias.HTTPAlias, Request, true), true); } } } else if (UserInfo.IsSuperUser) { BTN_Edit.Visible = true; Binding_Panel2(); } else { List <AIS.Content> contenus = DataMapping.GetListContentHOMEPAGE("Annonce", 1); if (contenus != null && contenus.Count() > 0) { content = contenus[0]; id_content = contenus[0].id; if (content.id_user == UserInfo.UserID) { BTN_Edit.Visible = true; } else if (UserInfo.IsSuperUser) { BTN_Edit.Visible = true; } else { BTN_Edit.Visible = false; } Binding_Panel2(); } else { if (PortalSettings.HomeTabId > 0) { Response.Redirect(Globals.NavigateURL(PortalSettings.HomeTabId), true); } else { Response.Redirect(Globals.GetPortalDomainName(PortalSettings.PortalAlias.HTTPAlias, Request, true), true); } } } }