CloudPayments notifications in Telegram: payments, declines and refunds in one chat

CloudPayments notifications in Telegram take three nana800 blocks: webhook receives the payment data, webhook response answers CloudPayments with {"code":0}, and Telegram message send posts to your chat or team group. CloudPayments sends the notification by itself after a payment, a decline or a refund, so you need no server. One notification is two basic block runs, and the answer is free.

Build it in the builder

What you can automate

  • A message for every payment (the Pay notification): amount, currency, order number InvoiceId, customer email and the last card digits
  • Declined payments (Fail) with the reason from Reason and ReasonCode, so a manager can reach the customer before they give up
  • Refunds (Refund): the amount and the original payment number PaymentTransactionId, so accounting sees every refund
  • Two-step payments: a Pay notification with the status Authorized means the money is only held, and the message reminds you to confirm the order
  • Tell apart trial payments of a test site: their TestMode is 1, and the condition block can skip them
  • See payments of links created by the CloudPayments block: the order number set in the block comes back in the notification as InvoiceId

How to set it up

  1. 1

    Create a scheme and put the answer first

    Create a scheme with the webhook trigger, the POST method and a path such as /cloudpayments. Right after the trigger add the free webhook response block: put {"code":0} into body json and keep the status OK. The answer goes first so CloudPayments gets it for every notification and within its 30 seconds of waiting.

  2. 2

    Enter the address in your CloudPayments account

    Turn the scheme on and copy the webhook address on the API page. In your CloudPayments account open the site settings and turn on the Pay, Fail and Refund notifications. Paste the address into each one with a mark at the end: ?type=pay, ?type=fail or ?type=refund. Choose the POST method and UTF-8 encoding.

  3. 3

    Route notifications by type

    After the answer add a condition block: query.type equals pay. Send its true branch to a Telegram message send block about the purchase. Send the other branch to a second condition that checks fail: its true branch gets the decline message, and the remaining branch the refund message. Condition blocks are free.

  4. 4

    Write the message texts

    In each Telegram block enter the bot token from @BotFather and the chat ID. The notification fields sit in body under the names from the CloudPayments docs: Amount with a dot, Currency, InvoiceId for the order number, Email, CardLastFour for the last four card digits, Reason for the decline reason, DateTime in UTC.

  5. 5

    Test it on a test site

    Make a payment on a CloudPayments test site and open the run history of the scheme: it shows the received fields and the {"code":0} answer. If no message arrived, check error_text in the result of the Telegram block. Do not turn the scheme off: a disabled scheme answers with error 409, and an enabled one costs $0.0042 per hour.

Pricing

A run of a CloudPayments block costs $0.002, a run of a Telegram block costs $0.001. Every month the balance is topped up to $3.50 for free, an enabled scheme costs $0.0042 per hour.

Services in this connection

  • CloudPayments

    CloudPayments payment links, payment search by order number and refunds right from a scheme, without code. Free balance every month, no card needed.

  • Telegram

    Build a Telegram bot without code: reply to messages, add buttons, send leads and alerts to a chat, group or channel. Free balance every month, no card needed.

Similar integrations

  • amoCRM + Telegram

    Get new amoCRM deals and stage changes as Telegram messages in a private chat or a team group. No code and no server, free balance every month.

  • Bitrix24 + Telegram

    Get new Bitrix24 leads, deals and tasks as Telegram messages in a private chat or a team group. No code and no server, free balance every month.

  • Email + Telegram

    Forward new emails from any IMAP mailbox to Telegram with no code: sender, subject and text, also from your company domain. Free balance every month, no card needed.

  • Gmail + Telegram

    Get new Gmail emails as Telegram messages: sender, subject and text in your private chat or a team group. Free balance every month, no card needed.

  • HTTP request + Telegram

    Check a website or API on schedule and get a Telegram message when it is down or returns an error. No code and no server of your own, free start every month.

  • OpenAI (ChatGPT) + Telegram

    ChatGPT writes posts and a bot publishes them to your Telegram channel on the days and hours you choose, with no code. Free balance every month, no card needed.

Frequently asked questions

Each notification is one webhook run and one Telegram message send, two basic block runs, and 1,000 runs cost $1. The webhook response and condition blocks are free. The scheme waits for notifications around the clock at $0.0042 per hour, which takes most of the free $3.50 a month. Only CloudPayments takes a fee from payments.

CloudPayments treats the notification as undelivered and repeats it up to 100 times with pauses of 1, 2, 5, 10 and 30 minutes. This happens when the scheme is off and the webhook answers with code 409. Without a webhook response block nana800 answers {"finished":true,"default":true}, which is not {"code":0} either. Once the scheme is on, the repeats get through and the messages arrive late.

Better not. Check arrives before the money is taken, and CloudPayments goes on with the payment only after getting {"code":0}. A scheme with webhook response would approve every payment, and a disabled scheme or a network failure would decline payments. Pay, Fail and Refund are enough for Telegram messages, and they arrive after the operation.

No. CloudPayments signs notifications in the Content-HMAC and X-Content-HMAC headers, and nana800 has no block that can compute this signature. So anyone who learns the address can send a fake notification. If a notification releases goods, add the CloudPayments block with get_payment and the TransactionId: a real payment returns the status Completed. That is two more runs.

Both a regular form (application/x-www-form-urlencoded) and JSON work: the webhook trigger parses both and puts the fields into body under the same names. The method in the notification settings must match the method of the trigger, POST is the easiest. The ?type=pay mark at the end of the address goes into query and does not change the webhook path.

By then CloudPayments already has {"code":0} and does not repeat the notification. The result of the Telegram block keeps error_text with the reason, for example a wrong chat ID, and an unsent message is not charged. The payment itself is not lost: its data stays in the run history of the scheme and in your CloudPayments account.

Build your first scheme for free

Sign-up is free and needs no card. Every month the balance is topped up to $3.50 for free, enough for about 3,500 runs of basic blocks.

Build it in the builder