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.

39 lines
1.7 KiB

1 year ago
  1. # Telegram Payments
  2. With the files in this folder, you can create and send invoices to your users, require their shipping details, define custom / flexible shipping methods and send a confirmation message after payment.
  3. ## Enable payments for your bot
  4. Read all about Telegram Payments and follow the setup guide here:
  5. https://core.telegram.org/bots/payments
  6. ## Configuring the `/payment` command
  7. First of all, as a bare minimum, you need to copy the [`PaymentCommand.php`](PaymentCommand.php) and [`PrecheckoutqueryCommand.php`](PrecheckoutqueryCommand.php) files in this folder to your custom commands folder.
  8. If you want to allow flexible shipping options, you will also need to copy [`ShippingqueryCommand.php`](ShippingqueryCommand.php) to your custom commands folder.
  9. Should you want to send a message on a successful payment, you will need to copy the [`GenericmessageCommand.php`](GenericmessageCommand.php) file as well.
  10. If you already have a `GenericmessageCommand.php` file, you'll need to copy the code from the `execute` method into your file.
  11. Next, you will need to add the Payment Provider Token (that you received in the previous step when linking your bot), to your `hook.php` or `manager.php` config.
  12. For `hook.php`:
  13. ```php
  14. $telegram->setCommandConfig('payment', ['payment_provider_token' => 'your_payment_provider_token_here']);
  15. ```
  16. For `manager.php` or using a general `config.php`, in the config array add:
  17. ```php
  18. ...
  19. 'commands' => [
  20. 'configs' => [
  21. 'payment' => ['payment_provider_token' => 'your_payment_provider_token_here'],
  22. ],
  23. ],
  24. ...
  25. ```
  26. Now, when sending the `/payment` command to your bot, you should receive an invoice.
  27. Have fun with Telegram Payments!