grammyjs / grammY

The Telegram Bot Framework.
https://grammy.dev
MIT License
2.37k stars 117 forks source link

Error: Missing information for API call to answerPreCheckoutQuery #666

Closed andrew-sol closed 1 day ago

andrew-sol commented 3 days ago

Here's my code:

    bot.on('pre_checkout_query', async (ctx) => {
      const query = ctx.update.pre_checkout_query;

      // some validation logic here...

      return await ctx.answerPreCheckoutQuery(true);
    });

I see the following error in the logs:

Error: Missing information for API call to answerPreCheckoutQuery

The interesting part is that regardless of the error everything works fine, the bot receives the successful payment message after this one. Why do I get this error? Is this a bug in the library or am I doing something wrong?

KnorpelSenf commented 1 day ago

Can you reproduce the error if you call ctx.api.answerPreCheckoutQuery manually and specify the right value for pre_checkout_query_id?

andrew-sol commented 1 day ago

Yep, it's the same when I use

bot.on('pre_checkout_query', async (ctx) => {
  const query = ctx.update.pre_checkout_query;

  // some validation logic here...

  return await ctx.api.answerPreCheckoutQuery(query.id, true);
});
andrew-sol commented 1 day ago

I'm sorry. The issue occurred because I accidentally put return await ctx.answerPreCheckoutQuery(true); at the end of the next handler - message:successful_payment. That's why everything worked well but the log appeared.

Thanks for your attention anyway, @KnorpelSenf