Api
Api copied to clipboard
SuccessfulPayment not work, error or misuse
hello i'm about to test payment capabilities, but it seem that SuccessfulPayment event not trigger, i'm i doing something wrong or what? preCheckoutQuery and answerPreCheckoutQuery phase work great!
$bot->preCheckoutQuery(function ($message) use ($bot) {
$bot->answerPreCheckoutQuery($message->getId(), true);
});
$bot->on(function (\TelegramBot\Api\Types\Payments\SuccessfulPayment $update) use ($bot) {
$message = $update->getMessage();
$id = $message->getChat()->getId();
$bot->sendMessage($id, 'it work!');
});
I have the same issue. Have you found a workaround?
this work for me!
/**
* validate order
*/
$bot->on(function (\TelegramBot\Api\Types\Update $update) use ($bot) {
$message = $update->getMessage();
$id = $message->getChat()->getId();
$successful_payment = $message->getSuccessfulPayment();
if ($successful_payment) {
$bot->sendMessage($id, 'it work!');
}
}, function () {
return true;
});