Telegram Bot API
🌐 Português

sendInvoice

Categoria: Pagamentos · Bot API 10.3 · Documentação oficial

Envia uma fatura para pagamento.

Retorno: Em caso de sucesso, retorna Message.

Parâmetros

ParâmetroTipoObrigatórioDescrição
chat_idInteger or StringSimChat ID ou @username
message_thread_idIntegerOpcionalID do tópico do fórum
direct_messages_topic_idIntegerOpcionalID do tópico de mensagens diretas (Bot API 10.0)
titleStringSimNome do produto (1-32)
descriptionStringSimDescrição do produto (1-255)
payloadStringSimPayload (dados internos)
provider_tokenStringOpcionalToken do provedor de pagamento
currencyStringSimMoeda (XTR para Stars)
pricesArray of LabeledPriceSimArray JSON de LabeledPrice
max_tip_amountIntegerOpcionalValor máximo da gorjeta
suggested_tip_amountsArray of IntegerOpcionalArray JSON de valores de gorjeta sugeridos
start_parameterStringOpcionalDeep link para o pagamento
provider_dataStringOpcionalDados JSON para o provedor
photo_urlStringOpcionalURL da foto do produto
photo_sizeIntegerOpcionalTamanho da foto
photo_widthIntegerOpcionalLargura da foto
photo_heightIntegerOpcionalAltura da foto
need_nameBooleanOpcionalSolicitar nome do usuário
need_phone_numberBooleanOpcionalSolicitar número de telefone
need_emailBooleanOpcionalSolicitar e-mail
need_shipping_addressBooleanOpcionalSolicitar endereço de entrega
send_phone_number_to_providerBooleanOpcionalEnviar telefone ao provedor
send_email_to_providerBooleanOpcionalEnviar e-mail ao provedor
is_flexibleBooleanOpcionalPreço de entrega flexível
disable_notificationBooleanOpcionalEnviar sem som
protect_contentBooleanOpcionalProteger conteúdo
allow_paid_broadcastBooleanOpcionalPermitir transmissão paga
message_effect_idStringOpcionalID do efeito da mensagem
suggested_post_parametersSuggestedPostParametersOpcionalObjeto JSON SuggestedPostParameters (para canais)
reply_parametersReplyParametersOpcionalObjeto JSON ReplyParameters
reply_markupInlineKeyboardMarkupOpcionalObjeto JSON InlineKeyboardMarkup

As descrições dos parâmetros são resumos concisos; consulte a documentação oficial para ver o texto completo.

Exemplo de requisição

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

Guia passo a passo: Como criar um bot no Telegram grátis: do BotFather à primeira mensagem