Exemplo n.º 1
0
        public ActionResult EditOptions(iproby.Models.options model)
        {
            string login = Session["login"].ToString();
            var contact_id_arr = (from a in db.customers
                                  where a.login == login
                                  select a);
            int customer_id = 0;
            int confirmed_flag = 0;
            foreach (var item in contact_id_arr)
            {
                customer_id = item.customer_id;
                if (item.confirmed_flag != null) {
                confirmed_flag = item.confirmed_flag.Value;
                }
            }
            var options_arr = (from a in db.options
                                  where a.customer_id == customer_id
                                  select a);
            int flag_send_from_clients = 0;
            foreach (var item in options_arr)
            {
                flag_send_from_clients = item.send_email_from_clients_flag.Value;
            }
            iproby.Models.options options = new iproby.Models.options();
            options.customer_id = customer_id;
            options.send_email_from_clients = flag_send_from_clients;
            options.confirmed_flag = confirmed_flag;
            if (showPaymentDialog) {
                iproby.Models.payment payment = new iproby.Models.payment();
                var announ_arr = (from a in db.customer_announ
                                  where a.customer_id == customer_id
                                  select a);
                int announ_id = 0;
                foreach (var item in announ_arr)
                {
                    announ_id = item.announ_id.Value;
                }
                iproby.Data_Model.payment payment_db = new iproby.Data_Model.payment();
                payment_db.customer_id = customer_id;
                payment_db.announ_id = announ_id;
                payment_db.description = payment.desc;
                payment_db.invid = payment.invid;
                payment_db.mrchlogin = payment.mrchlogin;
                payment_db.outsum = payment.outsum.ToString();
                payment_db.date_from = DateTime.Now;
                payment_db.status = "try";

                db.payments.Add(payment_db);
                db.SaveChanges();
                payment.invid = payment_db.id;
                var payments = db.payments.Find(payment_db.id);
                if (payments != null)
                {
                    payments.invid = payment_db.id;
                    payment.invid = payment_db.id;
                    string sCrcBase = string.Format("{0}:{1}:{2}:{3}",
                                          payment.mrchlogin, payment.outsum, payment.invid, payment.password1);
                    MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
                    byte[] bSignature = md5.ComputeHash(Encoding.ASCII.GetBytes(sCrcBase));
                    StringBuilder sbSignature = new StringBuilder();
                    foreach (byte b in bSignature)
                        sbSignature.AppendFormat("{0:x2}", b);
                    string sMyCrc = sbSignature.ToString();
                    payment.signaturevalue = sMyCrc;
                    payment_db.signaturevalue = sMyCrc;
                    db.SaveChanges();
                }
                ViewData["showPaymentDialog"] = "showPaymentDialog";
                showPaymentDialog = false;
                options.payment = payment;
            }

            return View(options);
        }
Exemplo n.º 2
0
        public ActionResult ResultPayment(iproby.Data_Model.payment model)
        {
            var invid_arr = (from a in db.payments
                             where a.invid == model.invid
                             select a);
            int customer_id = 0;

            foreach (var item in invid_arr)
            {
                customer_id = item.customer_id;
            }
            var announ_arr = (from a in db.customer_announ
                              where a.customer_id == customer_id
                              select a);
            int announ_id = 0;

            foreach (var item in announ_arr)
            {
                announ_id = item.announ_id.Value;
            }
            var contact_arr = (from a in db.customers
                               where a.customer_id == customer_id
                               join db_target1 in db.contacts on a.contact_id equals db_target1.contact_id
                               select db_target1);
            string email = string.Empty;

            foreach (var item in contact_arr)
            {
                email = item.email;
            }
            iproby.Models.payment paym = new iproby.Models.payment();
            // HTTP parameters
            string sOutSum  = GetPrm("OutSum");
            string sInvId   = GetPrm("InvId");
            string sCrc     = GetPrm("SignatureValue");
            string sCrcBase = string.Format("{0}:{1}:{2}",
                                            sOutSum, sInvId, paym.password2);
            MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();

            byte[]        bSignature  = md5.ComputeHash(Encoding.ASCII.GetBytes(sCrcBase));
            StringBuilder sbSignature = new StringBuilder();

            foreach (byte b in bSignature)
            {
                sbSignature.AppendFormat("{0:x2}", b);
            }
            string sMyCrc = sbSignature.ToString();
            string status = "success";

            if (sCrc.ToUpper() != sMyCrc.ToUpper())
            {
                status = "signatureincorrect-" + sCrc.ToUpper() + "-" + sMyCrc.ToUpper() + "-" + sOutSum + "-" + sInvId + "-";
            }
            model.announ_id      = announ_id;
            model.customer_id    = customer_id;
            model.status         = status;
            model.outsum         = sOutSum.ToString();
            model.signaturevalue = sCrc;
            model.mrchlogin      = paym.mrchlogin;
            DateTime date_from = DateTime.Now;

            model.date_from = date_from;
            if (string.IsNullOrEmpty(model.state))
            {
                model.state = GetPrm("State");
            }
            if (string.IsNullOrEmpty(model.Code))
            {
                model.Code = GetPrm("Code");
            }
            if (string.IsNullOrEmpty(model.Info))
            {
                model.Info = GetPrm("Info");
            }
            if (string.IsNullOrEmpty(model.IncCurrLabel))
            {
                model.IncCurrLabel = GetPrm("IncCurrLabel");
            }
            if (string.IsNullOrEmpty(model.PaymentMethod))
            {
                model.PaymentMethod = GetPrm("PaymentMethod");
            }
            if (string.IsNullOrEmpty(model.description))
            {
                model.description = GetPrm("Description");
            }
            if (string.IsNullOrEmpty(model.description))
            {
                model.description = paym.desc;
            }
            if (string.IsNullOrEmpty(model.OutCurrLabel))
            {
                model.OutCurrLabel = GetPrm("OutCurrLabel");
            }

            db.payments.Add(model);
            db.SaveChanges();
            iproby.Models.payment paymentModel = new iproby.Models.payment();
            paymentModel.status_text = "OK" + model.invid + "\n";
            InformationController info = new InformationController();
            string text_email          = @"Благодарим за платеж!

                Данные платежа:
                id Объявления: " + announ_id + @"
                id Пользователя: " + customer_id + @"
                id Транзакции: " + model.invid + @"
                Сумма платежа: " + sOutSum + @"
                Время платежа: " + date_from.ToString() + @"
                Статус: " + status + @"


                Это сообщение сгенерировано автоматически. По всем вопросам пишите на [email protected]";

            info.SendMail(email, text_email);
            return(View("~/Views/Cabinet/OKPayment.cshtml", paymentModel));
        }
Exemplo n.º 3
0
        public ActionResult SuccessPayment(iproby.Data_Model.payment model)
        {
            var invid_arr = (from a in db.payments
                             where a.invid == model.invid
                             select a);
            int customer_id = 0;

            foreach (var item in invid_arr)
            {
                customer_id = item.customer_id;
            }
            var announ_arr = (from a in db.customer_announ
                              where a.customer_id == customer_id
                              select a);
            int announ_id = 0;

            foreach (var item in announ_arr)
            {
                announ_id = item.announ_id.Value;
            }
            iproby.Models.payment paym = new iproby.Models.payment();
            // HTTP parameters
            string sOutSum = GetPrm("OutSum");
            string sInvId  = GetPrm("InvId");
            string sCrc    = GetPrm("SignatureValue");

            string sCrcBase = string.Format("{0}:{1}:{2}",
                                            sOutSum, sInvId, paym.password1);
            MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();

            byte[]        bSignature  = md5.ComputeHash(Encoding.ASCII.GetBytes(sCrcBase));
            StringBuilder sbSignature = new StringBuilder();

            foreach (byte b in bSignature)
            {
                sbSignature.AppendFormat("{0:x2}", b);
            }
            string sMyCrc = sbSignature.ToString();
            string status = "success";

            if (sMyCrc.ToUpper() != sCrc.ToUpper())
            {
                status = "2signatureincorrect-" + sCrc.ToUpper() + "-" + sMyCrc.ToUpper() + "-" + sOutSum + "-" + sInvId + "-";
            }

            iproby.Data_Model.payment payment = new iproby.Data_Model.payment();
            payment.announ_id      = announ_id;
            payment.customer_id    = customer_id;
            payment.invid          = model.invid;
            payment.mrchlogin      = paym.mrchlogin;
            payment.outsum         = sOutSum.ToString();
            payment.signaturevalue = sCrc;
            payment.status         = status;
            DateTime date_from = DateTime.Now;

            payment.date_from = date_from;

            if (string.IsNullOrEmpty(model.state))
            {
                payment.state = GetPrm("State");
            }
            else
            {
                payment.state = model.state;
            }
            if (string.IsNullOrEmpty(model.Code))
            {
                payment.Code = GetPrm("Code");
            }
            else
            {
                payment.Code = model.Code;
            }
            if (string.IsNullOrEmpty(model.Info))
            {
                payment.Info = GetPrm("Info");
            }
            else
            {
                payment.Info = model.Info;
            }
            if (string.IsNullOrEmpty(model.IncCurrLabel))
            {
                payment.IncCurrLabel = GetPrm("IncCurrLabel");
            }
            else
            {
                payment.IncCurrLabel = model.IncCurrLabel;
            }
            if (string.IsNullOrEmpty(model.PaymentMethod))
            {
                payment.PaymentMethod = GetPrm("PaymentMethod");
            }
            else
            {
                payment.PaymentMethod = model.PaymentMethod;
            }
            if (string.IsNullOrEmpty(model.description))
            {
                payment.description = GetPrm("Description");
            }
            else
            {
                payment.description = model.description;
            }
            if (string.IsNullOrEmpty(model.description))
            {
                payment.description = paym.desc;
            }
            if (string.IsNullOrEmpty(model.OutCurrLabel))
            {
                payment.OutCurrLabel = GetPrm("OutCurrLabel");
            }
            else
            {
                payment.OutCurrLabel = model.OutCurrLabel;
            }

            db.payments.Add(payment);
            db.SaveChanges();
            return(RedirectToAction("EditOptions", "Cabinet"));
        }
Exemplo n.º 4
0
        public ActionResult EditOptions(iproby.Models.options model)
        {
            string login          = Session["login"].ToString();
            var    contact_id_arr = (from a in db.customers
                                     where a.login == login
                                     select a);
            int customer_id    = 0;
            int confirmed_flag = 0;

            foreach (var item in contact_id_arr)
            {
                customer_id = item.customer_id;
                if (item.confirmed_flag != null)
                {
                    confirmed_flag = item.confirmed_flag.Value;
                }
            }
            var options_arr = (from a in db.options
                               where a.customer_id == customer_id
                               select a);
            int flag_send_from_clients = 0;

            foreach (var item in options_arr)
            {
                flag_send_from_clients = item.send_email_from_clients_flag.Value;
            }
            iproby.Models.options options = new iproby.Models.options();
            options.customer_id             = customer_id;
            options.send_email_from_clients = flag_send_from_clients;
            options.confirmed_flag          = confirmed_flag;
            if (showPaymentDialog)
            {
                iproby.Models.payment payment = new iproby.Models.payment();
                var announ_arr = (from a in db.customer_announ
                                  where a.customer_id == customer_id
                                  select a);
                int announ_id = 0;
                foreach (var item in announ_arr)
                {
                    announ_id = item.announ_id.Value;
                }
                iproby.Data_Model.payment payment_db = new iproby.Data_Model.payment();
                payment_db.customer_id = customer_id;
                payment_db.announ_id   = announ_id;
                payment_db.description = payment.desc;
                payment_db.invid       = payment.invid;
                payment_db.mrchlogin   = payment.mrchlogin;
                payment_db.outsum      = payment.outsum.ToString();
                payment_db.date_from   = DateTime.Now;
                payment_db.status      = "try";

                db.payments.Add(payment_db);
                db.SaveChanges();
                payment.invid = payment_db.id;
                var payments = db.payments.Find(payment_db.id);
                if (payments != null)
                {
                    payments.invid = payment_db.id;
                    payment.invid  = payment_db.id;
                    string sCrcBase = string.Format("{0}:{1}:{2}:{3}",
                                                    payment.mrchlogin, payment.outsum, payment.invid, payment.password1);
                    MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
                    byte[]        bSignature     = md5.ComputeHash(Encoding.ASCII.GetBytes(sCrcBase));
                    StringBuilder sbSignature    = new StringBuilder();
                    foreach (byte b in bSignature)
                    {
                        sbSignature.AppendFormat("{0:x2}", b);
                    }
                    string sMyCrc = sbSignature.ToString();
                    payment.signaturevalue    = sMyCrc;
                    payment_db.signaturevalue = sMyCrc;
                    db.SaveChanges();
                }
                ViewData["showPaymentDialog"] = "showPaymentDialog";
                showPaymentDialog             = false;
                options.payment = payment;
            }

            return(View(options));
        }
Exemplo n.º 5
0
        public ActionResult ResultPayment(iproby.Data_Model.payment model)
        {
            var invid_arr = (from a in db.payments
                                      where a.invid == model.invid
                                      select a);
                int customer_id = 0;
                foreach (var item in invid_arr)
                {
                    customer_id = item.customer_id;
                }
                var announ_arr = (from a in db.customer_announ
                                  where a.customer_id == customer_id
                                  select a);
                int announ_id = 0;
                foreach (var item in announ_arr)
                {
                    announ_id = item.announ_id.Value;
                }
                var contact_arr = (from a in db.customers
                                  where a.customer_id == customer_id
                                   join db_target1 in db.contacts on a.contact_id equals db_target1.contact_id
                                   select db_target1);
                string email = string.Empty;
                foreach (var item in contact_arr)
                {
                    email = item.email;
                }
                iproby.Models.payment paym = new iproby.Models.payment();
                // HTTP parameters
                string sOutSum = GetPrm("OutSum");
                string sInvId = GetPrm("InvId");
                string sCrc = GetPrm("SignatureValue");
                string sCrcBase = string.Format("{0}:{1}:{2}",
                                                 sOutSum, sInvId, paym.password2);
                MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
                byte[] bSignature = md5.ComputeHash(Encoding.ASCII.GetBytes(sCrcBase));
                StringBuilder sbSignature = new StringBuilder();
                foreach (byte b in bSignature)
                    sbSignature.AppendFormat("{0:x2}", b);
                string sMyCrc = sbSignature.ToString();
                string status = "success";
                if (sCrc.ToUpper() != sMyCrc.ToUpper())
                {
                    status = "signatureincorrect-" + sCrc.ToUpper() + "-" + sMyCrc.ToUpper() + "-" + sOutSum + "-" + sInvId + "-";
                }
                model.announ_id = announ_id;
                model.customer_id = customer_id;
                model.status = status;
                model.outsum = sOutSum.ToString();
                model.signaturevalue = sCrc;
                model.mrchlogin = paym.mrchlogin;
                DateTime date_from = DateTime.Now;
                model.date_from = date_from;
                if (string.IsNullOrEmpty(model.state))
                    model.state = GetPrm("State");
                if (string.IsNullOrEmpty(model.Code))
                    model.Code = GetPrm("Code");
                if (string.IsNullOrEmpty(model.Info))
                    model.Info = GetPrm("Info");
                if (string.IsNullOrEmpty(model.IncCurrLabel))
                    model.IncCurrLabel = GetPrm("IncCurrLabel");
                if (string.IsNullOrEmpty(model.PaymentMethod))
                    model.PaymentMethod = GetPrm("PaymentMethod");
                if (string.IsNullOrEmpty(model.description))
                    model.description = GetPrm("Description");
                if (string.IsNullOrEmpty(model.description))
                    model.description = paym.desc;
                if (string.IsNullOrEmpty(model.OutCurrLabel))
                    model.OutCurrLabel = GetPrm("OutCurrLabel");

                db.payments.Add(model);
                db.SaveChanges();
                iproby.Models.payment paymentModel = new iproby.Models.payment();
                paymentModel.status_text = "OK" + model.invid + "\n";
                InformationController info = new InformationController();
                string text_email=@"Благодарим за платеж!

                Данные платежа:
                id Объявления: "+announ_id+@"
                id Пользователя: "+customer_id+@"
                id Транзакции: "+model.invid+@"
                Сумма платежа: " + sOutSum + @"
                Время платежа: " +date_from.ToString()+@"
                Статус: "+status+@"

                Это сообщение сгенерировано автоматически. По всем вопросам пишите на [email protected]";
                info.SendMail(email, text_email);
                return View("~/Views/Cabinet/OKPayment.cshtml", paymentModel);
        }
Exemplo n.º 6
0
        public ActionResult SuccessPayment(iproby.Data_Model.payment model)
        {
            var invid_arr = (from a in db.payments
                                 where a.invid == model.invid
                                 select a);
                int customer_id = 0;
                foreach (var item in invid_arr)
                {
                    customer_id = item.customer_id;
                }
                var announ_arr = (from a in db.customer_announ
                                      where a.customer_id == customer_id
                                      select a);
                int announ_id = 0;
                foreach (var item in announ_arr)
                {
                    announ_id = item.announ_id.Value;
                }
                iproby.Models.payment paym = new iproby.Models.payment();
                // HTTP parameters
                string sOutSum = GetPrm("OutSum");
                string sInvId = GetPrm("InvId");
                string sCrc = GetPrm("SignatureValue");

                string sCrcBase = string.Format("{0}:{1}:{2}",
                                                 sOutSum, sInvId, paym.password1);
                MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
                byte[] bSignature = md5.ComputeHash(Encoding.ASCII.GetBytes(sCrcBase));
                StringBuilder sbSignature = new StringBuilder();
                foreach (byte b in bSignature)
                    sbSignature.AppendFormat("{0:x2}", b);
                string sMyCrc = sbSignature.ToString();
                string status = "success";
                if (sMyCrc.ToUpper() != sCrc.ToUpper())
                {
                    status = "2signatureincorrect-" + sCrc.ToUpper() + "-" + sMyCrc.ToUpper() + "-" + sOutSum + "-" + sInvId + "-";
                }

            iproby.Data_Model.payment payment = new iproby.Data_Model.payment();
            payment.announ_id = announ_id;
            payment.customer_id = customer_id;
            payment.invid = model.invid;
            payment.mrchlogin = paym.mrchlogin;
            payment.outsum = sOutSum.ToString();
            payment.signaturevalue = sCrc;
            payment.status = status;
            DateTime date_from = DateTime.Now;
            payment.date_from = date_from;

            if (string.IsNullOrEmpty(model.state))
                payment.state = GetPrm("State");
            else payment.state = model.state;
            if (string.IsNullOrEmpty(model.Code))
                payment.Code = GetPrm("Code");
            else payment.Code = model.Code;
            if (string.IsNullOrEmpty(model.Info))
                payment.Info = GetPrm("Info");
            else payment.Info = model.Info;
            if (string.IsNullOrEmpty(model.IncCurrLabel))
                payment.IncCurrLabel = GetPrm("IncCurrLabel");
            else payment.IncCurrLabel = model.IncCurrLabel;
            if (string.IsNullOrEmpty(model.PaymentMethod))
                payment.PaymentMethod = GetPrm("PaymentMethod");
            else payment.PaymentMethod = model.PaymentMethod;
            if (string.IsNullOrEmpty(model.description))
                payment.description = GetPrm("Description");
            else payment.description = model.description;
            if (string.IsNullOrEmpty(model.description))
                payment.description = paym.desc;
            if (string.IsNullOrEmpty(model.OutCurrLabel))
                payment.OutCurrLabel = GetPrm("OutCurrLabel");
            else payment.OutCurrLabel = model.OutCurrLabel;

            db.payments.Add(payment);
            db.SaveChanges();
            return RedirectToAction("EditOptions", "Cabinet");
        }