Exemple #1
0
 public async Task Should_Send_Invoice_With_Reply_Markup()
 {
     await BotClient.SendInvoiceAsync(
         chatId : (int)_classFixture.PrivateChat.Id,
         title : "Product",
         description : "product description",
         payload : "test payload",
         providerToken : _classFixture.PaymentProviderToken,
         startParameter : "start_parameter",
         currency : "USD",
         prices : new[] { new LabeledPrice("price", 150), },
         replyMarkup : new InlineKeyboardMarkup(new[]
     {
         new[]
         {
             InlineKeyboardButton.WithPayment("Pay this invoice"),
             InlineKeyboardButton.WithUrl("Repository", "https://github.com/TelegramBots/Telegram.Bot")
         },
         new[]
         {
             InlineKeyboardButton.WithCallbackData("Some other button")
         }
     })
         );
 }
        public static InlineKeyboardMarkup Payment()
        {
            List <List <InlineKeyboardButton> > list = new List <List <InlineKeyboardButton> >
            {
                new List <InlineKeyboardButton>()
            };

            list[list.Count - 1].Add(InlineKeyboardButton.WithPayment("Оплатить!"));

            list[list.Count - 1].Add(new InlineKeyboardButton()
            {
                Text         = "🔙Назад",
                CallbackData = CommandName.FindAnArtistBackToMenu
            });

            return(new InlineKeyboardMarkup(list));
        }
Exemple #3
0
        public async Task Should_Send_Invoice_With_Reply_Markup()
        {
            InlineKeyboardMarkup replyMarkup = new(new[]
            {
                new[]
                {
                    InlineKeyboardButton.WithPayment("Pay this invoice"),
                    InlineKeyboardButton.WithUrl("Repository", "https://github.com/TelegramBots/Telegram.Bot")
                },
                new[]
                {
                    InlineKeyboardButton.WithCallbackData("Some other button")
                }
            });

            PaymentsBuilder paymentsBuilder = new PaymentsBuilder()
                                              .WithProduct(_ => _
                                                           .WithTitle(title: "Reproduction of \"La nascita di Venere\"")
                                                           .WithDescription(description:
                                                                            "Sandro Botticelli`s the Birth of Venus depicts the goddess Venus arriving at the shore" +
                                                                            " after her birth, when she had emerged from the sea fully-grown ")
                                                           .WithProductPrice(label: "Price of the painting", amount: 500_000)
                                                           .WithProductPrice(label: "Wooden frame", amount: 100_000)
                                                           .WithPhoto(
                                                               url: "https://cdn.pixabay.com/photo/2012/10/26/03/16/painting-63186_1280.jpg",
                                                               width: 1280,
                                                               height: 820
                                                               ))
                                              .WithCurrency("USD")
                                              .WithPayload("<my-payload>")
                                              .WithReplyMarkup(replyMarkup)
                                              .WithPaymentProviderToken(_classFixture.PaymentProviderToken)
                                              .ToChat(_classFixture.PrivateChat.Id);

            SendInvoiceRequest requestRequest = paymentsBuilder.BuildInvoiceRequest();

            await BotClient.MakeRequestAsync(requestRequest);
        }
 public static KeyboardRow <InlineKeyboardButton> AddPaymentButton(
     this KeyboardRow <InlineKeyboardButton> rowBuilder, string text)
 => rowBuilder.AddButton(InlineKeyboardButton.WithPayment(text));
Exemple #5
0
        private async Task <bool> isSendFile()
        {
            String filesLocaton = wayNow;

            if (filesLocaton.Contains(sendSymbol[0]) || filesLocaton.Contains(sendSymbol[1]))
            {
                String newFilesLocaton = filesLocaton.Remove(filesLocaton.Length - 1, 1);
                filesLocaton = newFilesLocaton.Replace("\\", " \\ ");

                setEditMessage("Заголовок", filesLocaton);
                ChoisenFile MessagesForEdit = getEditMessage("Заголовок");

                if (filesLocaton.Contains("грн)") && !adminsID.Contains(chatID))
                {
                    await Bot.EditMessageTextAsync(MessagesForEdit.Message.Chat.Id, MessagesForEdit.Message.MessageId, $"<b>{MessagesForEdit.Text}</b> <i>(Ожидание транзакции...)</i>", ParseMode.Html);

                    bool     isDonated     = Users[chatID].isDonated;
                    String   filesLocation = MessagesForEdit.Text.Replace(" \\ ", "\\").Replace(sendSymbol[0], "");
                    string[] splitLocation = filesLocation.Split('\\');
                    String[] splitPrice    = splitLocation[splitLocation.Length - 1].Split(' ');
                    int      price         = int.Parse((double.Parse(splitPrice[splitPrice.Length - 1].Replace('.', ',').Replace("(", "").Replace("грн)", "")) * 100).ToString());

                    InlineKeyboardMarkup buttons = new InlineKeyboardMarkup(new[] {
                        new[] {
                            InlineKeyboardButton.WithPayment($"Оплатить"),
                            InlineKeyboardButton.WithCallbackData("Отмена", "Отмена транзакции"),
                        }
                        //new[] {
                        //    InlineKeyboardButton.WithCallbackData("Скриншот файла","Скриншот файла"),
                        //},
                    });

                    List <LabeledPrice> prices = new List <LabeledPrice>();
                    prices.Add(new LabeledPrice($"{MessagesForEdit.Text}", price));
                    if (isDonated)
                    {
                        prices.Add(new LabeledPrice($"Скидка {Discount}%", -(price * Discount / 100)));
                    }

                    Message messForDelete = sendInvoice(
                        $"{MessagesForEdit.Text}",
                        $"Готовое задание по предмету",
                        $"{filesLocation}",
                        prices,
                        "https://lh3.googleusercontent.com/frJofbBD4ZHQQMLs_wcWZSAEckCkdakFQ2j0DbqxYuv_33xjG8zP2-RKXoO7jbyVFZUy-DLR2ekSoBiKgwFZxt1bycOaoJL6Q9XjBoexky30zTKyLht31LbVYNPa-eHmNOk_VQtsVdZabCeJcor9u-oq6Kg1OKJ8G2TQOsdnrj10d7Jvi378Ot5jYTdb_bES_ZbWcScoo3mHddBrebJlxm8vgLHjZ4VAYrKCdPbnYqTN3gxHozhlxQx8ySo_YGZKt_Bn6dzq9b0WAKTl6ahqyrzPGUC3j-4euuGfZLuUuJcFYNiwRDKxZDl5o_rxWJpQjuIhL0hy9F8zuY-cjxK9HySPmi1jpdOchjzyew0O-d-9gXYykCJV_ZH_GjnvCgnuIaxz_WuUa7Ynm2TqdbFuiaVXalPwOrjL3bteaCJLVoB8k-tiKh_15XZm1rMkBRgfu0zZ-YMXLPYNJSDwz4IJd7FmpQ9C6yIzZ6eHtkfNgOwEcjFnZW199sOPqybvvJ9ETVZ-NF7C8kZI1OaQNMA-fmgPyUpyOJICrtZC3WpTO0UhOWyBQC14ju9etfAav9aCygqFH76khQhYa3Qt7xHllO-mByzZTSPqqLc1AbQm6dwk2HnEjpWDHEQQngKuG8tgRBLmy-gg8eWDdAcezn2dl8TFd-wwl8uivo99DEH-hn_skgqi33f0ZYw-NaP3sQ=w976-h406-no?authuser=0",
                        PhotoHeight: 800,
                        PhotoWidth: 1920,
                        ReplyMarkup: buttons
                        ).Result;
                    Message order = await Bot.SendTextMessageAsync(
                        Channel,
                        $"<b>Заказ 🛒</b>\n\n" +
                        $"" +
                        $"🤖 Бот: {BotLink}\n" +
                        $"🆔 Пользователь: @{messForDelete.Chat.Username} ({getUserName(messForDelete.Chat)})\n" +
                        $"📎 Файл: <i>{filesLocation}</i>\n" +
                        $"💳 Сумма: {((double)messForDelete.Invoice.TotalAmount / 100).ToString().Replace(',', '.')} {messForDelete.Invoice.Currency}",
                        ParseMode.Html);

                    if (OrderQueue.ContainsKey(chatID))
                    {
                        await Bot.DeleteMessageAsync(Channel, OrderQueue[chatID].MessageId);
                    }

                    OrderQueue.Add(chatID, order);
                    Users[chatID].MessagesForDelete.Add(new ChoisenFile {
                        Message = messForDelete, Name = "Оплата"
                    });
                    return(true);
                }
                await Task.Run(async() => {
                    await sendFiles(wayNow, false);
                });

                return(true);
            }
            else
            {
                return(false);
            }
        }