Exemplo n.º 1
0
        private GenXmlTemplate _templateHeader; //this is used to pickup the meta data on page load.

        #endregion Fields

        #region Methods

        protected void CtrlItemCommand(object source, RepeaterCommandEventArgs e)
        {
            var cArg = e.CommandArgument.ToString();
            var param = new string[3];
            if (Utils.RequestParam(Context, "eid") != "") param[0] = "eid=" + Utils.RequestParam(Context, "eid");

            switch (e.CommandName.ToLower())
            {
                case "pay":
                    if (_cartInfo != null)
                    {

                        _cartInfo.SaveModelTransQty(); // move qty into trans
                        _cartInfo.ConvertToOrder(DebugMode);
                        var orderData = new OrderData(_cartInfo.PurchaseInfo.ItemID);

                        orderData.payselectionXml = GenXmlFunctions.GetGenXml(rpPaymentGateways, "", "");

                        orderData.PaymentProviderKey = cArg.ToLower(); // provider keys should always be lowecase
                        orderData.SavePurchaseData();
                        var redirecturl = PaymentsInterface.Instance(orderData.PaymentProviderKey).RedirectForPayment(orderData);
                        if (redirecturl != "") Response.Redirect(redirecturl, true);
                    }
                    Response.Redirect(Globals.NavigateURL(TabId, "", param), true);
                    break;
            }
        }
Exemplo n.º 2
0
        public override string RedirectForPayment(OrderData orderData)
        {
            orderData.OrderStatus = "020";
            orderData.PurchaseInfo.SetXmlProperty("genxml/paymenterror", "");
            orderData.PurchaseInfo.Lang = Utils.GetCurrentCulture();
            orderData.SavePurchaseData();
            try
            {
                HttpContext.Current.Response.Clear();
                HttpContext.Current.Response.Write(ProviderUtils.GetBankRemotePost(orderData));
            }
            catch (Exception ex)
            {
                // rollback transaction
                orderData.PurchaseInfo.SetXmlProperty("genxml/paymenterror", "<div>ERROR: Invalid payment data </div><div>" + ex + "</div>");
                orderData.PaymentFail();
                var param = new string[3];
                param[0] = "orderid=" + orderData.PurchaseInfo.ItemID.ToString("");
                param[1] = "status=0";
                return Globals.NavigateURL(StoreSettings.Current.PaymentTabId, "", param);
            }

            try
            {
                HttpContext.Current.Response.End();
            }
            catch (Exception ex)
            {
                // this try/catch to avoid sending error 'ThreadAbortException'
            }

            return "";
        }
Exemplo n.º 3
0
 public override string RedirectForPayment(OrderData orderData)
 {
     orderData.OrderStatus = "020";
     orderData.SavePurchaseData();
     var param = new string[3];
     param[0] = "orderid=" + orderData.PurchaseInfo.ItemID.ToString("D");
     param[1] = "status=1";
     return Globals.NavigateURL(StoreSettings.Current.PaymentTabId, "", param);
 }
Exemplo n.º 4
0
        private void PageLoad()
        {
            if (UserId > 0 && _cartInfo.UserId == -1) // user may have just logged in.
            {
                _cartInfo.UserId = UserId;
                _cartInfo.Save();
            }

            var orderid = Utils.RequestQueryStringParam(Context, "orderid");

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

                if (_cartInfo != null && _cartInfo.IsValidated())
                {

                    _cartInfo.SaveModelTransQty(); // move qty into trans
                    _cartInfo.ConvertToOrder(DebugMode);
                    _cartInfo.ApplyModelTransQty();

                    // Send emails
                    NBrightBuyUtils.SendEmailOrderToClient("ordercreatedclientemail.html", _cartInfo.PurchaseInfo.ItemID, "ordercreatedemailsubject");
                    NBrightBuyUtils.SendEmailToManager("ordercreatedemail.html", _cartInfo.PurchaseInfo, "ordercreatedemailsubject");

                    // update status to completed
                    _orderData = new OrderData(PortalId, _cartInfo.PurchaseInfo.ItemID);
                    _orderData.SavePurchaseData();

                    var cartL = new List<NBrightInfo>();
                    cartL.Add(_cartInfo.GetInfo());

                    // display payment OK for order
                    rpDetailDisplay.DataSource = cartL;
                    rpDetailDisplay.DataBind();
                }

                #endregion
            }
            else
            {
                #region "Payment Details"

                if (Utils.IsNumeric(orderid))
                {
                    // orderid exists, so must be return from bank; Process it!!
                    _orderData = new OrderData(PortalId, Convert.ToInt32(orderid));
                    DoDetail(rpDetailDisplay, _orderData.PurchaseInfo);
                }
                else
                {
                    // display return page
                    DoDetail(rpDetailDisplay, _cartInfo.PurchaseInfo);
                    DoDetail(rpPaymentGateways, _cartInfo.PurchaseInfo);
                    DoDetail(rpDetailFooter, _cartInfo.PurchaseInfo);
                }

                #endregion
            }
        }
Exemplo n.º 5
0
 public static void SendEmailOrderToClient(String templateName, int orderId, String emailsubjectresxkey = "", String fromEmail = "", String emailmsg = "")
 {
     var ordData = new OrderData(orderId);
     var lang = ordData.Lang;
     if (ordData.GetInfo().UserId > 0)
     {
         // this order is linked to a DNN user, so get the order email from the DNN profile (so if it's updated since the order, we pickup the new one)
         var objUser = UserController.GetUserById(ordData.PortalId, ordData.GetInfo().UserId);
         if (objUser != null)
         {
             if (ordData.EmailAddress != objUser.Email)
             {
                 ordData.EmailAddress = objUser.Email;
                 ordData.SavePurchaseData();
             }
             if (objUser.Profile.PreferredLocale != "") lang = objUser.Profile.PreferredLocale;
         }
     }
     if (lang == "") lang = Utils.GetCurrentCulture();
     // we're going to send email to all email addreses linked to the order.
     var emailList = ordData.EmailAddress;
     if (!emailList.Contains(ordData.EmailShippingAddress) && Utils.IsEmail(ordData.EmailShippingAddress)) emailList += "," + ordData.EmailShippingAddress;
     if (!emailList.Contains(ordData.EmailBillingAddress) && Utils.IsEmail(ordData.EmailBillingAddress)) emailList += "," + ordData.EmailBillingAddress;
     ordData.PurchaseInfo.SetXmlProperty("genxml/emailmsg", emailmsg);
     SendEmail(emailList, templateName, ordData.GetInfo(), emailsubjectresxkey, fromEmail, lang);
 }
Exemplo n.º 6
0
 private void DeleteInvoice(int orderid)
 {
     var orderData = new OrderData(PortalId, orderid);
     GenXmlFunctions.DeleteFile(orderData.InvoiceFileName, StoreSettings.Current.FolderUploadsMapPath,"");
     orderData.InvoiceDownloadName = "";
     orderData.InvoiceFileExt = "";
     orderData.InvoiceFileName = "";
     orderData.InvoiceFilePath = "";
     orderData.SavePurchaseData();
 }
Exemplo n.º 7
0
        public static void SendOrderEmail(string emailtype, int orderId, string emailsubjectresxkey, string fromEmail, string emailmsg, bool onlyUserManagerOnly)
        {
            var ordData = new OrderData(orderId);
            var lang = ordData.ClientLang;
            if (ordData.GetInfo().UserId > 0)
            {
                // this order is linked to a DNN user, so get the order email from the DNN profile (so if it's updated since the order, we pickup the new one)
                var objUser = UserController.GetUserById(ordData.PortalId, ordData.GetInfo().UserId);
                if (objUser != null)
                {
                    if (ordData.EmailAddress != objUser.Email)
                    {
                        ordData.EmailAddress = objUser.Email;
                        ordData.SavePurchaseData();
                    }
                    lang = ordData.ClientLang; // pickup is the client prefered local has changed.
                }
            }
            if (lang == "") lang = Utils.GetCurrentCulture();
            // we're going to send email to all email addreses linked to the order.
            var emailList = ordData.EmailAddress;
            if (!emailList.Contains(ordData.EmailShippingAddress) && Utils.IsEmail(ordData.EmailShippingAddress)) emailList += "," + ordData.EmailShippingAddress;
            if (!emailList.Contains(ordData.EmailBillingAddress) && Utils.IsEmail(ordData.EmailBillingAddress)) emailList += "," + ordData.EmailBillingAddress;

            // also send to manager is created.
            if (emailtype == "OrderCreatedClient")
            {
                emailList += "," + StoreSettings.Current.ManagerEmail;
            }

            if (!onlyUserManagerOnly || UserController.Instance.GetCurrentUserInfo().UserID > 0)
            {

                var passSettings = new Dictionary<string, string>();
                passSettings.Add("printtype", emailtype);
                passSettings.Add("emailmessage", emailmsg);
                foreach (var s in StoreSettings.Current.Settings()) // copy store setting, otherwise we get a byRef assignement
                {
                    if (passSettings.ContainsKey(s.Key))
                        passSettings[s.Key] = s.Value;
                    else
                        passSettings.Add(s.Key, s.Value);
                }

                // check for user or manager.
                var sendEmailFlag = true;
                if (onlyUserManagerOnly && UserController.Instance.GetCurrentUserInfo().UserID != ordData.UserId)
                {
                    if (!NBrightBuyUtils.CheckRights())
                    {
                        sendEmailFlag = false;
                    }
                }

                if (sendEmailFlag)
                {
                    var emailBody = "";
                    emailBody = NBrightBuyUtils.RazorTemplRender("OrderHtmlOutput.cshtml", 0, "", ordData, "/DesktopModules/NBright/NBrightBuy", StoreSettings.Current.Get("themefolder"), lang, passSettings);
                    if (StoreSettings.Current.DebugModeFileOut) Utils.SaveFile(PortalSettings.Current.HomeDirectoryMapPath + "\\testemail.html", emailBody);
                    SendEmail(emailBody, emailList, emailtype, ordData.GetInfo(), emailsubjectresxkey, fromEmail, lang);
                    ordData.AddAuditMessage(emailmsg, "email", UserController.Instance.GetCurrentUserInfo().Username, "False", NBrightBuyUtils.ResourceKey("Notification." + emailsubjectresxkey, StoreSettings.Current.EditLanguage));
                    ordData.SavePurchaseData();
                }
            }
        }