You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i've built a telegram bot using nodejs that downloads videos from tweet urls. Completed that part. now, Iim struggling to implement a paywall using the sendInvoice method in the Telegram API.
So finally to implement what's being said and to make things simple i started to use this library node-telegram-bot-api (previously used rest api from telegram)
Even after making the changes suggested from the docs and on the similar stackoverflow solution above.
I have come to this (an abstracted version 2 of my source code):
import{config}from"dotenv";importTelegramBotfrom"node-telegram-bot-api";importgetTwitterVideoURLfrom"./twitterfunction.js";config();consttoken=process.env.TELEGRAM_BOT_TOKEN;// console.log(token);constbot=newTelegramBot(token,{polling: true});bot.on("message",async(msg)=>{// console.log(JSON.stringify(msg, null, 2));constchatId=msg.chat.id;constmessage=msg.text.trim();console.log(JSON.stringify(msg,null,2));bot.sendInvoice(chatId,"Title goes here","Unlock premium content with a subscription","Invoice for payment","MY_PROVIDER_TOKEN","USD",[{label: "tax",amount: 4000}],{is_flexible: false,need_phone_number: false,need_email: true,need_shipping_address: false,});});bot.on("pre_checkout_query",async(query)=>{console.log("Received pre-checkout query:",query);// Answer the pre-checkout query within 10 seconds more info: https://core.telegram.org/bots/api#answerprecheckoutqueryconstpreCheckoutQueryAnswer=awaitbot.answerPreCheckoutQuery(query.id,true);console.log("Pre-checkout query answer:",preCheckoutQueryAnswer);});bot.on("successful_payment",async(payload)=>{console.log("Successful payment:",payload);constmessage=`Thank you for your payment of ${payload.total_amount/100}${payload.currency}!`;awaitbot.sendMessage(payload.chat_id,message);});bot.on("invoice",(error)=>{console.log("invoice",error);});bot.on("shipping_query",async(query)=>{console.log("Received shipping query:",query);// Don't have any shipping options, provide an empty arrayconstshippingOptions=[];constshippingQueryAnswer=awaitbot.answerShippingQuery(query.id,true,// Set to false if the shipping cannot be processed{shipping_options: shippingOptions});console.log("Shipping query answer:",shippingQueryAnswer);});
Still the same problem. Tried other payment provider too no luck.
Can anyone help me out please.
The text was updated successfully, but these errors were encountered:
i've built a telegram bot using nodejs that downloads videos from tweet urls. Completed that part. now, Iim struggling to implement a paywall using the
sendInvoice
method in the Telegram API.https://core.telegram.org/bots/api#sendinvoice
i'm using Stripe for payments in test mode. however, after sending the invoice, when users try to pay, it buffers and times out as in the image.
Question i asked on stackoverflow (my version 1 code without using any external libs for the bot):
https://stackoverflow.com/questions/78251916/stripe-pre-checkout-timeout-error-while-making-a-test-payment-from-telegram-bot
Not sure what was wrong there at the first time; i did find this similar problem on stackoverflow:
https://stackoverflow.com/questions/73341054/telegram-sendinvoice-method-is-failing
Which i almost thought i solved it, but i am not even receiving the
update
object as explained herehttps://core.telegram.org/bots/api#answershippingquery
So finally to implement what's being said and to make things simple i started to use this library
node-telegram-bot-api
(previously used rest api from telegram)Even after making the changes suggested from the docs and on the similar stackoverflow solution above.
I have come to this (an abstracted version 2 of my source code):
Still the same problem. Tried other payment provider too no luck.
Can anyone help me out please.
The text was updated successfully, but these errors were encountered: