How to get PreCheckoutQuery in Telegram?


Hello, I am trying to implement the acceptance of payments through the Telegram Bot. I created the sendInvoice method, and now I need to implement the answerPreCheckoutQuery method. But it’s not entirely clear how to get an update with preCheckoutQuery after payment. Thank you in advance.


So, this issue is resolved, but now another problem.

In Telegram two ways to get updates for the bot - “getUpdates” and “Webhooks”, but you cannot use them together. To make a payment, I have to get PreCheckoutQuery via Webhook. But when I switch to the Webhook mode, the bot naturally stops working, because getUpdates is no longer working. Then I tried to turn on the webhook only at the time of confirmation of the payment, and then immediately switch to getUpdates mode, and everything seems to be working, the payment passes, but after that the bot completely stops responding. “Ask a Question” action starts but the answer does not return. When I send answer to the bot, the logs show endless waiting for an answer to a question. What could be the problem?

(Daniel Beckett) #3

Hi @DmitrySpace

I believe you also emailed into the support desk for help with this. Did you see the response we sent on there? :slightly_smiling_face:


Yes, I send message to you


The question is still relevant! :grimacing:

1 Like
(Michael Araque) #6

I have the same problem i can get the precheckout_id via url with answerprecheckoutquery but in my code i try to get the Update to get ID automatically and i receive a blank response


Dmitry, could you please share the way of implementation payment in Flowxo. I’ve done creating invoice, but stuck on making answerPreCheckout :frowning:

Thanks in advance!

(Nathan Stults) #8

This was not possible until an update today - we are now correctly processing the Telegram Payments callbacks. Here is a sample for a simple payment with no flexible shipping method required:

If anyone needs to see a sample with dynamic shipping costs let us know.



(Nathan Stults) #9

This is a more up to date sample: