Api icon indicating copy to clipboard operation
Api copied to clipboard

SuccessfulPayment not work, error or misuse

Open studiosacchetti opened this issue 3 years ago • 2 comments

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!');
        
    });

studiosacchetti avatar Jul 12 '22 16:07 studiosacchetti

I have the same issue. Have you found a workaround?

DewFill avatar Oct 05 '22 22:10 DewFill

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;
                    });

studiosacchetti avatar Oct 06 '22 08:10 studiosacchetti