protected void Page_Load(object sender, EventArgs e)
    {
        bool offerGlobalPaymentMethods = false;

        mShippingOptionId = QueryHelper.GetInteger("objectid", 0);
        if (mShippingOptionId > 0)
        {
            mShippingOptionInfoObj = ShippingOptionInfoProvider.GetShippingOptionInfo(mShippingOptionId);
            EditedObject           = mShippingOptionInfoObj;

            if (mShippingOptionInfoObj != null)
            {
                int editedSiteId = mShippingOptionInfoObj.ShippingOptionSiteID;
                // Check object's site id
                CheckEditedObjectSiteID(editedSiteId);

                // Offer global payment methods when allowed
                offerGlobalPaymentMethods = ECommerceSettings.AllowGlobalPaymentMethods(editedSiteId);

                DataSet ds = PaymentOptionInfoProvider.GetPaymentOptionsForShipping(mShippingOptionId).OrderBy("PaymentOptionDisplayName");
                if (!DataHelper.DataSourceIsEmpty(ds))
                {
                    mCurrentValues = TextHelper.Join(";", DataHelper.GetStringValues(ds.Tables[0], "PaymentOptionID"));
                }

                if (!RequestHelper.IsPostBack())
                {
                    uniSelector.Value = mCurrentValues;
                }
            }
        }

        uniSelector.OnSelectionChanged += uniSelector_OnSelectionChanged;
        uniSelector.WhereCondition      = GetSelectorWhereCondition(offerGlobalPaymentMethods);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check permissions for CMS Desk -> Ecommerce
        if (!CMSContext.CurrentUser.IsAuthorizedPerUIElement("CMS.Ecommerce", "Configuration.ShippingOptions.PaymentMethods"))
        {
            RedirectToCMSDeskUIElementAccessDenied("CMS.Ecommerce", "Configuration.ShippingOptions.PaymentMethods");
        }

        bool offerGlobalPaymentMethods = false;

        lblAvialable.Text = GetString("com.shippingoption.payments");
        mShippingOptionId = QueryHelper.GetInteger("shippingoptionid", 0);
        if (mShippingOptionId > 0)
        {
            mShippingOptionInfoObj = ShippingOptionInfoProvider.GetShippingOptionInfo(mShippingOptionId);
            EditedObject           = mShippingOptionInfoObj;

            if (mShippingOptionInfoObj != null)
            {
                int editedSiteId = mShippingOptionInfoObj.ShippingOptionSiteID;
                // Check object's site id
                CheckEditedObjectSiteID(editedSiteId);

                // Offer global payment methods when allowed or configuring global shipping option
                if (editedSiteId != 0)
                {
                    SiteInfo si = SiteInfoProvider.GetSiteInfo(editedSiteId);
                    if (si != null)
                    {
                        offerGlobalPaymentMethods = ECommerceSettings.AllowGlobalPaymentMethods(si.SiteName);
                    }
                }
                // Configuring global shipping option
                else
                {
                    offerGlobalPaymentMethods = true;
                }

                DataSet ds = PaymentOptionInfoProvider.GetPaymentOptionsForShipping(mShippingOptionId, false);
                if (!DataHelper.DataSourceIsEmpty(ds))
                {
                    mCurrentValues = TextHelper.Join(";", SqlHelperClass.GetStringValues(ds.Tables[0], "PaymentOptionID"));
                }

                if (!RequestHelper.IsPostBack())
                {
                    uniSelector.Value = mCurrentValues;
                }
            }
        }

        uniSelector.IconPath            = GetObjectIconUrl("ecommerce.paymentoption", "object.png");
        uniSelector.OnSelectionChanged += uniSelector_OnSelectionChanged;
        uniSelector.WhereCondition      = GetSelectorWhereCondition(offerGlobalPaymentMethods);
    }
        /// <summary>
        /// Returns a payment method with the specified identifier.
        /// </summary>
        /// <param name="paymentMethodId">Payment method's identifier.</param>
        /// <returns><see cref="PaymentOptionInfo"/> object representing a payment method with the specified identifier. Returns <c>null</c> if not found.</returns>
        public PaymentOptionInfo GetById(int paymentMethodId)
        {
            var paymentInfo = PaymentOptionInfoProvider.GetPaymentOptionInfo(paymentMethodId);

            if (paymentInfo?.PaymentOptionSiteID == SiteID)
            {
                return(paymentInfo);
            }

            if (paymentInfo?.PaymentOptionSiteID == 0 && ECommerceSettings.AllowGlobalPaymentMethods(SiteID))
            {
                return(paymentInfo);
            }

            return(null);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Returns a payment method with the specified identifier.
        /// </summary>
        /// <param name="paymentMethodId">Payment method's identifier.</param>
        /// <returns><see cref="PaymentOptionInfo"/> object representing a payment method with the specified identifier. Returns <c>null</c> if not found.</returns>
        public PaymentOptionInfo GetById(int paymentMethodId)
        {
            return(repositoryCacheHelper.CacheObject(() =>
            {
                var paymentInfo = paymentOptionInfoProvider.Get(paymentMethodId);

                if (paymentInfo?.PaymentOptionSiteID == SiteContext.CurrentSiteID)
                {
                    return paymentInfo;
                }

                if (paymentInfo?.PaymentOptionSiteID == 0 && ECommerceSettings.AllowGlobalPaymentMethods(SiteContext.CurrentSiteID))
                {
                    return paymentInfo;
                }

                return null;
            }, $"{nameof(PaymentMethodRepository)}|{nameof(GetById)}|{paymentMethodId}"));
        }