Пример #1
0
        public static string GetPaymentButtonText()
        {
            try
            {
                var rtn = DnnUtils.GetResourceString("/DesktopModules/NBright/NBrightBuy/App_LocalResources/", "CartView.Order");

                // get payment providers, if only 1 then return payment url.
                if (StoreSettings.Current.GetBool("singlepaymentoption"))
                {
                    var pluginData = new PluginData(PortalSettings.Current.PortalId);
                    var provList   = pluginData.GetPaymentProviders();
                    if (provList.Count() == 1)
                    {
                        rtn = DnnUtils.GetResourceString("/DesktopModules/NBright/NBrightBuy/App_LocalResources/", "CartView.PaymentButton");
                    }
                }

                return(rtn);
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return("ERROR");
            }
        }
Пример #2
0
        // dynamically create provider
        private static void CreateProvider()
        {
            string providerName = null;

            _providerList = new Dictionary <string, PaymentsInterface>();

            var pluginData = new PluginData(PortalSettings.Current.PortalId);
            var l          = pluginData.GetPaymentProviders(false);

            foreach (var p in l)
            {
                var          prov   = p.Value;
                ObjectHandle handle = null;
                handle = Activator.CreateInstance(prov.GetXmlProperty("genxml/textbox/assembly"),
                                                  prov.GetXmlProperty("genxml/textbox/namespaceclass"));
                var objProvider = (PaymentsInterface)handle.Unwrap();
                var ctrlkey     = prov.GetXmlProperty("genxml/textbox/ctrl");
                if (!_providerList.ContainsKey(ctrlkey))
                {
                    objProvider.Paymentskey = ctrlkey;
                    if (!_providerList.ContainsKey(ctrlkey))
                    {
                        _providerList.Add(ctrlkey, objProvider);
                    }
                }
            }
        }
Пример #3
0
        // dynamically create provider
        private static void CreateProvider()
        {
            string providerName = null;

            _providerList = new Dictionary<string, PaymentsInterface>();

            var pluginData = new PluginData(PortalSettings.Current.PortalId);
            var l = pluginData.GetPaymentProviders();

            foreach (var p in l)
            {
                var prov = p.Value;
                ObjectHandle handle = null;
                handle = Activator.CreateInstance(prov.GetXmlProperty("genxml/textbox/assembly"),
                    prov.GetXmlProperty("genxml/textbox/namespaceclass"));
                var objProvider = (PaymentsInterface) handle.Unwrap();
                var ctrlkey = prov.GetXmlProperty("genxml/textbox/ctrl");
                if (!_providerList.ContainsKey(ctrlkey))
                {
                    objProvider.Paymentskey = ctrlkey;
                    _providerList.Add(ctrlkey, objProvider);
                }
            }
        }
Пример #4
0
        public static string GetPaymentUrl()
        {
            try
            {
                var currentcart = new CartData(PortalSettings.Current.PortalId);

                if (currentcart.GetCartItemList().Count > 0)
                {
                    currentcart.SetValidated(true);
                    if (currentcart.EditMode == "E")
                    {
                        currentcart.ConvertToOrder();
                    }
                }
                else
                {
                    currentcart.SetValidated(true);
                }
                currentcart.Save();

                var rtnurl = Globals.NavigateURL(StoreSettings.Current.PaymentTabId);
                if (currentcart.EditMode == "E")
                {
                    // is order being edited, so return to order status after edit.
                    // ONLY if the cartsummry is being displayed to the manager.
                    currentcart.ConvertToOrder();
                    // redirect to back office
                    var param = new string[2];
                    param[0] = "ctrl=orders";
                    param[1] = "eid=" + currentcart.PurchaseInfo.ItemID.ToString("");
                    var strbackofficeTabId = StoreSettings.Current.Get("backofficetabid");
                    var backofficeTabId    = PortalSettings.Current.ActiveTab.TabID;
                    if (Utils.IsNumeric(strbackofficeTabId))
                    {
                        backofficeTabId = Convert.ToInt32(strbackofficeTabId);
                    }
                    rtnurl = Globals.NavigateURL(backofficeTabId, "", param);
                }

                // get payment providers, if only 1 then return payment url.
                if (StoreSettings.Current.GetBool("singlepaymentoption"))
                {
                    var pluginData = new PluginData(PortalSettings.Current.PortalId);
                    var provList   = pluginData.GetPaymentProviders();
                    if (provList.Count() == 1)
                    {
                        foreach (var d in provList)
                        {
                            var p    = d.Value;
                            var key  = p.GetXmlProperty("genxml/textbox/ctrl");
                            var prov = PaymentsInterface.Instance(key);
                            if (prov != null)
                            {
                                rtnurl += "?provider=" + prov.Paymentskey;
                            }
                        }
                    }
                }

                return(rtnurl);
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return("ERROR");
            }
        }
Пример #5
0
        override protected void OnInit(EventArgs e)
        {
            base.OnInit(e);

            if (ModSettings.Get("themefolder") == "")  // if we don't have module setting jump out
            {
                rpPaymentGateways.ItemTemplate = new GenXmlTemplate("NO MODULE SETTINGS");
                return;
            }

            try
            {
                var pluginData = new PluginData(PortalSettings.Current.PortalId);
                _provList = pluginData.GetPaymentProviders();
                _cartInfo = new CartData(PortalId);

                var orderid     = Utils.RequestQueryStringParam(Context, "orderid");
                var templOk     = ModSettings.Get("paymentoktemplate");
                var templFail   = ModSettings.Get("paymentfailtemplate");
                var templHeader = "";
                var templFooter = "";
                var templText   = "";

                if ((_provList.Count == 0 || _cartInfo.PurchaseInfo.GetXmlPropertyDouble("genxml/appliedtotal") <= 0) && orderid == "")
                {
                    #region "No Payment providers, so process as a ordering system"

                    var displayTempl = templOk;
                    if (!_cartInfo.IsValidated())
                    {
                        displayTempl = templFail;
                    }

                    rpDetailDisplay.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(ModCtrl.GetTemplateData(ModSettings, displayTempl, Utils.GetCurrentCulture(), DebugMode), ModSettings.Settings(), PortalSettings.HomeDirectory);
                    _templateHeader = (GenXmlTemplate)rpDetailDisplay.ItemTemplate;

                    // we may have voucher discounts that give a zero appliedtotal, so process.
                    var discountprov = DiscountCodeInterface.Instance();
                    if (discountprov != null)
                    {
                        discountprov.UpdatePercentUsage(PortalId, UserId, _cartInfo.PurchaseInfo);
                        discountprov.UpdateVoucherAmount(PortalId, UserId, _cartInfo.PurchaseInfo);
                    }

                    #endregion
                }
                else
                {
                    #region "Payment Details"

                    // display the payment method by default
                    templHeader = ModSettings.Get("paymentordersummary");
                    templFooter = ModSettings.Get("paymentfooter");
                    var templPaymentText = "";
                    var msg = "";
                    if (Utils.IsNumeric(orderid))
                    {
                        // orderid exists, so must be return from bank; Process it!!
                        _orderData = new OrderData(PortalId, Convert.ToInt32(orderid));
                        _prov      = PaymentsInterface.Instance(_orderData.PaymentProviderKey);

                        msg = _prov.ProcessPaymentReturn(Context);
                        if (msg == "")                                                      // no message so successful
                        {
                            _orderData = new OrderData(PortalId, Convert.ToInt32(orderid)); // get the updated order.
                            _orderData.PaymentOk("050");
                            templText = templOk;
                        }
                        else
                        {
                            _orderData = new OrderData(PortalId, Convert.ToInt32(orderid)); // reload the order, becuase the status and typecode may have changed by the payment provider.
                            _orderData.AddAuditMessage(msg, "paymsg", "payment.ascx", "False");
                            _orderData.Save();
                            templText = templFail;
                        }
                        templFooter = ""; // return from bank, hide footer
                    }
                    else
                    {
                        // not returning from bank, so display list of payment providers.
                        rpPaymentGateways.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(GetPaymentProviderTemplates(), ModSettings.Settings(), PortalSettings.HomeDirectory);
                    }

                    if (templText == "")
                    {
                        templText = templHeader;                  // if we are NOT returning from bank, then display normal header summary template
                    }
                    templPaymentText = ModCtrl.GetTemplateData(ModSettings, templText, Utils.GetCurrentCulture(), DebugMode);

                    rpDetailDisplay.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(templPaymentText, ModSettings.Settings(), PortalSettings.HomeDirectory);
                    _templateHeader = (GenXmlTemplate)rpDetailDisplay.ItemTemplate;

                    if (templFooter != "")
                    {
                        var templPaymentFooterText = ModCtrl.GetTemplateData(ModSettings, templFooter, Utils.GetCurrentCulture(), DebugMode);
                        rpDetailFooter.ItemTemplate = NBrightBuyUtils.GetGenXmlTemplate(templPaymentFooterText, ModSettings.Settings(), PortalSettings.HomeDirectory);
                    }

                    #endregion
                }


                // insert page header text
                NBrightBuyUtils.IncludePageHeaders(ModCtrl, ModuleId, Page, _templateHeader, ModSettings.Settings(), null, DebugMode);
            }
            catch (Exception exc)
            {
                //display the error on the template (don;t want to log it here, prefer to deal with errors directly.)
                var l = new Literal();
                l.Text = exc.ToString();
                phData.Controls.Add(l);
            }
        }