createInvoiceLink
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ểu | Bắt buộc | Mô tả |
|---|---|---|---|
business_connection_id | String | Tùy chọn | ID kết nối doanh nghiệp |
title | String | Có | Tên sản phẩm |
description | String | Có | Mô tả sản phẩm |
payload | String | Có | Payload của hóa đơn |
provider_token | String | Tùy chọn | Token nhà cung cấp thanh toán |
currency | String | Có | Tiền tệ |
prices | Array of LabeledPrice | Có | Mảng JSON LabeledPrice |
subscription_period | Integer | Tùy chọn | Chu kỳ gói đăng ký tính bằng giây |
max_tip_amount | Integer | Tùy chọn | Số tiền boa tối đa |
suggested_tip_amounts | Array of Integer | Tùy chọn | Mảng JSON các mức tiền boa gợi ý |
provider_data | String | Tùy chọn | Dữ liệu JSON cho nhà cung cấp |
photo_url | String | Tùy chọn | URL ảnh sản phẩm |
photo_size | Integer | Tùy chọn | Kích thước ảnh |
photo_width | Integer | Tùy chọn | Chiều rộng ảnh |
photo_height | Integer | Tùy chọn | Chiều cao ảnh |
need_name | Boolean | Tùy chọn | Yêu cầu họ tên |
need_phone_number | Boolean | Tùy chọn | Yêu cầu số điện thoại |
need_email | Boolean | Tùy chọn | Yêu cầu email |
need_shipping_address | Boolean | Tùy chọn | Yêu cầu địa chỉ giao hàng |
send_phone_number_to_provider | Boolean | Tùy chọn | Gửi số điện thoại cho nhà cung cấp |
send_email_to_provider | Boolean | Tùy chọn | Gửi email cho nhà cung cấp |
is_flexible | Boolean | Tùy chọn | Giá linh hoạt |
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
Phương thức liên quan
sendInvoiceGửi hóa đơn thanh toán.refundStarPaymentHoàn tiền một khoản thanh toán bằng Telegram Stars.sendGiftGửi quà tặng cho người dùng hoặc chat.getMyStarBalanceTrả về số dư Telegram Stars của bot.getStarTransactionsTrả về các giao dịch Telegram Stars của bot.editUserStarSubscriptionHủy hoặc gia hạn gói đăng ký Telegram Stars.giftPremiumSubscriptionTặng gói đăng ký Telegram Premium.answerShippingQueryTrả lời truy vấn giao hàng.answerPreCheckoutQueryTrả lời truy vấn pre-checkout.getAvailableGiftsTrả về các quà tặng mà bot có thể gửi.getUserGiftsTrả về quà tặng của người dùng.getChatGiftsTrả về quà tặng của chat.