コード例 #1
0
        private async Task <IActionResult> InsertQiwiTelephone()
        {
            MarketBotDbContext db = new MarketBotDbContext();

            var qiwi = db.PaymentTypeConfig.Where(p => p.PaymentId == ConstantVariable.PaymentTypeVariable.QIWI && p.Login == ReplyToMessageText).FirstOrDefault();

            if (qiwi != null)
            {
                return(await SendTextMessageAndForceReply("Данный номер телефона уже добавлен", QiwiTelForcerReply));
            }

            else
            {
                PaymentTypeConfig paymentTypeConfig = new PaymentTypeConfig
                {
                    Enable    = true,
                    Login     = ReplyToMessageText,
                    TimeStamp = DateTime.Now,
                    Pass      = String.Empty,
                    PaymentId = ConstantVariable.PaymentTypeVariable.QIWI
                };

                db.PaymentTypeConfig.Add(paymentTypeConfig);
                db.SaveChanges();

                BotMessage = new AdminQiwiSettingsMessage(paymentTypeConfig);
                await SendMessage(BotMessage.BuildMsg());

                return(OkResult);
            }
        }
コード例 #2
0
        public IActionResult Bitcoin()
        {
            db = new MarketBotDbContext();


            PaymentTypeConfig = db.PaymentTypeConfig.Where(p => p.PaymentId == Bot.Core.ConstantVariable.PaymentTypeVariable.Bitcoin).OrderByDescending(p => p.Id).FirstOrDefault();

            if (PaymentTypeConfig == null)
            {
                PaymentTypeConfig = new PaymentTypeConfig
                {
                    Host      = "127.0.0.1",
                    Login     = "",
                    Pass      = "",
                    Port      = "8332",
                    Enable    = true,
                    PaymentId = Bot.Core.ConstantVariable.PaymentTypeVariable.Bitcoin
                };
            }

            ViewBag.Title = "Bitcoin Cash";
            ViewBag.Text  = "В папке с установленными Bitcoin Core создайте бат файл.Сохраните и запустите этот бат файл и дождитесь синхронизации базы данных (Размер базы данных более 180гб)." +
                            "Содержимое бат файла:";
            ViewBag.Bat = "bitcoin-qt.exe -server -rest -rpcuser=root -rpcpassword=toor -rpcport=8332";

            return(View("CryptoCurrency", PaymentTypeConfig));
        }
コード例 #3
0
        private async Task <IActionResult> InsertYandexShopId()
        {
            MarketBotDbContext db = new MarketBotDbContext();

            PaymentTypeConfig paymentTypeConfig = new PaymentTypeConfig
            {
                Enable    = true,
                Login     = ReplyToMessageText,
                TimeStamp = DateTime.Now,
                Pass      = "",
                PaymentId = ConstantVariable.PaymentTypeVariable.DebitCardForYandexKassa
            };

            db.PaymentTypeConfig.Add(paymentTypeConfig);
            db.SaveChanges();
            db.Dispose();
            return(await SendYandexKassaView());
        }
コード例 #4
0
        /// <summary>
        /// Сохранить изменения в бд
        /// </summary>
        /// <param name="config"></param>
        /// <returns></returns>
        private int SaveChanges(PaymentTypeConfig config)
        {
            if (db == null)
            {
                db = new MarketBotDbContext();
            }

            if (config != null && config.Id > 0) // Есле уже сущестуюущая запись, то редактируем ее
            {
                var OldCgf = db.PaymentTypeConfig.Where(c => c.Id == config.Id).FirstOrDefault();

                if (OldCgf != null)
                {
                    OldCgf.Login  = config.Login;
                    OldCgf.Pass   = config.Pass;
                    OldCgf.Enable = config.Enable;
                    OldCgf.Host   = config.Host;
                    OldCgf.Port   = config.Port;
                    return(EnablePaymentType(config.Enable, Convert.ToInt32(config.PaymentId)));
                }

                else
                {
                    return(0);
                }
            }

            if (config != null && config.Id == 0) // Если это новая запись то добавляем ее в бд
            {
                config.TimeStamp = DateTime.Now;
                db.PaymentTypeConfig.Add(config);
                return(EnablePaymentType(config.Enable, Convert.ToInt32(config.PaymentId)));
            }

            else
            {
                return(-1);
            }
        }
コード例 #5
0
        public async Task <IActionResult> TestConnection([FromBody] PaymentTypeConfig config)
        {
            if (config.PaymentId == Bot.Core.ConstantVariable.PaymentTypeVariable.QIWI)
            {
                if (await Services.Qiwi.QiwiFunction.TestConnection(config.Login, config.Pass))
                {
                    return(new JsonResult("Успех"));
                }

                else
                {
                    return(new JsonResult("Ошибка соединения"));
                }
            }

            if (config.PaymentId != Bot.Core.ConstantVariable.PaymentTypeVariable.QIWI && config != null)
            {
                string FirstBlockHash = String.Empty;

                Services.BitCoinCore.BitCoin ltc = new Services.BitCoinCore.BitCoin(config.Login, config.Pass, config.Host, config.Port);
                var block = ltc.GetInfo <Services.BitCoinCore.GetInfo>();

                if (block != null && block.result != null && block.result.blocks > 0)
                {
                    return(new JsonResult("Успех"));
                }

                else
                {
                    return(new JsonResult("Ошибка соединения"));
                }
            }

            else
            {
                return(new JsonResult("Ошибка соединения"));
            }
        }
コード例 #6
0
        public IActionResult AddQiwi(string telephone, string token)
        {
            db = new MarketBotDbContext();

            if (telephone != null && token != null)
            {
                PaymentTypeConfig = new PaymentTypeConfig
                {
                    Host      = "https://qiwi.com/api",
                    Login     = telephone,
                    Pass      = token,
                    Port      = "80",
                    Enable    = true,
                    PaymentId = Bot.Core.ConstantVariable.PaymentTypeVariable.QIWI
                };

                db.PaymentTypeConfig.Add(PaymentTypeConfig);

                db.SaveChanges();
            }

            return(RedirectToAction("Qiwi"));
        }
コード例 #7
0
        public IActionResult Save([FromBody] PaymentTypeConfig config)
        {
            if (config != null && config.Login == "" && config.PaymentId == Bot.Core.ConstantVariable.PaymentTypeVariable.QIWI)
            {
                return(Json("Заполните поле Номер телефона"));
            }

            if (config != null && config.Pass == "" && config.PaymentId == Bot.Core.ConstantVariable.PaymentTypeVariable.QIWI)
            {
                return(Json("Заполните поле Токен доступа"));
            }


            if (config != null && SaveChanges(config) >= 0)
            {
                return(Json("Сохранено"));
            }

            else
            {
                return(Json("Ошибка"));
            }
        }
コード例 #8
0
 public AdminQiwiSettingsMessage(PaymentTypeConfig config)
 {
     this.QiwiConfig = config;
 }
コード例 #9
0
        public TelegramDebitCardInvoice CreateInvoice()
        {
            db = new MarketBotDbContext();

            if (this.Order != null)
            {
                this.Order.OrderProduct = db.OrderProduct.Where(p => p.OrderId == Order.Id).Include(p => p.Product).Include(p => p.Price).ToList();
            }

            if (this.Order != null && this.Order.OrderAddress == null)
            {
                this.Order.OrderAddress = db.OrderAddress.Where(a => a.OrderId == Order.Id).FirstOrDefault();
            }

            if (this.Order != null && this.Order.OrderAddress == null)
            {
                this.Order.Invoice = db.Invoice.Where(a => a.Id == Order.InvoiceId).FirstOrDefault();
            }

            if (this.BotInfo.Configuration.Currency == null)
            {
                this.BotInfo.Configuration.Currency = db.Currency.Find(this.BotInfo.Configuration.CurrencyId);
            }

            this.PaymentTypeConfig = db.PaymentTypeConfig.Where(p => p.PaymentId == this.Order.Invoice.PaymentTypeId).FirstOrDefault();

            var group = this.Order.OrderProduct.GroupBy(o => o.Product).ToList();

            if (PaymentTypeConfig != null)
            {
                if (this.Order.OrderAddress == null)
                {
                    labeledPrice = new LabeledPrice[group.Count];
                }

                else
                {
                    labeledPrice = new LabeledPrice[group.Count + 1];
                    labeledPrice[labeledPrice.Length - 1]        = new LabeledPrice();
                    labeledPrice[labeledPrice.Length - 1].Amount = Convert.ToInt32(this.Order.OrderAddress.ShipPriceValue * 100);
                    labeledPrice[labeledPrice.Length - 1].Label  = "Доставка";
                }

                int counter = 0;

                foreach (var g in group)
                {
                    if (g.Key.Unit == null)
                    {
                        g.Key.Unit = db.Units.Find(g.Key.UnitId);
                    }

                    labeledPrice[counter]        = new LabeledPrice();
                    labeledPrice[counter].Amount = Convert.ToInt32(this.Order.PositionPrice(g.Key.Id) * 100);
                    labeledPrice[counter].Label  = g.Key.Name + " x " + this.Order.PositionCount(g.Key.Id).ToString() + "  " + g.Key.Unit.ShortName;
                    counter++;
                }

                this.Title         = "Заказ №" + this.Order.Number.ToString();
                this.Desc          = "Оплатите заказ с помощью банковской карты, через Telegram";
                this.PayLoad       = this.Order.Id.ToString();
                this.StartParametr = "pay";
                this.ProviderToken = PaymentTypeConfig.Pass;
                this.CurrencyCode  = this.BotInfo.Configuration.Currency.Code;

                return(this);
            }

            else
            {
                return(null);
            }
        }