Telegram Bot API
🌐 Русский

createInvoiceLink

Категория: Оплата · Bot API 10.3 · Официальная документация

Создаёт ссылку для оплаты.

Возвращает: При успехе возвращает String.

Параметры

ПараметрТипОбязательныйОписание
business_connection_idStringНетID бизнес-подключения
titleStringДаНазвание товара
descriptionStringДаОписание товара
payloadStringДаПолезная нагрузка
provider_tokenStringНетТокен платёжного провайдера
currencyStringДаВалюта
pricesArray of LabeledPriceДаJSON массив LabeledPrice
subscription_periodIntegerНетПериод подписки в секундах
max_tip_amountIntegerНетМакс. сумма чаевых
suggested_tip_amountsArray of IntegerНетJSON массив предлагаемых чаевых
provider_dataStringНетJSON данные для провайдера
photo_urlStringНетURL фото товара
photo_sizeIntegerНетРазмер фото
photo_widthIntegerНетШирина фото
photo_heightIntegerНетВысота фото
need_nameBooleanНетЗапросить имя
need_phone_numberBooleanНетЗапросить телефон
need_emailBooleanНетЗапросить email
need_shipping_addressBooleanНетЗапросить адрес доставки
send_phone_number_to_providerBooleanНетОтправить телефон провайдеру
send_email_to_providerBooleanНетОтправить email провайдеру
is_flexibleBooleanНетГибкая цена

Описания параметров даны кратко; полный текст — в официальной документации (на английском).

Пример запроса

curl

curl -s -X POST "https://api.telegram.org/bot$TOKEN/createInvoiceLink" \
  -H "Content-Type: application/json" \
  -d '{
  "title": "Example",
  "description": "Example item",
  "payload": "order-1",
  "currency": "XTR",
  "prices": [
    {
      "label": "Item",
      "amount": 100
    }
  ]
}'

Python

import requests

TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
    f"https://api.telegram.org/bot{TOKEN}/createInvoiceLink",
    json={
        "title": "Example",
        "description": "Example item",
        "payload": "order-1",
        "currency": "XTR",
        "prices": [
            {
                "label": "Item",
                "amount": 100
            }
        ]
    },
    timeout=30,
)
print(resp.json())

JavaScript

const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/createInvoiceLink`, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "title": "Example",
    "description": "Example item",
    "payload": "order-1",
    "currency": "XTR",
    "prices": [
      {
        "label": "Item",
        "amount": 100
      }
    ]
  }),
});
console.log(await res.json());

Пошаговое руководство: Как создать бота в Телеграм: от @BotFather до первого сообщения