Telegram Bot API
🌐 Tiếng Việt

createInvoiceLink

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

Tạo liên kết thanh toán.

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

Tham số

Tham sốKiểuBắt buộcMô tả
business_connection_idStringTùy chọnID kết nối doanh nghiệp
titleStringCóTên sản phẩm
descriptionStringCóMô tả sản phẩm
payloadStringCóPayload của hóa đơn
provider_tokenStringTùy chọnToken nhà cung cấp thanh toán
currencyStringCóTiền tệ
pricesArray of LabeledPriceCóMảng JSON LabeledPrice
subscription_periodIntegerTùy chọnChu kỳ gói đăng ký tính bằng giây
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 ý
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
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ọnGiá linh hoạt

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/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());

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