public async Task <IActionResult> Run()
        {
            try
            {
                BotInfo = Bot.GeneralFunction.GetBotInfo();

                PaymentsFunction = new PaymentsFunction();

                var InvoiceList = PaymentsFunction.FindNoPaidInvoice(); //Находим все не оплаченые чеки

                TelegramBotClient = new TelegramBotClient(BotInfo.Token);

                foreach (var invoice in InvoiceList)
                {
                    var result = await PaymentsFunction.CheckPaidInvoice(invoice);

                    if (result != null && result.Paid && result.Payment.Count > 0) // владельцу бота
                    {
                        await TelegramBotClient.SendTextMessageAsync(BotInfo.OwnerChatId, "Поступил новый платеж /payment" + result.Payment.LastOrDefault().Id.ToString());
                    }

                    if (result != null && result.Paid && result.Payment.Count > 0) // в чат
                    {
                        await TelegramBotClient.SendTextMessageAsync(BotInfo.Configuration.PrivateGroupChatId, "Поступил новый платеж /payment" + result.Payment.LastOrDefault().Id.ToString());
                    }
                }

                return(Ok());
            }

            catch
            {
                return(NotFound());
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Кнопка  я оплатил. ПРоверка платежа
        /// </summary>
        /// <returns></returns>
        private async Task <IActionResult> CheckPay()
        {
            PaymentsFunction paymentsFunction = new PaymentsFunction();
            var invoice = await paymentsFunction.CheckPaidInvoice(OrderId);

            paymentsFunction.Dispose();

            if (invoice != null && invoice.Payment.Count > 0 && invoice.Paid) // платеж найден и счет имеет статут Оплачен
            {
                BotMessage = new InvoiceViewMessage(invoice, OrderId);
                await EditMessage(BotMessage.BuildMsg());

                //уведомляем сотрудников о поступлении платежа
                PaymentViewMessage paymentViewMessage = new PaymentViewMessage(invoice.Payment.LastOrDefault().Id);
                await SendMessageAllBotEmployeess(paymentViewMessage.BuildMsg());
            }

            else
            {
                await AnswerCallback("Платеж не найден", true);
            }

            return(OkResult);
        }