Example #1
0
        private void Page_Load(object sender, EventArgs e)
        {
            try
            {
                _localResourceFile = TemplateSourceDirectory + "/" + Localization.LocalResourceDirectory +
                                     "/EventIPN.resx";

                var sPpnMessages = ""; //  Payment message
                // assign posted variables to local variables
                _receiverEmail  = Request.Params["receiver_email"];
                _itemName       = Request.Params["item_name"];
                _itemNumber     = Request.Params["item_number"];
                _quantity       = Request.Params["quantity"];
                _invoice        = Request.Params["invoice"];
                _custom         = Request.Params["custom"];
                _paymentStatus  = Request.Params["payment_status"];
                _currency       = Request.Params["mc_currency"];
                _pendingReason  = Request.Params["pending_reason"];
                _paymentDate    = Request.Params["payment_date"];
                _paymentFee     = Request.Params["mc_fee"];
                _paymentGross   = Request.Params["mc_gross"];
                _txnID          = Request.Params["txn_id"];
                _txnType        = Request.Params["txn_type"];
                _firstName      = Request.Params["first_name"];
                _lastName       = Request.Params["last_name"];
                _addressStreet  = Request.Params["address_street"];
                _addressCity    = Request.Params["address_city"];
                _addressState   = Request.Params["address_state"];
                _addressZip     = Request.Params["address_zip"];
                _addressCountry = Request.Params["address_country"];
                _addressStatus  = Request.Params["address_status"];
                _payerEmail     = Request.Params["payer_email"];
                _payerStatus    = Request.Params["payer_status"];
                _paymentType    = Request.Params["payment_type"];
                _notifyVersion  = Request.Params["notify_version"];
                _verifySign     = Request.Params["verify_sign"];
                _subscrDate     =
                    Request.Params
                    ["subscr_date"];     //Start date or cancellation date depending on whether transaction is "subscr_signup" or "subscr_cancel"
                _period1 =
                    Request.Params
                    ["period1"];     //(optional) Trial subscription interval in days, weeks, months, years (example: a 4 day interval is "period1: 4 d")
                _period2 =
                    Request.Params
                    ["period2"];                        //(optional) Trial subscription interval in days, weeks, months, years
                _period3 =
                    Request.Params["period3"];          //Regular subscription interval in days, weeks, months, years
                _amount1   = Request.Params["amount1"]; //(optional) Amount of payment for trial period1
                _amount2   = Request.Params["amount2"]; //(optional) Amount of payment for trial period2
                _amount3   = Request.Params["amount3"]; //Amount of payment for regular period3
                _recurring =
                    Request.Params["recurring"];        //Indicates whether regular rate recurs (1 is yes, 0 is no)
                _reattempt =
                    Request.Params
                    ["reattempt"];                        //Indicates whether reattempts should occur upon payment failures (1 is yes, 0 is no)
                _retryAt    = Request.Params["retry_at"]; //Date we will retry failed subscription payment
                _recurTimes =
                    Request.Params["recur_times"];        //How many payment installments will occur at the regular rate
                _username =
                    Request.Params
                    ["username"];     //(optional) Username generated by PayPal and given to subscriber to access the subscription
                _password =
                    Request.Params
                    ["password"];                //(optional) Password generated by PayPal and given to subscriber to access the subscription (password will be hashed).
                _subscrID =
                    Request.Params["subscr_id"]; //(optional) ID generated by PayPal for the subscriber
                _strToSend = Request.Form.ToString();

                // Create the string to post back to PayPal system to validate
                _strToSend += "&cmd=_notify-validate";

                // Get the Event Signup
                _objEventSignups =
                    _objCtlEventSignups.EventsSignupsGet(Convert.ToInt32(_itemNumber), 0, true);

                // Get Module Settings
                _moduleID = _objEventSignups.ModuleID;
                _settings = EventModuleSettings.GetEventModuleSettings(_moduleID, _localResourceFile);

                //Initialize the WebRequest.
                var webURL = "";
                webURL = _settings.Paypalurl + "/cgi-bin/webscr";

                //Send PayPal Verification Response
                var myRequest = (HttpWebRequest)WebRequest.Create(webURL);
                myRequest.AllowAutoRedirect = false;
                myRequest.Method            = "POST";
                myRequest.ContentType       = "application/x-www-form-urlencoded";

                //Create post stream
                var requestStream = myRequest.GetRequestStream();
                var someBytes     = Encoding.UTF8.GetBytes(_strToSend);
                requestStream.Write(someBytes, 0, someBytes.Length);
                requestStream.Close();

                //Send request and get response
                var myResponse = (HttpWebResponse)myRequest.GetResponse();
                if (myResponse.StatusCode == HttpStatusCode.OK)
                {
                    //Obtain a 'Stream' object associated with the response object.
                    var receiveStream = myResponse.GetResponseStream();
                    var encode        = Encoding.GetEncoding("utf-8");

                    //Pipe the stream to a higher level stream reader with the required encoding format.
                    var readStream = new StreamReader(receiveStream, encode);

                    //Read result
                    var result = readStream.ReadLine();
                    if (result == "INVALID")
                    {
                        MailUsTheOrder("PPIPN: Status came back as INVALID!", false);
                    }
                    else if (result == "VERIFIED")
                    {
                        switch (_paymentStatus)
                        {
                        case "Completed"
                            : //The payment has been completed and the funds are successfully in your account balance
                            switch (_txnType)
                            {
                            case "web_accept":
                            case "cart":
                                //"web_accept": The payment was sent by your customer via the Web Accept feature.
                                //"cart": This payment was sent by your customer via the Shopping Cart feature
                                sPpnMessages =
                                    sPpnMessages +
                                    "PPIPN: This payment was sent by your customer via the Shopping Cart feature" +
                                    Environment.NewLine;
                                break;

                            case "send_money"
                                :     //This payment was sent by your customer from the PayPal website, imports the "Send Money" tab
                                sPpnMessages =
                                    sPpnMessages +
                                    "PPIPN: This payment was sent by your customer from the PayPal website" +
                                    Environment.NewLine;
                                break;

                            case "subscr_signup":         //This IPN is for a subscription sign-up
                                sPpnMessages =
                                    sPpnMessages + "PPIPN: This IPN is for a subscription sign-up" +
                                    Environment.NewLine;
                                break;

                            case "subscr_cancel":         //This IPN is for a subscription cancellation
                                sPpnMessages =
                                    sPpnMessages + "PPIPN: Subscription cancellation." + Environment.NewLine;
                                break;

                            case "subscr_failed":         //This IPN is for a subscription payment failure
                                sPpnMessages =
                                    sPpnMessages + "PPIPN: Subscription failed." + Environment.NewLine;
                                break;

                            case "subscr_payment":         //This IPN is for a subscription payment
                                sPpnMessages =
                                    sPpnMessages + "PPIPN: This IPN is for a subscription payment" +
                                    Environment.NewLine;
                                break;

                            case "subscr_eot":         //This IPN is for a subscription's end of term
                                sPpnMessages =
                                    sPpnMessages + "PPIPN:  Subscription end of term." + Environment.NewLine;
                                break;
                            }
                            switch (_addressStatus)
                            {
                            case "confirmed":         //Customer provided a Confirmed Address
                                break;

                            case "unconfirmed":         //Customer provided an Unconfirmed Address
                                break;
                            }
                            switch (_payerStatus)
                            {
                            case "verified":         //Customer has a Verified U.S. PayPal account
                                break;

                            case "unverified":         //Customer has an Unverified U.S. PayPal account
                                break;

                            case "intl_verified":         //Customer has a Verified International PayPal account
                                break;

                            case "intl_unverified":         //Customer has an Unverified International PayPal account
                                break;
                            }
                            switch (_paymentType)
                            {
                            case "echeck":         //This payment was funded with an eCheck
                                sPpnMessages =
                                    sPpnMessages + "PPIPN: Payment was funded with an eCheck." +
                                    Environment.NewLine;
                                break;

                            case "instant"
                                :     //This payment was funded with PayPal balance, credit card, or Instant Transfer
                                sPpnMessages =
                                    sPpnMessages +
                                    "PPIPN: This payment was funded with PayPal balance, credit card, or Instant Transfer" +
                                    Environment.NewLine;
                                break;
                            }
                            MailUsTheOrder(sPpnMessages, true);
                            break;

                        case "Pending"
                            : //The payment is pending - see the "pending reason" variable below for more information. Watch: You will receive another instant payment notification when the payment becomes "completed", "failed", or "denied"
                            switch (_pendingReason)
                            {
                            case "echeck"
                                :     //The payment is pending because it was made by an eCheck, which has not yet cleared
                                break;

                            case "intl"
                                :     //The payment is pending because you, the merchant, hold an international account and do not have a withdrawal mechanism. You must manually accept or deny this payment from your Account Overview
                                break;

                            case "verify"
                                :     //The payment is pending because you, the merchant, are not yet verified. You must verify your account before you can accept this payment
                                break;

                            case "address"
                                :     //The payment is pending because your customer did not include a confirmed shipping address and you, the merchant, have your Payment Receiving Preferences set such that you want to manually accept or deny each of these payments. To change your preference, go to the "Preferences" section of your "Profile"
                                break;

                            case "upgrade"
                                :     //The payment is pending because it was made via credit card and you, the merchant, must upgrade your account to Business or Premier status in order to receive the funds
                                break;

                            case "unilateral"
                                :     //The payment is pending because it was made to an email address that is not yet registered or confirmed
                                break;

                            case "other"
                                :     //The payment is pending for an "other" reason. For more information, contact customer service
                                break;
                            }
                            MailUsTheOrder("PPIPN: Order is waiting to be processed.");
                            break;

                        case "Failed"
                            : //The payment has failed. This will only happen if the payment was made from your customer's bank account
                            MailUsTheOrder(
                                "PPIPN: This only happens if the payment was made from our customer's bank account.");
                            break;

                        case "Denied"
                            : //You, the merchant, denied the payment. This will only happen if the payment was previously pending due to one of the "pending reasons"
                            MailUsTheOrder("PPIPN: We denied this payment.");
                            break;
                        }
                    }
                }
                //Close the response to free resources.
                myResponse.Close(); //If it is "OK"
            }
            catch (Exception exc)
            {
                Exceptions.LogException(
                    new ModuleLoadException("EventIPN, Paypal Exception: " + exc.Message + " at: " + exc.Source));
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Example #2
0
        public override List <SitemapUrl> GetUrls(int portalID, PortalSettings ps, string version)
        {
            var sitemapUrls = new List <SitemapUrl>();

            var objDesktopModule = default(DesktopModuleInfo);

            objDesktopModule = DesktopModuleController.GetDesktopModuleByModuleName("DNN_Events", portalID);

            var objModules          = new ModuleController();
            var objModule           = default(ModuleInfo);
            var lstModules          = objModules.GetModulesByDefinition(portalID, objDesktopModule.FriendlyName);
            var moduleIds           = new ArrayList();
            var visibleModuleIds    = new ArrayList();
            var visibleTabModuleIds = new ArrayList();

            foreach (ModuleInfo tempLoopVar_objModule in lstModules)
            {
                objModule = tempLoopVar_objModule;
                var objTabPermissions = TabPermissionController.GetTabPermissions(objModule.TabID, portalID);
                var objTabPermission  = default(TabPermissionInfo);
                foreach (TabPermissionInfo tempLoopVar_objTabPermission in objTabPermissions)
                {
                    objTabPermission = tempLoopVar_objTabPermission;
                    if (objTabPermission.PermissionKey == "VIEW" && objTabPermission.RoleName != "" &&
                        objTabPermission.AllowAccess && (objTabPermission.RoleID == -1) |
                        (objTabPermission.RoleID == -3))
                    {
                        if (objModule.InheritViewPermissions)
                        {
                            visibleTabModuleIds.Add("Tab" + objModule.TabID + "Mod" + objModule.ModuleID);
                            visibleModuleIds.Add(objModule.ModuleID);
                            break;
                        }
                        var objModulePermission = default(ModulePermissionInfo);
                        // ReSharper disable LoopCanBeConvertedToQuery
                        foreach (ModulePermissionInfo tempLoopVar_objModulePermission in objModule.ModulePermissions)
                        {
                            objModulePermission = tempLoopVar_objModulePermission;
                            // ReSharper restore LoopCanBeConvertedToQuery
                            if (objModulePermission.PermissionKey == "VIEW" && objModulePermission.RoleName != "" &&
                                objModulePermission.AllowAccess && (objModulePermission.RoleID == -1) |
                                (objModulePermission.RoleID == -3))
                            {
                                visibleTabModuleIds.Add("Tab" + objModule.TabID + "Mod" + objModule.ModuleID);
                                visibleModuleIds.Add(objModule.ModuleID);
                                break;
                            }
                        }
                    }
                }
            }
            foreach (ModuleInfo tempLoopVar_objModule in lstModules)
            {
                objModule = tempLoopVar_objModule;
                // This check for objModule = Nothing because of error in DNN 5.0.0 in GetModulesByDefinition
                if (ReferenceEquals(objModule, null))
                {
                    continue;
                }
                if (objModule.IsDeleted)
                {
                    continue;
                }
                if (moduleIds.Contains(objModule.ModuleID))
                {
                    continue;
                }
                if (!visibleTabModuleIds.Contains("Tab" + objModule.TabID + "Mod" + objModule.ModuleID))
                {
                    continue;
                }
                moduleIds.Add(objModule.ModuleID);

                var settings = EventModuleSettings.GetEventModuleSettings(objModule.ModuleID, null);
                if (!settings.EnableSitemap)
                {
                    continue;
                }
                if (settings.SocialGroupModule == EventModuleSettings.SocialModule.UserProfile)
                {
                    continue;
                }

                var iCategoryIDs = new ArrayList();
                if (settings.Enablecategories == EventModuleSettings.DisplayCategories.DoNotDisplay)
                {
                    iCategoryIDs = settings.ModuleCategoryIDs;
                }
                else
                {
                    iCategoryIDs.Add("-1");
                }
                var ilocationIDs = new ArrayList();
                if (settings.Enablelocations == EventModuleSettings.DisplayLocations.DoNotDisplay)
                {
                    ilocationIDs = settings.ModuleLocationIDs;
                }
                else
                {
                    ilocationIDs.Add("-1");
                }

                var objEventTimeZoneUtilities = new EventTimeZoneUtilities();
                var currDate =
                    objEventTimeZoneUtilities.ConvertFromUTCToModuleTimeZone(DateTime.UtcNow, settings.TimeZoneId);
                var dtStartDate = DateAndTime.DateAdd(DateInterval.Day, Convert.ToDouble(-settings.SiteMapDaysBefore),
                                                      currDate);
                var dtEndDate = DateAndTime.DateAdd(DateInterval.Day, settings.SiteMapDaysAfter, currDate);

                var objEventInfoHelper = new EventInfoHelper(objModule.ModuleID, objModule.TabID, portalID, settings);
                var lstevents          = default(ArrayList);
                lstevents = objEventInfoHelper.GetEvents(dtStartDate, dtEndDate, settings.MasterEvent, iCategoryIDs,
                                                         ilocationIDs, -1, -1);

                var objEvent = default(EventInfo);
                foreach (EventInfo tempLoopVar_objEvent in lstevents)
                {
                    objEvent = tempLoopVar_objEvent;
                    if (settings.Enforcesubcalperms && !visibleModuleIds.Contains(objEvent.ModuleID))
                    {
                        continue;
                    }
                    var pageUrl = new SitemapUrl();
                    pageUrl.Url             = objEventInfoHelper.DetailPageURL(objEvent, false);
                    pageUrl.Priority        = settings.SiteMapPriority;
                    pageUrl.LastModified    = objEvent.LastUpdatedAt;
                    pageUrl.ChangeFrequency = SitemapChangeFrequency.Daily;
                    sitemapUrls.Add(pageUrl);
                }
            }

            return(sitemapUrls);
        }
Example #3
0
        private string CleanupExpired()
        {
            var returnStr       = "Event Cleanup completed.";
            var noDeletedEvents = 0;

            Status = "Performing Event Cleanup";

            var objDesktopModule = default(DesktopModuleInfo);

            objDesktopModule = DesktopModuleController.GetDesktopModuleByModuleName("DNN_Events", 0);

            if (ReferenceEquals(objDesktopModule, null))
            {
                return("Module Definition 'DNN_Events' not found. Cleanup cannot be performed.");
            }

            Status = "Performing Event Cleanup: Dummy";
            Status = "Performing Event Cleanup:" + objDesktopModule.FriendlyName;

            var objPortals = new PortalController();
            var objPortal  = default(PortalInfo);
            var objModules = new ModuleController();
            var objModule  = default(ModuleInfo);

            var lstportals = objPortals.GetPortals();

            foreach (PortalInfo tempLoopVar_objPortal in lstportals)
            {
                objPortal = tempLoopVar_objPortal;
                Status    = "Performing Event Cleanup:" + objDesktopModule.FriendlyName + " PortalID: Dummy";
                Status    = "Performing Event Cleanup:" + objDesktopModule.FriendlyName + " PortalID:" +
                            objPortal.PortalID;

                var lstModules = objModules.GetModulesByDefinition(objPortal.PortalID, objDesktopModule.FriendlyName);
                foreach (ModuleInfo tempLoopVar_objModule in lstModules)
                {
                    objModule = tempLoopVar_objModule;
                    // This check for objModule = Nothing because of error in DNN 5.0.0 in GetModulesByDefinition
                    if (ReferenceEquals(objModule, null))
                    {
                        continue;
                    }
                    Status = "Performing Event Cleanup:" + objDesktopModule.FriendlyName + " PortalID:" +
                             objPortal.PortalID + " ModuleID: Dummy";
                    Status = "Performing Event Cleanup:" + objDesktopModule.FriendlyName + " PortalID:" +
                             objPortal.PortalID + " ModuleID:" + objModule.ModuleID;

                    var settings = EventModuleSettings.GetEventModuleSettings(objModule.ModuleID, null);
                    if (settings.Expireevents != "")
                    {
                        Status = "Performing Event Cleanup:" + objDesktopModule.FriendlyName + " PortalID:" +
                                 objPortal.PortalID + " ModuleID:" + objModule.ModuleID + " IN PROGRESS";

                        var objEventCtl = new EventController();
                        var expireDate  =
                            DateAndTime.DateAdd(DateInterval.Day, -Convert.ToInt32(settings.Expireevents),
                                                DateTime.UtcNow);
                        var startdate          = expireDate.AddYears(-10);
                        var endDate            = expireDate.AddDays(1);
                        var objEventInfoHelper = new EventInfoHelper(objModule.ModuleID, settings);
                        var categoryIDs        = new ArrayList();
                        categoryIDs.Add("-1");
                        var locationIDs = new ArrayList();
                        locationIDs.Add("-1");
                        var lstEvents =
                            objEventInfoHelper.GetEvents(startdate, endDate, false, categoryIDs, locationIDs, -1, -1);

                        var objEventTimeZoneUtilities = new EventTimeZoneUtilities();
                        foreach (EventInfo objEvent in lstEvents)
                        {
                            var eventTime =
                                objEventTimeZoneUtilities.ConvertToUTCTimeZone(
                                    objEvent.EventTimeEnd, objEvent.EventTimeZoneId);
                            if (eventTime < expireDate)
                            {
                                objEvent.Cancelled = true;
                                objEventCtl.EventsSave(objEvent, true, 0, true);
                                noDeletedEvents++;
                                returnStr = "Event Cleanup completed. " + noDeletedEvents + " Events deleted.";
                            }
                        }
                        objEventCtl.EventsCleanupExpired(objModule.PortalID, objModule.ModuleID);
                    }
                }
            }
            Status = "Cleanup complete";
            return(returnStr);
        }