Closed bazuker closed 9 months ago
Hi @bazuker, thanks for the report!
This looks to be an issue with the conversation logic rather than invoices. Are you able to provide a minimal repro of this issue? I don't seem to be able to reproduce it on my end.
Also - just to double check, are you using the handlePayment
method for any other handlers (other than the "payment" command you show here)? It looks like it might be being triggered by another handler which isn't chat-scoped (eg, ShippingQuery
and PreCheckoutQuery
). If this is the case, you might want to consider setting the KeyStrategy to KeyStrategySender
, since it doesn't make sense to use chatids as part of the key strategy if there is no chat!
Hey @PaulSonOfLars! Thanks for replying and Merry Christmas!
Changing the KeyStrategy to KeyStrategySender
-> StateStorage: conversation.NewInMemoryStorage(conversation.KeyStrategySender)
has fixed the panic, however the transaction still fails, but now without any error message so I still do no understand what is going on unfortunately.
Also, how do I capture the successfully completed transaction? Maybe I need to define another handler somewhere?
Merry Christmas to you too @bazuker!
Good to know - I'll be sure to add a check to handle chat-less updates. Wasn't something I had considered at time of writing.
From your description, it sounds like the sending of the payment is done OK, so SendInvoice
likely isn't failing (hence no error there).
So, my question here is going to be, how do you know the transaction is failing? What about https://core.telegram.org/bots/api#answerprecheckoutquery; are you handling the checkout query as telegram expects? Checkouts don't work if not handled within 10s, which may be the issue
@PaulSonOfLars I see. How to create an update handler for the callback made by telegram API to use bot.AnswerPreCheckoutQuery(..)
?
I've tried adding something like this
dispatcher.AddHandler(handlers.NewCallback(nil, func(b *gotgbot.Bot, ctx *ext.Context) error {
fmt.Println("some update!")
return nil
}))
But it does not seem to catch the pre-checkout update.
Well @bazuker, it isnt a callback update, its a precheckout update, which is why that handler doesn't trigger for it :)
It also looks like youre the first person using the lib for payment-related things, so there havent been any payment handlers added yet - I just opened up #129 to add new payment related handlers.
Would appreciate it if you could give it a try and come with any feedback (eg, other filters to add?) that you might have! You should be able to use the commit SHA to try out my changes before i merge them in with go get github.com/PaulSonOfLars/gotgbot/v2@5cd5cd5e49a45c53c22f69240824ab890cc3e120
@PaulSonOfLars thank you!
Glad I could help! I'll take this as confirmation that the PR worked as expected :)
Steps:
Setup
Stack trace