Telegram Bot API
🌐 Tiếng Việt

sendInvoice

Danh mục: Thanh toán · Bot API 10.3 · Tài liệu chính thức

Gửi hóa đơn thanh toán.

Giá trị trả về: Nếu thành công, trả về Message.

Tham số

Tham sốKiểuBắt buộcMô tả
chat_idInteger or StringCóID chat hoặc @username
message_thread_idIntegerTùy chọnID chủ đề diễn đàn
direct_messages_topic_idIntegerTùy chọnID chủ đề tin nhắn trực tiếp (Bot API 10.0)
titleStringCóTên sản phẩm (1-32)
descriptionStringCóMô tả sản phẩm (1-255)
payloadStringCóPayload của hóa đơn
provider_tokenStringTùy chọnToken nhà cung cấp thanh toán
currencyStringCóTiền tệ (XTR cho Stars)
pricesArray of LabeledPriceCóMảng JSON LabeledPrice
max_tip_amountIntegerTùy chọnSố tiền boa tối đa
suggested_tip_amountsArray of IntegerTùy chọnMảng JSON các mức tiền boa gợi ý
start_parameterStringTùy chọnDeep link để thanh toán
provider_dataStringTùy chọnDữ liệu JSON cho nhà cung cấp
photo_urlStringTùy chọnURL ảnh sản phẩm
photo_sizeIntegerTùy chọnKích thước ảnh
photo_widthIntegerTùy chọnChiều rộng ảnh
photo_heightIntegerTùy chọnChiều cao ảnh
need_nameBooleanTùy chọnYêu cầu họ tên người dùng
need_phone_numberBooleanTùy chọnYêu cầu số điện thoại
need_emailBooleanTùy chọnYêu cầu email
need_shipping_addressBooleanTùy chọnYêu cầu địa chỉ giao hàng
send_phone_number_to_providerBooleanTùy chọnGửi số điện thoại cho nhà cung cấp
send_email_to_providerBooleanTùy chọnGửi email cho nhà cung cấp
is_flexibleBooleanTùy chọnPhí giao hàng linh hoạt
disable_notificationBooleanTùy chọnGửi không âm thanh
protect_contentBooleanTùy chọnBảo vệ nội dung
allow_paid_broadcastBooleanTùy chọnCho phép gửi hàng loạt trả phí
message_effect_idStringTùy chọnID hiệu ứng tin nhắn
suggested_post_parametersSuggestedPostParametersTùy chọnĐối tượng JSON SuggestedPostParameters (cho kênh)
reply_parametersReplyParametersTùy chọnĐối tượng JSON ReplyParameters
reply_markupInlineKeyboardMarkupTùy chọnJSON: InlineKeyboardMarkup

Mô tả tham số chỉ là bản tóm tắt ngắn gọn; xem tài liệu chính thức để đọc toàn văn.

Ví dụ request

curl

curl -s -X POST "https://api.telegram.org/bot$TOKEN/sendInvoice" \
  -H "Content-Type: application/json" \
  -d '{
  "chat_id": 123456789,
  "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}/sendInvoice",
    json={
        "chat_id": 123456789,
        "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}/sendInvoice`, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "chat_id": 123456789,
    "title": "Example",
    "description": "Example item",
    "payload": "order-1",
    "currency": "XTR",
    "prices": [
      {
        "label": "Item",
        "amount": 100
      }
    ]
  }),
});
console.log(await res.json());

Hướng dẫn từng bước: Cách tạo bot Telegram từ A đến Z: BotFather, token và tin nhắn đầu tiên