> For the complete documentation index, see [llms.txt](https://docs.graspil.com/en/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.graspil.com/en/cases/case-yookassa.md).

# Case: accepting payments via YooKassa

A step-by-step guide: how to connect a bot and accept payments right inside it via YooKassa — from connecting the shop to an automation that creates a payment, sends the link, and reacts to the outcom

This guide walks through the whole path — from connecting a YooKassa shop to an automation that creates a payment, sends the user a payment link, and continues the scenario depending on whether the user paid, canceled, or never paid.

{% hint style="info" %}
**End result:** the user reaches the right step in the bot (e.g. picked a plan) → graspil creates a payment directly via the YooKassa API and sends the user a payment link → after the payment is completed (or canceled, or the wait times out) the automation continues down the matching branch — you can grant access, say thanks, send a reminder, and so on.
{% endhint %}

{% hint style="warning" %}
Payment goes through the YooKassa API directly, not through Telegram's built-in payments — this gives more control over payment data. Connecting is a one-click YooKassa sign-in (OAuth) — no technical keys to enter.
{% endhint %}

{% hint style="info" %}
If anything is unclear along the way — open the chat with the built-in AI assistant in your account and describe the task in your own words, it will suggest concrete steps for your situation.
{% endhint %}

***

## Step 1. Connect your bot

For the automation to send messages and react to user events, connect your bot first — see [Connecting a bot](/en/connect-bot.md) for details.

## Step 2. Connect the YooKassa integration

1. Go to the **Integrations** section in your account.
2. Find the **YooKassa** card in the list of available integrations and click **Configure**.
3. Click **Connect** — you'll be redirected to YooKassa's authorization page.
4. Sign in to your YooKassa account (if not already signed in), pick the shop you want to grant access to, and confirm.
5. You'll be redirected back to your graspil account automatically — the integration is connected.

{% hint style="info" %}
No technical keys to enter, and nothing to configure by hand in the YooKassa cabinet — graspil registers payment notifications automatically right after connecting.
{% endhint %}

Use **Test connection** any time to confirm access is still active. If access was revoked (e.g. you disconnected the app in YooKassa's settings) — reconnect the integration the same way.

## Step 3. Build the automation

There's no ready-made template in the catalog yet — build the flow manually, in the **Automations** section ([full documentation](/en/app/automations.md)).

1. Open **Automations** → **Create automation**, select your bot.
2. Add a **trigger** — for example, a "Buy" button click, or any other event after which the user should be billed.
3. Add an action block **Integrations** → **Create payment (YooKassa)** and fill in:
   * **Integration** — the one you connected in Step 2.
   * **Amount** — a number (e.g. `990.00`) or a template, e.g. `{{ event.value }}`, if the amount depends on the user's choice.
   * **Currency** — defaults to `RUB`.
   * **Payment description** — what the user (and YooKassa itself) will see, e.g. `Pro plan payment`.
   * **Payment wait timeout** — how many minutes to wait for payment before treating it as abandoned.
4. The block has three outputs — connect each to its own continuation:

   * **Paid** — the user paid the invoice.
   * **Canceled** — the payment was canceled in YooKassa.
   * **Not paid** — the wait timeout expired.

   You don't need to add a separate "Wait for event" block — the "Create payment" block already waits for the outcome itself; you only need to wire its ready-made outputs onward.
5. From the "Create payment" block to the next step (e.g. a "Send message" block on the **Paid** output), add a message with the payment link — use the variable `{{ steps.<id>.confirmation_url }}` (the block id is filled in automatically when you pick the variable in the message builder).
6. Connect every block with arrows, click **Run test** to check the flow, and publish the automation.

{% hint style="info" %}
A typical flow: **Trigger → Create payment → Send message with the link** (right after the payment is created, without waiting for it to be paid) **→** further down the **Paid** output — grant access/say thanks, and on **Canceled**/**Not paid** — e.g. a reminder or an offer to try again.
{% endhint %}

***

## Reacting to a payment from another automation

The "YooKassa payment succeeded" event is also available as a regular **"By event"** trigger in any other automation for the same bot — for example, if you want to run a separate scenario in parallel rather than continue the same chain (notify a manager, add the user to a segment, etc.). See the full list in [Events](/en/app/reports/events.md).

***

## Need help setting this up?

If something isn't working or you still have questions — contact graspil support, we'll help you set up payment acceptance via YooKassa for your specific case.
