public override bool HandleRequest(
            WorldPayPaymentResponse wpResponse,
            PayPalLog worldPayLog,
            Page page)
        {
            bool result = false;

            if (worldPayLog.SerializedObject.Length == 0) { return result; }

            Cart cart = (Cart)SerializationHelper.DeserializeFromString(typeof(Cart), worldPayLog.SerializedObject);

            Store store = new Store(cart.StoreGuid);
            //SiteSettings siteSettings = new SiteSettings(store.SiteGuid);
            config = SiteUtils.GetCommerceConfig();

            switch (wpResponse.TransStatus)
            {
                case "Y": //success
                    ProcessOrder(cart, store, wpResponse, worldPayLog, page);

                    result = true;
                    break;

                case "C": // cancelled
                default:
                    ProcessCancellation(cart, store, wpResponse, worldPayLog, page);
                    break;

            }

            return result;
        }
        /// <summary>
        /// Verify if the user has access to perform the callback
        /// </summary>
        /// <param name="UserName">The UserName making the call.</param>
        /// <param name="Password">The Password of the user.</param>
        /// <returns>True or false if the user is able to perform the callback.</returns>
        protected virtual bool UserHasAccess(string UserName, string Password)
        {
            CommerceConfiguration commerceConfig = SiteUtils.GetCommerceConfig();

            return(UserName == commerceConfig.GoogleMerchantID && Password == commerceConfig.GoogleMerchantKey);

            //return true;
        }
Ejemplo n.º 3
0
        private void LoadSettings()
        {
            store = StoreHelper.GetStore();
            if (store == null) { return; }

            commerceConfig = SiteUtils.GetCommerceConfig();
            currencyCulture = ResourceHelper.GetCurrencyCulture(siteSettings.GetCurrency().Code);

            if (Request.IsAuthenticated)
            {
                siteUser = SiteUtils.GetCurrentSiteUser();
            }

            if (StoreHelper.UserHasCartCookie(store.Guid))
            {
                cart = StoreHelper.GetCart();
                if (cart != null)
                {
                    cartOffers = cart.GetOffers();

                    canCheckoutWithoutAuthentication = store.CanCheckoutWithoutAuthentication(cart);

                    if ((cart.LastModified < DateTime.UtcNow.AddDays(-1)) && (cart.DiscountCodesCsv.Length > 0))
                    {
                        StoreHelper.EnsureValidDiscounts(store, cart);
                    }

                    if ((cart.UserGuid == Guid.Empty)&&(siteUser != null))
                    {
                        cart.UserGuid = siteUser.UserGuid;
                        cart.Save();
                    }
                    cart.RefreshTotals();
                }
            }

            ConfigureCheckoutButtons();

            AddClassToBody("webstore webstorecheckout");
        }
        private void LoadSettings()
        {
            PageId = WebUtils.ParseInt32FromQueryString("pageid", -1);
            ModuleId = WebUtils.ParseInt32FromQueryString("mid", -1);
            payPalGetExpressCheckoutLogGuid = WebUtils.ParseGuidFromQueryString("plog", payPalGetExpressCheckoutLogGuid);

            if (payPalGetExpressCheckoutLogGuid == Guid.Empty)
            {
                Response.Redirect(SiteUtils.GetCurrentPageUrl());
            }

            checkoutDetailsLog = new PayPalLog(payPalGetExpressCheckoutLogGuid);

            if (checkoutDetailsLog.RowGuid == Guid.Empty)
            {
                Response.Redirect(SiteUtils.GetCurrentPageUrl());
            }

            cart = (Cart)SerializationHelper.DeserializeFromString(typeof(Cart), checkoutDetailsLog.SerializedObject);

            if (cart == null)
            {
                Response.Redirect(SiteUtils.GetCurrentPageUrl());
            }
            cart.DeSerializeCartOffers();

            cart.RefreshTotals();

            if ((cart.LastModified < DateTime.UtcNow.AddDays(-1)) && (cart.DiscountCodesCsv.Length > 0))
            {
                StoreHelper.EnsureValidDiscounts(store, cart);
            }

            siteUser = SiteUtils.GetCurrentSiteUser();
            //if (siteUser == null)
            //{
            //    Response.Redirect(SiteUtils.GetCurrentPageUrl());
            //}

            if ((siteUser != null)&&(cart.UserGuid == Guid.Empty))
            {
                // user wasn't logged in when express checkout was called
                cart.UserGuid = siteUser.UserGuid;
                cart.Save();
                //if (checkoutDetailsLog.UserGuid == Guid.Empty)
                //{
                //    // we need to make sure we have the user in the log and serialized cart
                //    checkoutDetailsLog.UserGuid = siteUser.UserGuid;
                //    cart.SerializeCartOffers();
                //    checkoutDetailsLog.SerializedObject = SerializationHelper.SerializeToSoap(cart);
                //    checkoutDetailsLog.Save();

                //}
            }

            if ((siteUser != null)&&(cart.UserGuid != siteUser.UserGuid))
            {
                Response.Redirect(SiteUtils.GetCurrentPageUrl());
            }

            if (ModuleId == -1)
            {
                ModuleId = StoreHelper.FindStoreModuleId(CurrentPage);
            }

            store = StoreHelper.GetStore();

            commerceConfig = SiteUtils.GetCommerceConfig();
            currencyCulture = ResourceHelper.GetCurrencyCulture(siteSettings.GetCurrency().Code);

            if (siteUser != null)
            {
                pnlRequireLogin.Visible = false;
            }
            else
            {
                btnMakePayment.Visible = false;
            }

            AddClassToBody("webstore webstoreexpresscheckout");
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates hidden form fields for PayPal Standard Cart upload
        /// </summary>
        /// <returns></returns>
        public static string GetCartUploadFormFields(
            Guid payPalLogGuid,
            Cart cart,
            Store store,
            CommerceConfiguration commerceConfig)
        {
            //TODO: PayPal is not seeing discounts?

            PayPalStandardPaymentGateway gateway
                = new PayPalStandardPaymentGateway(
                    commerceConfig.PayPalStandardUrl,
                    commerceConfig.PayPalStandardEmailAddress,
                    commerceConfig.PayPalStandardPDTId);

            gateway.Amount = cart.OrderTotal;
            gateway.Tax = cart.TaxTotal;
            gateway.Shipping = cart.ShippingTotal;
            gateway.CartDiscount = cart.Discount;

            //Currency currency = new Currency(cart.CurrencyGuid);
            //if (currency.Guid != Guid.Empty)
            //{
            //    gateway.CurrencyCode = currency.Code;
            //}
            //gateway.CurrencyCode = store.DefaultCurrency;
            SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings();
            gateway.CurrencyCode = siteSettings.GetCurrency().Code;

            gateway.OrderHasShippableProducts = cart.HasShippingProducts();
            gateway.ShippingFirstName = cart.OrderInfo.DeliveryFirstName;
            gateway.ShippingLastName = cart.OrderInfo.DeliveryLastName;

            gateway.ShippingAddress1 = cart.OrderInfo.DeliveryAddress1;
            gateway.ShippingAddress2 = cart.OrderInfo.DeliveryAddress2;
            gateway.ShippingCity = cart.OrderInfo.DeliveryCity;
            gateway.ShippingState = cart.OrderInfo.DeliveryState;
            gateway.ShippingPostalCode = cart.OrderInfo.DeliveryPostalCode;

            //add the items
            foreach (CartOffer offer in cart.CartOffers)
            {
                PayPalOrderItem item = new PayPalOrderItem();
                item.Amount = offer.OfferPrice;
                item.ItemName = offer.Name;
                item.ItemNumber = offer.OfferGuid.ToString();
                item.Quantity = offer.Quantity;
                item.Tax = offer.Tax;

                gateway.Items.Add(item);

            }

            gateway.OrderDescription = store.Name + " " + WebStoreResources.OrderHeading;

            gateway.Custom = payPalLogGuid.ToString();

            string siteRoot = SiteUtils.GetNavigationSiteRoot();
            string storePageUrl = SiteUtils.GetCurrentPageUrl();

            gateway.ReturnUrl = siteRoot + "/Services/PayPalPDTHandler.aspx";
            gateway.NotificationUrl = siteRoot + "/Services/PayPalIPNHandler.aspx";
            gateway.CancelUrl = storePageUrl;

            return gateway.GetCartUploadFormFields();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Creates the URL for PayPal Standard BuyNow button
        /// </summary>
        /// <returns></returns>
        public static string GetBuyNowUrl(
            Guid payPalLogGuid,
            Cart cart, 
            Store store,
            CommerceConfiguration commerceConfig)
        {
            //PayPalStandardPaymentGateway gateway = new PayPalStandardPaymentGateway();
            //gateway.PayPalStandardUrl = commerceConfig.PayPalStandardUrl;
            //gateway.BusinessEmail = commerceConfig.PayPalStandardEmailAddress;
            //gateway.PDTId = commerceConfig.PayPalStandardPDTId;

            PayPalStandardPaymentGateway gateway
                = new PayPalStandardPaymentGateway(
                    commerceConfig.PayPalStandardUrl,
                    commerceConfig.PayPalStandardEmailAddress,
                    commerceConfig.PayPalStandardPDTId);

            gateway.Amount = cart.OrderTotal;
            gateway.Tax = cart.TaxTotal;
            gateway.Shipping = cart.ShippingTotal;

            //Currency currency = new Currency(cart.CurrencyGuid);
            //gateway.CurrencyCode = store.DefaultCurrency;

            SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings();
            gateway.CurrencyCode = siteSettings.GetCurrency().Code;

            gateway.OrderHasShippableProducts = cart.HasShippingProducts();

            // TODO: guess we need to split this into first and last
            gateway.ShippingFirstName =  cart.OrderInfo.DeliveryFirstName;
            gateway.ShippingLastName = cart.OrderInfo.DeliveryLastName;

            gateway.ShippingAddress1 = cart.OrderInfo.DeliveryAddress1;
            gateway.ShippingAddress2 = cart.OrderInfo.DeliveryAddress2;
            gateway.ShippingCity = cart.OrderInfo.DeliveryCity;
            gateway.ShippingState = cart.OrderInfo.DeliveryState;
            gateway.ShippingPostalCode = cart.OrderInfo.DeliveryPostalCode;

            //add the items
            //foreach (CartOffer offer in cart.CartOffers)
            //{
            //    PayPalOrderItem item = new PayPalOrderItem();
            //    item.Amount = offer.OfferPrice;
            //    item.ItemName = offer.Name;
            //    item.ItemNumber = offer.OfferGuid.ToString();
            //    item.Quantity = offer.Quantity;

            //    gateway.Items.Add(item);

            //}

            gateway.OrderDescription = store.Name + " " + WebStoreResources.OrderHeading;

            gateway.Custom = payPalLogGuid.ToString();

            string siteRoot = SiteUtils.GetNavigationSiteRoot();
            string storePageUrl = SiteUtils.GetCurrentPageUrl();

            gateway.ReturnUrl = siteRoot + "/Services/PayPalPDTHandler.aspx";
            gateway.NotificationUrl = siteRoot + "/Services/PayPalIPNHandler.aspx";
            gateway.CancelUrl = storePageUrl;

            return gateway.GetBuyNowButtonUrl();
        }
Ejemplo n.º 7
0
        private static void SendConfirmEmail(
            CultureInfo defaultCulture,
            CultureInfo currencyCulture,
            SiteSettings siteSettings,
            int pageId,
            CommerceConfiguration commerceConfig, 
            Store store, 
            Order order,
            string subjectTemplate,
            string textBodyTemplate)
        {
            if (store == null) { return; }
            if (order == null) { return; }
            if(siteSettings == null) { return; }

            if (!ShouldSendConfirmation(siteSettings.SiteId, order))
            {
                log.Info("confirmation email for order " + order.OrderGuid.ToString() + " not sent due to disabled by configuration");
                return;
            }

            //SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings();
            //CultureInfo currencyCulture = ResourceHelper.GetCurrencyCulture(siteSettings.GetCurrency().Code);

            //EmailMessageTask messageTask = new EmailMessageTask(SiteUtils.GetSmtpSettings());
            //messageTask.EmailFrom = store.SalesEmail;
            // TODO: implement from alias for store
            //messageTask.EmailFromAlias = siteSettings.DefaultFromEmailAlias;
            string email;
            if (order.CustomerEmail.Length > 0)
            {
                //messageTask.EmailTo = order.CustomerEmail;
                email = order.CustomerEmail;
            }
            else
            {
                SiteUser siteUser = new SiteUser(siteSettings, order.UserGuid);
                //messageTask.EmailTo = siteUser.Email;

                email = siteUser.Email;

            }

            //if (store.OrderBccEmail.Length > 0)
            //{
            //    messageTask.EmailBcc = store.OrderBccEmail;
            //}

            PageSettings page = new PageSettings(siteSettings.SiteId, pageId);

            string siteRoot = SiteUtils.GetNavigationSiteRoot();
            string storeLink = string.Empty;

            if (page.Url.StartsWith("~/"))
            {
                storeLink = siteRoot + page.Url.Replace("~/", "/");
            }
            else
            {
                storeLink = siteRoot;
            }

            string orderLink = siteRoot +
                "/WebStore/OrderDetail.aspx?pageid="
                + pageId.ToInvariantString()
                + "&mid=" + store.ModuleId.ToInvariantString()
                + "&orderid=" + order.OrderGuid.ToString();

            StringBuilder orderDetails = new StringBuilder();
            DataSet dsOffers = Order.GetOrderOffersAndProducts(store.Guid, order.OrderGuid);

            foreach (DataRow row in dsOffers.Tables["Offers"].Rows)
            {
                string og = row["OfferGuid"].ToString();
                orderDetails.Append(row["Name"].ToString() + " ");
                orderDetails.Append(row["Quantity"].ToString() + " @ ");
                orderDetails.Append(string.Format(currencyCulture, "{0:c}", Convert.ToDecimal(row["OfferPrice"])));
                orderDetails.Append("\r\n");

                string whereClause = string.Format("OfferGuid = '{0}'", og);
                DataView dv = new DataView(dsOffers.Tables["Products"], whereClause, "", DataViewRowState.CurrentRows);

                if (dv.Count > 1)
                {
                    foreach (DataRow r in dsOffers.Tables["Products"].Rows)
                    {
                        string pog = r["OfferGuid"].ToString();
                        if (og == pog)
                        {
                            orderDetails.Append(r["Name"].ToString() + " ");
                            orderDetails.Append(r["Quantity"].ToString() + "  \r\n");

                        }

                    }
                }

            }

            //messageTask.Subject = string.Format(
            //    defaultCulture,
            //    subjectTemplate,
            //    store.Name,
            //    order.OrderGuid.ToString()
            //    );

            //messageTask.TextBody = string.Format(
            //    defaultCulture,
            //    textBodyTemplate,
            //    order.CustomerFirstName + " " + order.CustomerLastName,
            //    store.Name,
            //    order.OrderGuid.ToString(),
            //    storeLink,
            //    orderLink,
            //    orderDetails.ToString(),
            //    order.OrderTotal.ToString("c", currencyCulture),
            //    order.ShippingTotal.ToString("c", currencyCulture),
            //    order.TaxTotal.ToString("c", currencyCulture),
            //    order.SubTotal.ToString("c", currencyCulture),
            //    order.Discount.ToString("c", currencyCulture)
            //    ).ToAscii();

            //messageTask.SiteGuid = siteSettings.SiteGuid;
            //messageTask.QueueTask();

            //WebTaskManager.StartOrResumeTasks();

            string fromAddress = store.EmailFrom;
            if (fromAddress.Length == 0) { fromAddress = siteSettings.DefaultEmailFromAddress; }

            Email.Send(
                        SiteUtils.GetSmtpSettings(),
                        fromAddress,
                        string.Empty,
                        string.Empty,
                        email,
                        string.Empty,
                        store.OrderBccEmail,
                        string.Format(defaultCulture, subjectTemplate, store.Name, order.OrderGuid.ToString()),
                        string.Format(
                                defaultCulture,
                                textBodyTemplate,
                                order.CustomerFirstName + " " + order.CustomerLastName,
                                store.Name,
                                order.OrderGuid.ToString(),
                                storeLink,
                                orderLink,
                                orderDetails.ToString(),
                                order.OrderTotal.ToString("c", currencyCulture),
                                order.ShippingTotal.ToString("c", currencyCulture),
                                order.TaxTotal.ToString("c", currencyCulture),
                                order.SubTotal.ToString("c", currencyCulture),
                                order.Discount.ToString("c", currencyCulture)
                                ),
                        false,
                        Email.PriorityNormal);
        }
Ejemplo n.º 8
0
        private void LoadSettings()
        {
            commerceConfig = SiteUtils.GetCommerceConfig();
            store = StoreHelper.GetStore();
            currencyCulture = ResourceHelper.GetCurrencyCulture(siteSettings.GetCurrency().Code);

            if((store != null)&&(offerGuid != Guid.Empty))
            {
                offer = new Offer(offerGuid);
                offerPrice = offer.Price;
            }

            teaserFileBaseUrl = WebUtils.GetSiteRoot() + "/Data/Sites/" + siteSettings.SiteId.ToInvariantString()
                + "/webstoreproductpreviewfiles/";

            AddClassToBody("webstore webstoreofferdetail");
        }
Ejemplo n.º 9
0
        private void LoadSettings()
        {
            ScriptConfig.IncludeColorBox = true;
            storeCountry = new GeoCountry(siteSettings.DefaultCountryGuid);
            currencyCulture = ResourceHelper.GetCurrencyCulture(siteSettings.GetCurrency().Code);
            commerceConfig = SiteUtils.GetCommerceConfig();

            store = StoreHelper.GetStore();
            if (store == null) { return; }

            cart = StoreHelper.GetClerkCart(store);
            tblCountryList = GeoCountry.GetList();

            if (WebUser.IsInRoles(siteSettings.RolesThatCanLookupUsers))
            {
                SetupSelectUserScript();
                //lnkUserLookup.Visible = true;
                lnkUserSearch.Visible = true;
            }

            AddClassToBody("webstore admincheckout");
        }
Ejemplo n.º 10
0
        private void LoadSettings()
        {
            store = StoreHelper.GetStore();
            if (store == null) { return; }

            canEdit = UserCanEditModule(moduleId, Store.FeatureGuid);

            timeOffset = SiteUtils.GetUserTimeOffset();
            currencyCulture = ResourceHelper.GetCurrencyCulture(siteSettings.GetCurrency().Code);
            if (Request.IsAuthenticated)
            {
                siteUser = SiteUtils.GetCurrentSiteUser();
            }

            orderGuid = WebUtils.ParseGuidFromQueryString("orderid", orderGuid);
            if (orderGuid == Guid.Empty)
            {
                orderGuid = WebUtils.ParseGuidFromQueryString("order", orderGuid);

            }

            if (orderGuid != Guid.Empty)
            {
                order = new Order(orderGuid);
                if (order.StoreGuid != store.Guid) { order = null; }

                if ((order.StatusGuid == OrderStatus.OrderStatusCancelledGuid)
                    ||(order.StatusGuid == OrderStatus.OrderStatusNoneGuid))
                { order = null; }

            }

            commerceConfig = SiteUtils.GetCommerceConfig();

            if (commerceConfig == null)
            {
                commerceConfig = new CommerceConfiguration(siteSettings);
            }

            AddClassToBody("webstore webstoreorderdetail");
        }
Ejemplo n.º 11
0
        private void LoadSettings()
        {
            store = StoreHelper.GetStore();
            if (store == null) { return; }

            commerceConfig = SiteUtils.GetCommerceConfig();
            currencyCulture = ResourceHelper.GetCurrencyCulture(siteSettings.GetCurrency().Code);
            storeCountry = new GeoCountry(siteSettings.DefaultCountryGuid);

            if (Request.IsAuthenticated)
            {
                siteUser = SiteUtils.GetCurrentSiteUser();
            }

            if (StoreHelper.UserHasCartCookie(store.Guid))
            {
                cart = StoreHelper.GetCart();

                if (cart != null)
                {
                    if ((cart.LastModified < DateTime.UtcNow.AddDays(-1)) && (cart.DiscountCodesCsv.Length > 0))
                    {
                        StoreHelper.EnsureValidDiscounts(store, cart);
                    }

                    if (siteUser != null)
                    {
                        if (cart.UserGuid == Guid.Empty)
                        {
                            // take ownership of anonymous cart
                            cart.UserGuid = siteUser.UserGuid;
                            cart.Save();
                            StoreHelper.InitializeOrderInfo(cart, siteUser);
                        }
                        else
                        {
                            // cart already has a user guid but
                            // check if it matches the current user
                            // cart cookie could have been left behind by a previous user
                            // on shared computers
                            // if cart user guid doesn't match reset billing shipping info
                            // and any other identifiers
                            // but leave items in cart
                            if (cart.UserGuid != siteUser.UserGuid)
                            {
                                cart.ResetUserInfo();
                                cart.UserGuid = siteUser.UserGuid;
                                cart.Save();
                                StoreHelper.InitializeOrderInfo(cart, siteUser);
                            }
                        }
                    }

                    if (WebStoreConfiguration.IsDemo)
                    {
                        LoadDemoCustomer();
                    }

                    canCheckoutWithoutAuthentication = store.CanCheckoutWithoutAuthentication(cart);

                    // disable till I finish
                    //canCheckoutWithoutAuthentication = false;

                }

                AddClassToBody("webstore webstoreconfirmorder");
            }

            pnlRequireLogin.Visible = !Request.IsAuthenticated;

            if ((canCheckoutWithoutAuthentication)||(Request.IsAuthenticated))
            {

                pnlOrderDetail.Visible = commerceConfig.CanProcessStandardCards || (commerceConfig.WorldPayInstallationId.Length > 0);
                pnlRequireLogin.Visible = true;
                pnlShippingTotal.Visible = false;
                pnlTaxTotal.Visible = false;
                pnlOrderTotal.Visible = false;

            }

            if ((cart != null) && (cart.SubTotal == 0) && (cart.CartOffers.Count > 0))
            {
                // free checkout
                pnlOrderDetail.Visible = true;
            }

            if (pnlOrderDetail.Visible) { tblCountryList = GeoCountry.GetList(); }

            ConfigureCheckoutButtons();

            //if (!Page.IsPostBack)
            //{
            //    if ((commerceConfig.PayPalIsEnabled) && (commerceConfig.PayPalUsePayPalStandard))
            //    {
            //        if (Request.IsAuthenticated)
            //        {
            //            SetupPayPalStandardForm();
            //        }
            //        else
            //        {
            //            // we need the user to be signed in before we send them to paypal if using PayPal Standard
            //            // because we want to return them to their order summary and that requires login
            //            // so we need to know who the user is before sending them to PayPal
            //            litOr.Visible = false;
            //            btnPayPal.Visible = false;
            //            btnGoogleCheckout.Visible = false;
            //        }
            //    }
            //}

            //if (!Request.IsAuthenticated)
            //{

            //    pnlOrderDetail.Visible = false;
            //    pnlRequireLogin.Visible = true;
            //    pnlShippingTotal.Visible = false;
            //    pnlTaxTotal.Visible = false;
            //    pnlOrderTotal.Visible = false;

            //    if (commerceConfig.GoogleCheckoutIsEnabled)
            //    {
            //        if (
            //        (!commerceConfig.Is503TaxExempt)
            //        && ((cart != null) && (cart.HasDonations()))
            //        )
            //        {
            //            //btnGoogleCheckout.Visible = false;
            //            lblGoogleMessage.Text = WebStoreResources.GoogleCheckoutDisabledForDonationsMessage;
            //            lblGoogleMessage.Visible = true;
            //            PaymentAcceptanceMark mark = (PaymentAcceptanceMark)pam1;
            //            mark.SuppressGoogleCheckout = true;

            //            mark = (PaymentAcceptanceMark)PaymentAcceptanceMark1;
            //            mark.SuppressGoogleCheckout = true;

            //            btnGoogleCheckout.Visible = true;
            //            btnGoogleCheckout.Enabled = false;
            //        }
            //    }

            //}
            //else
            //{
            //    if (
            //        (!commerceConfig.Is503TaxExempt)
            //         && ((cart != null)&& (cart.HasDonations()))
            //        && (commerceConfig.GoogleCheckoutIsEnabled)
            //        )
            //    {
            //        btnGoogleCheckout.Visible = true;
            //        btnGoogleCheckout.Enabled = false;
            //        lblGoogleMessage.Text = WebStoreResources.GoogleCheckoutDisabledForDonationsMessage;
            //        lblGoogleMessage.Visible = true;
            //    }

            //}
        }
Ejemplo n.º 12
0
        private void LoadSettings()
        {
            AddClassToBody("webstore webstorecart");

            SiteUtils.AddNoIndexMeta(Page);

            commerceConfig = SiteUtils.GetCommerceConfig();
            currencyCulture = ResourceHelper.GetCurrencyCulture(siteSettings.GetCurrency().Code);

            moduleSettings = ModuleSettings.GetModuleSettings(moduleId);
            if (moduleSettings != null)
            {
                config = new WebStoreConfiguration(moduleSettings);
            }

            litCartFooter.Text = config.CartPageFooter;

            if (Request.IsAuthenticated)
            {
                siteUser = SiteUtils.GetCurrentSiteUser();
            }

            store = StoreHelper.GetStore();
            if (store == null) { return; }

            if (
                (StoreHelper.UserHasCartCookie(store.Guid))
                || (Request.IsAuthenticated)
                )
            {
                cart = StoreHelper.GetCart();
            }

            //if we can't process cards internally there is no reason (except a free order) to go to the ConfirmOrder.aspx page
            //and the order can be processed wtithout the user signing in or if the user is already signed in
            if (
                ((!commerceConfig.CanProcessStandardCards)&&(commerceConfig.WorldPayInstallationId.Length == 0))
                && ((Request.IsAuthenticated) || (canCheckoutWithoutAuthentication))
                )
            {
                lnkCheckout.Visible = false;
            }

            if (cart == null)
            {
                pnlDiscountCode.Visible = false;
                lnkCheckout.Visible = false;
                return;
            }

            if ((cart.LastModified < DateTime.UtcNow.AddDays(-1)) && (cart.DiscountCodesCsv.Length > 0))
            {
                StoreHelper.EnsureValidDiscounts(store, cart);
            }

            if (store != null)
            {
                canCheckoutWithoutAuthentication = store.CanCheckoutWithoutAuthentication(cart);
            }

            cartList.Store = store;
            cartList.ShoppingCart = cart;
            cartList.CurrencyCulture = currencyCulture;

            cartListAlt.Store = store;
            cartListAlt.ShoppingCart = cart;
            cartListAlt.CurrencyCulture = currencyCulture;

            if (displaySettings.UseAltCartList)
            {
                cartList.Visible = false;
                cartListAlt.Visible = true;
            }

            // disable till I finish
            //canCheckoutWithoutAuthentication = false;

            ConfigureCheckoutButtons();

            int countOfDiscountCodes = Discount.GetCountOfActiveDiscountCodes(store.ModuleGuid);
            pnlDiscountCode.Visible = (countOfDiscountCodes > 0);

            // don't show the discount code panel if the cart is empty
            if (cart.SubTotal == 0)
            {
                // allow checkout if cart has items (support checkout with free items)
                if (cart.CartOffers.Count == 0)
                {
                    lnkCheckout.Visible = false;
                }
                else
                {
                    //cart has free items
                    lnkCheckout.Visible = true;
                }
                //litOr.Visible = false;
                //btnPayPal.Visible = false;
                //btnGoogleCheckout.Visible = false;
                pnlDiscountCode.Visible = false;
            }

            // kill switch to disable discount codes (doesn't prevent use of ones already in the cart but prevents new uses
            bool disableDiscounts = false;
            ConfigHelper.GetBoolProperty("WebStoreDisabledDiscounts", disableDiscounts);
            if (disableDiscounts) { pnlDiscountCode.Visible = false; }

            //if (!Page.IsPostBack)
            //{
            //    if ((commerceConfig.PayPalIsEnabled) && (commerceConfig.PayPalUsePayPalStandard))
            //    {
            //        if (Request.IsAuthenticated)
            //        {
            //            siteUser = SiteUtils.GetCurrentSiteUser();
            //            SetupPayPalStandardForm();
            //        }
            //        else
            //        {
            //            //TODO: if the cart has no download items allow checkout without registration/sign in

            //            // we need the user to be signed in before we send them to paypal if using PayPal Standard
            //            // because we want to return them to their order summary and that requires login
            //            // so we need to know who the user is before sending them to PayPal
            //            litOr.Visible = false;
            //            btnPayPal.Visible = false;
            //            btnGoogleCheckout.Visible = false;
            //        }
            //    }
            //}

            //if (!Request.IsAuthenticated)
            //{

            //    if (commerceConfig.GoogleCheckoutIsEnabled)
            //    {
            //        if (
            //        (!commerceConfig.Is503TaxExempt)
            //        && (cart != null)
            //        && (cart.HasDonations())
            //        )
            //        {
            //            lblGoogleMessage.Text = WebStoreResources.GoogleCheckoutDisabledForDonationsMessage;
            //            lblGoogleMessage.Visible = true;
            //            PaymentAcceptanceMark mark = (PaymentAcceptanceMark)pam1;
            //            mark.SuppressGoogleCheckout = true;

            //            btnGoogleCheckout.Visible = true;
            //            btnGoogleCheckout.Enabled = false;
            //        }
            //    }
            //}
            //else
            //{
            //    if (
            //        (!commerceConfig.Is503TaxExempt)
            //        && (cart != null)
            //        && (cart.HasDonations())
            //        && (commerceConfig.GoogleCheckoutIsEnabled)
            //        )
            //    {
            //        btnGoogleCheckout.Visible = true;
            //        btnGoogleCheckout.Enabled = false;
            //        lblGoogleMessage.Text = WebStoreResources.GoogleCheckoutDisabledForDonationsMessage;
            //        lblGoogleMessage.Visible = true;
            //    }

            //}
        }
Ejemplo n.º 13
0
        public static CommerceConfiguration GetCommerceConfig()
        {
            if (HttpContext.Current == null) return null;

            if (HttpContext.Current.Items["commerceConfig"] != null)
            {
                return (CommerceConfiguration)HttpContext.Current.Items["commerceConfig"];
            }

            SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings();

            if ((siteSettings == null) || (siteSettings.SiteGuid == Guid.Empty)) return null;

            CommerceConfiguration commerceConfig = new CommerceConfiguration(siteSettings);

            HttpContext.Current.Items.Add("commerceConfig", commerceConfig);

            return commerceConfig;
        }
Ejemplo n.º 14
0
        private void LoadSettings()
        {
            commerceConfig = SiteUtils.GetCommerceConfig();
            store = StoreHelper.GetStore();

            if (store == null) { return; }

            //currencyCulture = ResourceHelper.GetCurrencyCulture(store.DefaultCurrency);
            currencyCulture = ResourceHelper.GetCurrencyCulture(siteSettings.GetCurrency().Code);

            if (productGuid != Guid.Empty)
            {
                product = new Product(productGuid);
                //offerPrice = offer.Price;
            }

            Hashtable Settings = ModuleSettings.GetModuleSettings(moduleId);
            enableRatingComments = WebUtils.ParseBoolFromHashtable(
                Settings, "EnableRatingCommentsSetting", enableRatingComments);

            teaserFileBaseUrl = WebUtils.GetSiteRoot() + "/Data/Sites/" + siteSettings.SiteId.ToInvariantString()
                + "/webstoreproductpreviewfiles/";

            if (displaySettings.UsejPlayerForMediaTeasers)
            {
                ScriptConfig.IncludejPlayer = true;
                ScriptConfig.IncludejPlayerPlaylist = true;

            }
            else
            {
                ScriptConfig.IncludeYahooMediaPlayer = true;
            }

            AddClassToBody("webstore webstoreproductdetail");
        }