コンテンツへスキップ
ArionPay
Telegramボット決済
近日公開

Telegram内で暗号資産決済を受け付ける

顧客がTelegramから離れずに支払えるよう、TelegramボットとMini Appの決済を開発中です。まだ利用はできません。現在は、Telegramで支払い通知を受け取る、既製のArionPay Telegramショップボットを運用する、REST APIで作成したArionPayの決済リンクを独自のボットから顧客に送る、といったことができます。

Telegram、Discord、メールでの支払い通知9つのネットワークで16種類のコインとトークン注文を届けるための署名付きWebhook
近日公開計画中のボット決済のプレビュー
NC

Northwind Coffee

ボット

/buy

12:04

コーヒー豆、1 kg

合計:$29.99 USD
ショップ自身のウォレットに直接支払い

/buy と入力…

現在可能:独自のボットから決済リンクを送る

ボットが署名付きAPIリクエスト1回で請求書を作成し、invoice_urlをボタンとして顧客に送ります。顧客はArionPayの決済ページで、あなたのウォレットに直接支払います。

import hashlib, hmac, json, os, time
import requests
import telebot  # pip install pyTelegramBotAPI requests

bot = telebot.TeleBot(os.environ["TELEGRAM_BOT_TOKEN"])

API_KEY = os.environ["ARIONPAY_API_KEY"]        # pk_...
API_SECRET = os.environ["ARIONPAY_API_SECRET"]  # your store's secret
BASE_URL = os.environ["ARIONPAY_URL"]           # your ArionPay address

def create_invoice(payload):
    body = json.dumps(payload, separators=(",", ":"))
    ts = str(int(time.time()))
    sig = hmac.new(API_SECRET.encode(), f"{ts}.{body}".encode(), hashlib.sha256).hexdigest()
    res = requests.post(
        f"{BASE_URL}/api/v1/invoices",
        data=body,  # send exactly the bytes you signed
        headers={
            "Content-Type": "application/json",
            "x-api-key": API_KEY,
            "x-timestamp": ts,
            "x-signature": sig,
        },
        timeout=15,
    )
    res.raise_for_status()
    return res.json()

@bot.message_handler(commands=["buy"])
def buy(message):
    user_id = message.from_user.id
    invoice = create_invoice({
        "amount": "29.99",
        "currency": "USD",
        "orderId": f"tg-{user_id}-{int(time.time())}",
        "metadata": {"telegramUserId": user_id},
    })
    markup = telebot.types.InlineKeyboardMarkup()
    markup.add(telebot.types.InlineKeyboardButton("Pay with crypto", url=invoice["invoice_url"]))
    bot.send_message(message.chat.id, "Your order: $29.99. Tap below to pay.", reply_markup=markup)

# Deliver the order when your webhook endpoint receives invoice.paid
# (check the ArionPay-Signature header first; see /docs).

bot.infinity_polling()

現在できること

支払い通知。支払いが届くと、Telegram、Discord、メールでメッセージを受け取れます。ダッシュボードでオンにしてください。

ショップボット。既製のTelegramショップボットをご自身のサーバーで運用するか、上記のコードのように、独自のボットからREST APIで請求書を作成します。

商品の提供。サーバーに署名付きのinvoice.paid Webhookが届いたら、購入された商品を顧客に送れます。