You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.5 KiB

1 year ago
  1. <?php
  2. /**
  3. * This file is part of the PHP Telegram Bot example-bot package.
  4. * https://github.com/php-telegram-bot/example-bot/
  5. *
  6. * (c) PHP Telegram Bot Team
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. /**
  12. * Pre-checkout query required for "/payment" command
  13. *
  14. * In this command you can perform any necessary verifications and checks
  15. * to allow or disallow the final checkout and payment of the invoice.
  16. */
  17. namespace Longman\TelegramBot\Commands\SystemCommands;
  18. use Longman\TelegramBot\Commands\SystemCommand;
  19. use Longman\TelegramBot\Entities\ServerResponse;
  20. class PrecheckoutqueryCommand extends SystemCommand
  21. {
  22. /**
  23. * @var string
  24. */
  25. protected $name = 'precheckoutquery';
  26. /**
  27. * @var string
  28. */
  29. protected $description = 'Pre-Checkout Query Handler';
  30. /**
  31. * @var string
  32. */
  33. protected $version = '0.1.0';
  34. /**
  35. * Main command execution
  36. *
  37. * @return ServerResponse
  38. */
  39. public function execute(): ServerResponse
  40. {
  41. // Simply approve, no need for any checks at this point.
  42. return $this->getPreCheckoutQuery()->answer(true);
  43. // If we do make certain checks, you can define the error message displayed to the user like this.
  44. // return $this->getPreCheckoutQuery()->answer(false, [
  45. // 'error_message' => 'Registration (or whatever) required...',
  46. // ]);
  47. }
  48. }