Telegram Stars & Paid Subscriptions

Raw MD
Accept Telegram Stars digital currency and configure recurring subscription periods using createInvoiceLink.

Monetizing with Telegram Stars

Telegram Stars (⭐️) allow users to pay for digital goods, services, and monthly subscriptions inside bots without third-party payment gateways.

Recurring Stars Subscription Invoice
function create_stars_subscription(string $title, string $description, int $starsPrice, int $periodSeconds = 2592000): string {
    $res = bot('createInvoiceLink', [
        'title'               => $title,
        'description'         => $description,
        'payload'             => 'sub_' . bin2hex(random_bytes(8)),
        'currency'            => 'XTR', // Official Telegram Stars Currency Code
        'prices'              => [
            ['label' => $title, 'amount' => $starsPrice]
        ],
        'subscription_period' => $periodSeconds // 2592000 = 30 days recurring
    ]);
    return $res['result'] ?? '';
}