From f1342e3f421f05f92eaa2728c54f10a9402651cf Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 1 Nov 2024 21:33:47 -0400 Subject: [PATCH] Add PreCheckoutQueryEvent handling --- src/TgBotLib/Classes/Utilities.php | 5 ++++ src/TgBotLib/Enums/UpdateEventType.php | 2 ++ src/TgBotLib/Events/PreCheckoutQueryEvent.php | 29 +++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 src/TgBotLib/Events/PreCheckoutQueryEvent.php diff --git a/src/TgBotLib/Classes/Utilities.php b/src/TgBotLib/Classes/Utilities.php index 339764b..e4651f0 100644 --- a/src/TgBotLib/Classes/Utilities.php +++ b/src/TgBotLib/Classes/Utilities.php @@ -101,6 +101,11 @@ return UpdateEventType::PAID_MEDIA_PURCHASED; } + if($update->getPreCheckoutQuery() !== null) + { + return UpdateEventType::PRE_CHECKOUT_QUERY; + } + return UpdateEventType::UPDATE_EVENT; } } \ No newline at end of file diff --git a/src/TgBotLib/Enums/UpdateEventType.php b/src/TgBotLib/Enums/UpdateEventType.php index 41a9c97..047f9b6 100644 --- a/src/TgBotLib/Enums/UpdateEventType.php +++ b/src/TgBotLib/Enums/UpdateEventType.php @@ -10,6 +10,7 @@ use TgBotLib\Events\PollAnswerEvent; use TgBotLib\Events\PollEvent; use TgBotLib\Events\PaidMediaPurchasedEvent; + use TgBotLib\Events\PreCheckoutQueryEvent; use TgBotLib\Events\RemovedChatBoostEvent; enum UpdateEventType : string @@ -23,4 +24,5 @@ case POLL_ANSWER = PollAnswerEvent::class; case POLL = PollEvent::class; case PAID_MEDIA_PURCHASED = PaidMediaPurchasedEvent::class; + case PRE_CHECKOUT_QUERY = PreCheckoutQueryEvent::class; } diff --git a/src/TgBotLib/Events/PreCheckoutQueryEvent.php b/src/TgBotLib/Events/PreCheckoutQueryEvent.php new file mode 100644 index 0000000..8ae749d --- /dev/null +++ b/src/TgBotLib/Events/PreCheckoutQueryEvent.php @@ -0,0 +1,29 @@ +update->getPreCheckoutQuery(); + } + } \ No newline at end of file