Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue calling answerPreCheckoutQuery #101

Closed
culda opened this issue Mar 6, 2024 · 4 comments
Closed

Issue calling answerPreCheckoutQuery #101

culda opened this issue Mar 6, 2024 · 4 comments
Assignees
Labels
puregram This issue concerns to puregram package

Comments

@culda
Copy link

culda commented Mar 6, 2024

the bug

I'm trying to handle pre_checkout_query updates and I have this code which throws an error

TypeError: Cannot read properties of undefined (reading 'telegram')
    at answerPreCheckoutQuery (file:///var/task/src/functions/shopTelegramWebhook/handler.mjs:37707:21)
    at handleUpdate (file:///var/task/src/functions/shopTelegramWebhook/handler.mjs:66424:11)
    at Runtime.handler (file:///var/task/src/functions/shopTelegramWebhook/handler.mjs:66369:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Code:

async function handleUpdate({
  update,
  telegram,
}: {
  update: TelegramUpdate;
  telegram: Telegram;
}) {
  const context = telegram.updates.handleUpdate(update);

  if (context?.is("pre_checkout_query")) {
    console.log(context.invoicePayload);
    await context.answerPreCheckoutQuery({ ok: true });
  }
}

Note the invoicePayload is correctly logged from the context.

steps to reproduce

steps to reproduce the behavior:

  1. send update to bot server
  2. call context.answerPreCheckoutQuery({ ok: true })

expected behavior

Expect the call to not throw an error

environment

package version
puregram 2.25.1
TypeScript 5
@culda culda added the puregram This issue concerns to puregram package label Mar 6, 2024
@culda
Copy link
Author

culda commented Mar 6, 2024

Works when I invoke the method from the api object.

    telegram.api.answerPreCheckoutQuery({
      pre_checkout_query_id: context.id,
      ok: true,
    });

@nitreojs
Copy link
Owner

nitreojs commented Mar 7, 2024

have to ask a question: why exactly are you handling updates manually? just to be sure everything is going ok on your side

@nitreojs
Copy link
Owner

bump?

@nitreojs
Copy link
Owner

i will close this issue as no further answer was provided, assuming the issue is not present anymore. feel free to reopen it if it happens again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
puregram This issue concerns to puregram package
Projects
None yet
Development

No branches or pull requests

2 participants