private void SavePayPalInfo(bool approved, EventInfo objEvent) { this._objEventSignups = this._objCtlEventSignups.EventsSignupsGet(int.Parse(this._itemNumber), 0, true); this._objEventSignups.Approved = approved; this._objEventSignups.PayPalAddress = this._addressStreet; this._objEventSignups.PayPalCity = this._addressCity; this._objEventSignups.PayPalCountry = this._addressCountry; this._objEventSignups.PayPalAmount = Convert.ToDecimal(this._paymentGross); this._objEventSignups.PayPalCurrency = this._currency; this._objEventSignups.PayPalFee = Convert.ToDecimal(this._paymentFee); this._objEventSignups.PayPalFirstName = this._firstName; this._objEventSignups.PayPalLastName = this._lastName; this._objEventSignups.PayPalPayerEmail = this._payerEmail; this._objEventSignups.PayPalPayerID = this._subscrID; this._objEventSignups.PayPalPayerStatus = this._payerStatus; this._objEventSignups.PayPalPaymentDate = DateTime.UtcNow; this._objEventSignups.PayPalReason = this._pendingReason; this._objEventSignups.PayPalRecieverEmail = this._receiverEmail; this._objEventSignups.PayPalState = this._addressState; this._objEventSignups.PayPalStatus = this._paymentStatus.ToLower(); this._objEventSignups.PayPalTransID = this._txnID; //objEventSignups.PayPalUserEmail = pay.IPNUserEmail this._objEventSignups.PayPalZip = this._addressZip; var eventsBase = new EventBase(); eventsBase.CreateEnrollment(this._objEventSignups, objEvent, this._settings); }
/// <summary> /// Informs the core journal that a user has enrolled to attend an event. /// </summary> /// <param name="objEventSignup"></param> /// <param name="objEvent"></param> /// <param name="tabId"></param> /// <param name="url"></param> /// <param name="userid"></param> public void NewEnrollment(EventSignupsInfo objEventSignup, EventInfo objEvent, int tabId, string url, int userid) { var objectKey = Constants.ContentEventTypeName + "_" + Constants.JournalEventAttendTypeName + "_" + string.Format("{0}:{1};{2}", objEventSignup.ModuleID, objEventSignup.EventID, objEventSignup.SignupID); var ji = JournalController.Instance.GetJournalItemByKey(objEvent.PortalID, objectKey); if (ji != null) { JournalController.Instance.DeleteJournalItemByKey(objEvent.PortalID, objectKey); } var securitySet = "E,"; var socialGroupId = 0; if (objEvent.SocialGroupId > 0) { securitySet = ","; socialGroupId = objEvent.SocialGroupId; } ji = new JournalItem { PortalId = objEvent.PortalID, ProfileId = objEventSignup.UserID, UserId = userid, ContentItemId = 0, Title = objEvent.EventName, ItemData = new ItemData { Url = url }, Summary = null, Body = null, JournalTypeId = GetEventAttendJournalTypeId(objEvent.PortalID), ObjectKey = objectKey, SecuritySet = securitySet, SocialGroupId = socialGroupId }; JournalController.Instance.SaveJournalItem(ji, tabId); }
protected void cmdPurchase_Click(object sender, EventArgs e) { var objEvent = default(EventInfo); try { if (this.Page.IsValid) { objEvent = this._objCtlEvent.EventsGet(this._itemID, this.ModuleId); // User wants to purchase event, create Event Signup Record this._objEventSignups = new EventSignupsInfo(); //Just in case the user has clicked back and has now clicked Purchase again!! var objEventSignupsChk = default(EventSignupsInfo); if (string.IsNullOrEmpty(this._anonEmail)) { objEventSignupsChk = this._objCtlEventSignups.EventsSignupsGetUser( objEvent.EventID, this.UserId, objEvent.ModuleID); } else { objEventSignupsChk = this._objCtlEventSignups.EventsSignupsGetAnonUser( objEvent.EventID, this._anonEmail, objEvent.ModuleID); } if (!ReferenceEquals(objEventSignupsChk, null)) { this._objEventSignups.SignupID = objEventSignupsChk.SignupID; } this._objEventSignups.EventID = objEvent.EventID; this._objEventSignups.ModuleID = objEvent.ModuleID; if (string.IsNullOrEmpty(this._anonEmail)) { this._objEventSignups.UserID = this.UserId; this._objEventSignups.AnonEmail = null; this._objEventSignups.AnonName = null; this._objEventSignups.AnonTelephone = null; this._objEventSignups.AnonCulture = null; this._objEventSignups.AnonTimeZoneId = null; } else { var objSecurity = new PortalSecurity(); this._objEventSignups.UserID = -1; this._objEventSignups.AnonEmail = objSecurity.InputFilter(this._anonEmail, PortalSecurity.FilterFlag.NoScripting); this._objEventSignups.AnonName = objSecurity.InputFilter(this._anonName, PortalSecurity.FilterFlag.NoScripting); this._objEventSignups.AnonTelephone = objSecurity.InputFilter(this._anonTelephone, PortalSecurity.FilterFlag.NoScripting); this._objEventSignups.AnonCulture = Thread.CurrentThread.CurrentCulture.Name; this._objEventSignups.AnonTimeZoneId = this.GetDisplayTimeZoneId(); } this._objEventSignups.PayPalStatus = "none"; this._objEventSignups.PayPalReason = "PayPal call initiated..."; this._objEventSignups.PayPalPaymentDate = DateTime.UtcNow; this._objEventSignups.Approved = false; this._objEventSignups.NoEnrolees = int.Parse(this.lblNoEnrolees.Text); this._objEventSignups = this.CreateEnrollment(this._objEventSignups, objEvent); if (!ReferenceEquals(objEventSignupsChk, null)) { this._objEventSignups = this._objCtlEventSignups.EventsSignupsGet(objEventSignupsChk.SignupID, objEventSignupsChk.ModuleID, false); } // Mail users if (this.Settings.SendEnrollMessagePaying) { var objEventEmailInfo = new EventEmailInfo(); var objEventEmail = new EventEmails(this.PortalId, this.ModuleId, this.LocalResourceFile, ((PageBase)this.Page).PageCulture.Name); objEventEmailInfo.TxtEmailSubject = this.Settings.Templates.txtEnrollMessageSubject; objEventEmailInfo.TxtEmailBody = this.Settings.Templates.txtEnrollMessagePaying; objEventEmailInfo.TxtEmailFrom = this.Settings.StandardEmail; if (string.IsNullOrEmpty(this._anonEmail)) { objEventEmailInfo.UserEmails.Add(this.PortalSettings.UserInfo.Email); objEventEmailInfo.UserLocales.Add(this.PortalSettings.UserInfo.Profile.PreferredLocale); objEventEmailInfo.UserTimeZoneIds.Add(this.PortalSettings.UserInfo.Profile.PreferredTimeZone .Id); } else { objEventEmailInfo.UserEmails.Add(this._objEventSignups.AnonEmail); objEventEmailInfo.UserLocales.Add(this._objEventSignups.AnonCulture); objEventEmailInfo.UserTimeZoneIds.Add(this._objEventSignups.AnonTimeZoneId); } objEventEmailInfo.UserIDs.Add(objEvent.OwnerID); objEventEmail.SendEmails(objEventEmailInfo, objEvent, this._objEventSignups); } // build PayPal URL var ppurl = this.Settings.Paypalurl + "/cgi-bin/webscr?cmd=_xclick&business="; var socialGroupId = this.GetUrlGroupId(); var objEventInfoHelper = new EventInfoHelper(this.ModuleId, this.TabId, this.PortalId, this.Settings); var returnURL = ""; if (socialGroupId > 0) { returnURL = objEventInfoHelper.AddSkinContainerControls( Globals.NavigateURL(this.TabId, "PPEnroll", "Mid=" + Convert.ToString(this.ModuleId), "signupid=" + Convert.ToString(this._objEventSignups.SignupID), "status=enrolled", "groupid=" + socialGroupId), "?"); } else { returnURL = objEventInfoHelper.AddSkinContainerControls( Globals.NavigateURL(this.TabId, "PPEnroll", "Mid=" + Convert.ToString(this.ModuleId), "signupid=" + Convert.ToString(this._objEventSignups.SignupID), "status=enrolled"), "?"); } if (returnURL.IndexOf("://") + 1 == 0) { returnURL = Globals.AddHTTP(Globals.GetDomainName(this.Request)) + returnURL; } var cancelURL = ""; if (socialGroupId > 0) { cancelURL = objEventInfoHelper.AddSkinContainerControls( Globals.NavigateURL(this.TabId, "PPEnroll", "Mid=" + Convert.ToString(this.ModuleId), "signupid=" + Convert.ToString(this._objEventSignups.SignupID), "status=cancelled", "groupid=" + socialGroupId), "?"); } else { cancelURL = objEventInfoHelper.AddSkinContainerControls( Globals.NavigateURL(this.TabId, "PPEnroll", "Mid=" + Convert.ToString(this.ModuleId), "signupid=" + Convert.ToString(this._objEventSignups.SignupID), "status=cancelled"), "?"); } if (cancelURL.IndexOf("://") + 1 == 0) { cancelURL = Globals.AddHTTP(Globals.GetDomainName(this.Request)) + cancelURL; } var strPayPalURL = ""; strPayPalURL = ppurl + Globals.HTTPPOSTEncode(objEvent.PayPalAccount); strPayPalURL = strPayPalURL + "&item_name=" + Globals.HTTPPOSTEncode(objEvent.ModuleTitle + " - " + this.lblEventName.Text + " ( " + this.lblFee.Text + " " + this.lblFeeCurrency.Text + " )"); strPayPalURL = strPayPalURL + "&item_number=" + Globals.HTTPPOSTEncode(Convert.ToString(this._objEventSignups.SignupID)); strPayPalURL = strPayPalURL + "&quantity=" + Globals.HTTPPOSTEncode(Convert.ToString(this._objEventSignups.NoEnrolees)); strPayPalURL = strPayPalURL + "&custom=" + Globals.HTTPPOSTEncode( Convert.ToDateTime(this.lblStartDate.Text).ToShortDateString()); // Make sure currency is in correct format var dblFee = double.Parse(this.lblFee.Text); var uiculture = Thread.CurrentThread.CurrentCulture; Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; strPayPalURL = strPayPalURL + "&amount=" + Globals.HTTPPOSTEncode(Strings.Format(dblFee, "#,##0.00")); Thread.CurrentThread.CurrentCulture = uiculture; strPayPalURL = strPayPalURL + "¤cy_code=" + Globals.HTTPPOSTEncode(this.lblTotalCurrency.Text); strPayPalURL = strPayPalURL + "&return=" + returnURL; strPayPalURL = strPayPalURL + "&cancel_return=" + cancelURL; strPayPalURL = strPayPalURL + "¬ify_url=" + Globals.HTTPPOSTEncode(Globals.AddHTTP(Globals.GetDomainName(this.Request)) + "/DesktopModules/Events/EventIPN.aspx"); strPayPalURL = strPayPalURL + "&undefined_quantity=&no_note=1&no_shipping=1"; //strPayPalURL = strPayPalURL & "&undefined_quantity=&no_note=1&no_shipping=1&rm=2" // redirect to PayPal this.Response.Redirect(strPayPalURL, true); } } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }
private void MailUsTheOrder(string tagMsg, bool sendToUser = true) { // ********* RWJS - Seems to add no value, and would have always returned nothing ********* // InitializeSettings(Item_number) var sMessage = ""; var sEmail = ""; var strNewLine = Environment.NewLine; if (this._settings.HTMLEmail == "html") { strNewLine = "<br />"; } sMessage = tagMsg + strNewLine + "Transaction ID: " + this._txnID + strNewLine + "Transaction Type: " + this._txnType + strNewLine + "Payment Type: " + this._paymentType + strNewLine + "Payment Status: " + this._paymentStatus + strNewLine + "Pending Reason: " + this._pendingReason + strNewLine + "Payment Date: " + this._paymentDate + strNewLine + "Receiver Email: " + this._receiverEmail + strNewLine + "Invoice: " + this._invoice + strNewLine + "Item Number: " + this._itemNumber + strNewLine + "Item Name: " + this._itemName + strNewLine + "Quantity: " + this._quantity + strNewLine + "Custom: " + this._custom + strNewLine + "Payment Currency: " + this._currency + strNewLine + "Payment Gross: " + this._paymentGross + strNewLine + "Payment Fee: " + this._paymentFee + strNewLine + "Payer Email: " + this._payerEmail + strNewLine + "First Name: " + this._firstName + strNewLine + "Last Name: " + this._lastName + strNewLine + "Street Address: " + this._addressStreet + strNewLine + "City: " + this._addressCity + strNewLine + "State: " + this._addressState + strNewLine + "Zip Code: " + this._addressZip + strNewLine + "Country: " + this._addressCountry + strNewLine + "Address Status: " + this._addressStatus + strNewLine + "Payer Status: " + this._payerStatus + strNewLine + "Verify Sign: " + this._verifySign + strNewLine + "Subscriber Date: " + this._subscrDate + strNewLine + "Period 1: " + this._period1 + strNewLine + "Period 2: " + this._period2 + strNewLine + "Period 3: " + this._period3 + strNewLine + "Amount 1: " + this._amount1 + strNewLine + "Amount 2: " + this._amount2 + strNewLine + "Amount 3: " + this._amount3 + strNewLine + "Recurring: " + this._recurring + strNewLine + "Reattempt: " + this._reattempt + strNewLine + "Retry At: " + this._retryAt + strNewLine + "Recur Times: " + this._recurTimes + strNewLine + "UserName: "******"Password: "******"Subscriber ID: " + this._subscrID + strNewLine + "Notify Version: " + this._notifyVersion + strNewLine; var portalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"]; sEmail = this._settings.StandardEmail.Trim(); sMessage = sMessage; try { var sSystemPrice = Convert.ToDecimal(this._paymentGross); // Also verify that Gross Payment is what we logged as the Fee ("payment_gross" field ) this._objEventSignups = this._objCtlEventSignups.EventsSignupsGet(Convert.ToInt32(this._itemNumber), 0, true); this._objEvent = this._objCtlEventEvent.EventsGet(this._objEventSignups.EventID, this._objEventSignups.ModuleID); var sPPPrice = this._objEvent.EnrollFee * this._objEventSignups.NoEnrolees; var objEventEmailInfo = new EventEmailInfo(); var objEventEmail = new EventEmails(this._objEvent.PortalID, this._objEventSignups.ModuleID, this._localResourceFile); objEventEmailInfo.TxtEmailSubject = this._settings.Templates.txtEnrollMessageSubject; objEventEmailInfo.TxtEmailFrom = sEmail; if (sendToUser) { if (this._objEventSignups.UserID > -1) { objEventEmailInfo.UserIDs.Add(this._objEventSignups.UserID); } else { objEventEmailInfo.UserEmails.Add(this._objEventSignups.AnonEmail); objEventEmailInfo.UserLocales.Add(this._objEventSignups.AnonCulture); objEventEmailInfo.UserTimeZoneIds.Add(this._objEventSignups.AnonTimeZoneId); } } objEventEmailInfo.UserIDs.Add(this._objEvent.OwnerID); var objEventEmailInfo2 = new EventEmailInfo(); objEventEmailInfo2.TxtEmailFrom = sEmail; objEventEmailInfo2.UserEmails.Add(this._objEvent.PayPalAccount); objEventEmailInfo2.UserLocales.Add(""); objEventEmailInfo2.UserTimeZoneIds.Add(""); if (sPPPrice == sSystemPrice) { //we're ok objEventEmailInfo2.TxtEmailSubject = "Sale of: " + this._itemName + " from " + portalSettings.PortalName; objEventEmailInfo2.TxtEmailBody = sMessage; if (this._paymentStatus.ToUpper() == "COMPLETED") { this.SavePayPalInfo(true, this._objEvent); // Mail users if (this._settings.SendEnrollMessagePaid) { objEventEmailInfo.TxtEmailBody = this._settings.Templates.txtEnrollMessagePaid; objEventEmail.SendEmails(objEventEmailInfo, this._objEvent, this._objEventSignups, true); } } else { this.SavePayPalInfo(false, this._objEvent); // Mail users if (this._settings.SendEnrollMessagePending) { objEventEmailInfo.TxtEmailBody = this._settings.Templates.txtEnrollMessagePending; objEventEmail.SendEmails(objEventEmailInfo, this._objEvent, this._objEventSignups, true); } } } else { //someone is trying to rip us off. objEventEmailInfo2.TxtEmailSubject = "Failed Price Matchup Check: " + this._itemName + " from " + portalSettings.PortalName; objEventEmailInfo2.TxtEmailBody = "There was an incorrect match between actual price and price paid. The following transaction information is provided below:" + strNewLine + strNewLine + "The purchasing email is: " + this._payerEmail + strNewLine + "User ID: " + this._custom + strNewLine + "Transaction Type: " + this._txnType + strNewLine + "Transaction ID: " + this._txnID + strNewLine + "Item Number: " + this._itemNumber + strNewLine + "PayPal Paid: " + sSystemPrice + strNewLine + "Actual Price: " + sPPPrice + strNewLine + strNewLine + "TRANSACTION DETAILS: " + strNewLine + strNewLine + sMessage; this.SavePayPalErrorLogInfo(); // Mail users if (this._settings.SendEnrollMessageIncorrect) { objEventEmailInfo.TxtEmailBody = this._settings.Templates.txtEnrollMessageIncorrect; objEventEmail.SendEmails(objEventEmailInfo, this._objEvent, this._objEventSignups, true); } } objEventEmail.SendEmails(objEventEmailInfo2, this._objEvent, this._objEventSignups, true); } catch (Exception exc) { Exceptions.LogException( new ModuleLoadException("EventIPN, Paypal Exception: " + exc.Message + " at: " + exc.Source)); Exceptions.ProcessModuleLoadException(this, exc); var localResourceFile = this.TemplateSourceDirectory + "/" + Localization.LocalResourceDirectory + "/EventIPN.resx"; var objEventEmailInfo = new EventEmailInfo(); var objEventEmail = new EventEmails(this._objEvent.PortalID, this._objEventSignups.ModuleID, localResourceFile); objEventEmailInfo.TxtEmailSubject = "Sale of: " + this._itemName + " from " + portalSettings.PortalName; objEventEmailInfo.TxtEmailFrom = this._settings.StandardEmail.Trim(); objEventEmailInfo.UserEmails.Add(this._objEvent.PayPalAccount); objEventEmailInfo.UserLocales.Add(""); objEventEmailInfo.UserTimeZoneIds.Add(""); objEventEmailInfo.TxtEmailBody = "There was a failure of the item purchase module. The following transaction information is provided below:" + strNewLine + strNewLine + "The purchasing email is: " + this._payerEmail + strNewLine + strNewLine + "User ID: " + this._custom + strNewLine + strNewLine + "Transaction Type: " + this._txnType + strNewLine + strNewLine + "Transaction ID: " + this._txnID + strNewLine + strNewLine + "Error Code: " + exc.Message + strNewLine + exc.Source; objEventEmail.SendEmails(objEventEmailInfo, this._objEvent, this._objEventSignups, true); } }
private void Page_Load(object sender, EventArgs e) { try { double dblTotal = 0; var strCurrency = ""; if (!ReferenceEquals(Request.Params["ItemID"], null)) { _itemID = int.Parse(Request.Params["ItemID"]); } if (!ReferenceEquals(Request.Params["AnonEmail"], null)) { _anonEmail = HttpUtility.UrlDecode(Request.Params["AnonEmail"]); } if (!ReferenceEquals(Request.Params["AnonName"], null)) { _anonName = HttpUtility.UrlDecode(Request.Params["AnonName"]); } if (!ReferenceEquals(Request.Params["AnonPhone"], null)) { _anonTelephone = HttpUtility.UrlDecode(Request.Params["AnonPhone"]); if (_anonTelephone == "0") { _anonTelephone = ""; } } // Set the selected theme SetTheme(pnlEventsModulePayPal); divMessage.Attributes.Add("style", "display:none;"); if (!Page.IsPostBack) { if (_itemID != -1) { if (!ReferenceEquals(Request.Params["NoEnrol"], null)) { _noEnrol = int.Parse(Request.Params["NoEnrol"]); } var objEvent = default(EventInfo); objEvent = _objCtlEvent.EventsGet(_itemID, ModuleId); // Compute Dates/Times (for recurring) var startdate = objEvent.EventTimeBegin; SelectedDate = startdate.Date; var d = default(DateTime); d = startdate.Date.AddMinutes(objEvent.EventTimeBegin.TimeOfDay.TotalMinutes); lblStartDate.Text = d.ToLongDateString() + " " + d.ToShortTimeString(); lblEventName.Text = objEvent.EventName; lblDescription.Text = Server.HtmlDecode(objEvent.EventDesc); lblFee.Text = string.Format("{0:#0.00}", objEvent.EnrollFee); lblNoEnrolees.Text = Convert.ToString(_noEnrol); lblPurchase.Text = Localization.GetString("lblPurchase", LocalResourceFile); lblPurchase.Visible = true; } else if (!ReferenceEquals(Request.Params["signupid"], null)) { // Get EventSignup _objEventSignups = new EventSignupsInfo(); var signupID = Convert.ToInt32(Request.Params["signupid"]); _objEventSignups = _objCtlEventSignups.EventsSignupsGet(signupID, ModuleId, false); lblStartDate.Text = _objEventSignups.EventTimeBegin.ToLongDateString() + " " + _objEventSignups.EventTimeBegin.ToShortTimeString(); lblEventName.Text = _objEventSignups.EventName; // Get Related Event var objEvent = default(EventInfo); objEvent = _objCtlEvent.EventsGet(_objEventSignups.EventID, _objEventSignups.ModuleID); lblDescription.Text = Server.HtmlDecode(objEvent.EventDesc); lblFee.Text = string.Format("{0:#0.00}", objEvent.EnrollFee); lblNoEnrolees.Text = Convert.ToString(_objEventSignups.NoEnrolees); if (Request.Params["status"].ToLower() == "enrolled") { // User has been successfully enrolled for this event (paid enrollment) ShowMessage(Localization.GetString("lblComplete", LocalResourceFile), MessageLevel.DNNSuccess); lblPurchase.Visible = false; cmdPurchase.Visible = false; cancelButton.Visible = false; cmdReturn.Visible = true; } else if (Request.Params["status"].ToLower() == "cancelled") { // User has been cancelled paid enrollment ShowMessage(Localization.GetString("lblCancel", LocalResourceFile), MessageLevel.DNNWarning); lblPurchase.Visible = false; cmdPurchase.Visible = false; cancelButton.Visible = false; cmdReturn.Visible = true; // Make sure we delete the signup DeleteEnrollment(signupID, objEvent.ModuleID, objEvent.EventID); // Mail users if (Settings.SendEnrollMessageCancelled) { var objEventEmailInfo = new EventEmailInfo(); var objEventEmail = new EventEmails(PortalId, ModuleId, LocalResourceFile, ((PageBase)Page).PageCulture.Name); objEventEmailInfo.TxtEmailSubject = Settings.Templates.txtEnrollMessageSubject; objEventEmailInfo.TxtEmailBody = Settings.Templates.txtEnrollMessageCancelled; objEventEmailInfo.TxtEmailFrom = Settings.StandardEmail; if (_objEventSignups.UserID > -1) { objEventEmailInfo.UserIDs.Add(_objEventSignups.UserID); } else { objEventEmailInfo.UserEmails.Add(_objEventSignups.AnonEmail); objEventEmailInfo.UserLocales.Add(_objEventSignups.AnonCulture); objEventEmailInfo.UserTimeZoneIds.Add(_objEventSignups.AnonTimeZoneId); } objEventEmailInfo.UserIDs.Add(objEvent.OwnerID); objEventEmail.SendEmails(objEventEmailInfo, objEvent, _objEventSignups); } } } else // security violation attempt to access item not related to this Module { Response.Redirect(GetSocialNavigateUrl(), true); } } dblTotal = Conversion.Val(lblFee.Text) * Conversion.Val(lblNoEnrolees.Text); lblTotal.Text = Strings.Format(dblTotal, "#,##0.00"); strCurrency = PortalSettings.Currency; lblFeeCurrency.Text = strCurrency; lblTotalCurrency.Text = strCurrency; } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }