Ejemplo n.º 1
0
        /// <summary>
        /// Get the necessary paypal API auth header from our setting group.
        /// </summary>
        /// <param name="paypalSettingGroup"></param>
        /// <returns></returns>
        public static AuthHeader GetAuthHeaderFromSetting(SettingGroup paypalSettingGroup)
        {
            AuthHeader PayPalAuthHeader = new AuthHeader();

            PayPalAuthHeader.BaseApiURL = paypalSettingGroup.GetSettingVal(PayPalSettingKeys.PayPal_API);
            PayPalAuthHeader.Username = paypalSettingGroup.GetSettingVal(PayPalSettingKeys.PayPal_Username);
            PayPalAuthHeader.Password = paypalSettingGroup.GetSettingVal(PayPalSettingKeys.PayPal_Password);
            PayPalAuthHeader.Signature = paypalSettingGroup.GetSettingVal(PayPalSettingKeys.PayPal_Signature);

            return PayPalAuthHeader;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Process a purchased product after the stock level has been altered from the purchase order
        /// </summary>
        /// <param name="product"></param>
        /// <returns></returns>
        public static bool ProcessPurchasedProduct(SettingGroup paypalSettings, Product product)
        {
            try
            {
                string StockLevelWarningString = paypalSettings.GetSettingVal(PayPalSettingKeys.StockLevelWarning);

                int StockLevelWarning = Int32.Parse(!string.IsNullOrWhiteSpace(StockLevelWarningString) ? StockLevelWarningString : "0");

                if (product.PurchaseSettings.StockLevel <= StockLevelWarning)
                {
                    Notification NewNotification = GenerateNewNotification(product.Name, product.Id, product.PurchaseSettings.StockLevel);

                    DashboardNotificationDAO.Save(NewNotification);
                }

                if (product.CheckoutPropertySettingsList != null && product.CheckoutPropertySettingsList.Count > 0)
                {
                    foreach (var CheckPropSetting in product.CheckoutPropertySettingsList)
                    {
                        if (CheckPropSetting.PurchaseSettings.StockLevel <= StockLevelWarning)
                        {
                            Notification NewNotification = GenerateNewNotification(product.Name, product.Id, product.PurchaseSettings.StockLevel, CheckPropSetting.CheckoutPropertySettingKeys);

                            DashboardNotificationDAO.Save(NewNotification);
                        }
                    }
                }

                return true;
            }
            catch (Exception e)
            {
                CompanyCommons.Logging.WriteLog("Chimera.Core.Notifications.ProductStock.ProcessPurchasedProduct()" + e.Message);
            }

            return false;
        }