YooMoney API
Old versions of the API
Help
Sign up for YooMoney
Setting up payments via Telegram Bots
To accept payments via Telegram, you will need to do three things:
  1. Create a bot
  2. Connect it to the YooMoney bot
  3. Set up your bot to process payments
To set up payments via the bot, you will need the shopId parameter that you can get after signing up for YooMoney
 
How to create a bot
  1. Open the chat with @BotFather in Telegram, send the /start command, then /newbot.
  2. Give the bot a name and a username. The bot's name will be shown in the contact list and at the top of the chat, it can be non-unique. The username will be in the short link to the bot, and it must be unique.
  3. Example:
    YooMoney: payments is the bot's name
    YooMoneyPaymentBot is the bot's username
  4. If the username is not taken, BotFather will respond to with the token, i.e. the "key" to access the created bot. Don't give this token to anyone else, even the YooMoney's or Telegram's support services.
    Once you have the key, the bot is ready: you can add an icon and configure the dialog patterns for customers. You can also set up payments via the bot.
How to connect your bot to the YooMoney bot
  1. Send the /mybots command to @BotFather. Click on your bot's name.
  2. Select BotSettings — Payments in the bot's dashboard.
  3. Если хотите сразу настроить настоящие платежи, в открывшемся меню выберите Connect ЮKassa: платежи. Если хотите сначала протестировать — выберите Connect ЮKassa: тест.
    Если выбран бот ЮKassa: платежи
    Если выбран бот ЮKassa: тест
  4. Return to the chat with @BotFather. It will send you the token required for invoicing. You can always view the token via BotSettings — Payments.
Setting up the bot to process payments
Обратите внимание: дальше речь пойдёт о настройке бота через API Telegram. Если вы используете конструктор ботов (Manybot, Botobot, Botmaker или любой другой), следуйте его инструкциям.
  1. Implement the sendinvoice method from Telegram's payment API your bot will start sending invoices to clients in response to this request. Invoices should include the price, name, product description, payload parameter, and provider_token parameter — the token provided by @BotFather after you connected your bot to the YooMoney bot.
    Обратите внимание, что платежи для тестового магазина должны быть не более 1000 рублей.
    View example of a sendinvoice request
    If you set up fiscalization via YooMoney, you will need to send data for fiscalization to YooMoney by adding the following parameters to the request:
    • need_phone_number или need_email
    • send_email_to_provider (если вы запрашивали у клиента электронную почту) илиsend_phone_number_to_provider (если вы запрашивали у клиента телефон),
    • provider_data и в нём объект receipt. Подробности — в API ЮKassa (смотрите раздел Атрибуты — receipt).
    See an example
    You can request the customer's phone number or email address earlier, during the chat with the bot. Then the first two parameters are not required, and provider_data with the receipt object would be enough.
    See an example
    If you need the customer to provide you with an address for delivery, implement the Shipping Query method. When the user provides the address, respond to this query with the answerShippingQuery method. Indicate the delivery methods and their prices in this method.
  2. When the user confirms the payment, Telegram will send you a webhook with Update containing the PreCheckoutQuery object. You need to respond to this query within 10 seconds by calling the answerPreCheckoutQuery method.
  3. You will receive two notifications: Telegram will send you a webhook with Update containing the SuccessfulPayment object, YooMoney will send you an email notification of transfer.
    В объекте SuccessfulPayment из уведомления от Telegram найдите параметр provider_payment_charge_id: там будет номер транзакции в ЮKassa. Этот номер лучше сохранить: по нему можно будет найти платёж в личном кабинете.
What payments via Telegram bot looks like
Обратите внимание: оплата через бота не поддерживается в десктопной и веб-версии Telegram — только в приложении.
As an example, let's take the replenishment of the mobile phone balance via the YooMoney test bot — @YooKassaTestShopBot.
  1. Send the /start command.
  2. Click Pay.
  3. This opens the payment page.
  4. Enter the bank card details and click Pay.
  5. На странице Checkout нажмите Pay.
  6. После успешной оплаты @YooKassaTestShopBot отправит в чат номер транзакции (для своего бота вы сможете запрограммировать другое действие).