Skip to main content

Async client for Telegram Wallet Pay API

Project description

Telegram Wallet Pay

Python async client for Telegram Wallet Pay API made of aiohttp and pydantic

Also contains:

  • pydantic models for every schema, even for incoming webhooks
  • signature validation tools:
    • ready-made Depends for FastAPI
    • ready-made decorator for aiohttp server

Python pypi Tests Coverage

Code linter: ruff Checked with mypy Gitmoji

Get started

Read Telegram Wallet Pay API docs

https://docs.wallet.tg/pay/#section/Get-started

Install our library

pip install telegram-wallet-pay

Create order

import asyncio
import os
from uuid import uuid4

from telegram_wallet_pay import TelegramWalletPay

# store TELEGRAM_WALLET_PAY_TOKEN to your .env
# wallet token can be issued via https://pay.wallet.tg/
TOKEN = os.getenv("TELEGRAM_WALLET_PAY_TOKEN")


async def main() -> None:
    """Create order."""
    # create wallet client instance
    wallet = TelegramWalletPay(TOKEN)

    # create your first order
    response = await wallet.create_order(
        amount=40,
        currency_code="EUR",
        description="TestPayment",
        external_id=str(uuid4()),
        timeout_seconds=5 * 60,
        customer_telegram_user_id=66812456,
    )

    # let's print creation response
    print("Response:", response)
    print("Order:", response.data)

    # don't forget close API-client instance on your app shutdown
    await wallet.close()


if __name__ == "__main__":
    asyncio.run(main())

Get order preview

import asyncio
import os

from telegram_wallet_pay import TelegramWalletPay

# store TELEGRAM_WALLET_PAY_TOKEN to your .env
# wallet token can be issued via https://pay.wallet.tg/
TOKEN = os.getenv("TELEGRAM_WALLET_PAY_TOKEN")


async def main() -> None:
    """Get order preview."""
    # create wallet client instance
    wallet = TelegramWalletPay(TOKEN)

    # get order preview
    response = await wallet.get_order_preview("<your-order-id>")

    # let's print received response
    print("Response:", response)
    print("Order Preview:", response.data)

    # don't forget close API-client instance on your app shutdown
    await wallet.close()


if __name__ == "__main__":
    asyncio.run(main())

Other examples

Also, feel free to open the folder with examples, and if there is something missing there, describe your needs in issue.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

telegram_wallet_pay-1.0.0.tar.gz (21.7 kB view details)

Uploaded Source

Built Distribution

telegram_wallet_pay-1.0.0-py3-none-any.whl (20.1 kB view details)

Uploaded Python 3

File details

Details for the file telegram_wallet_pay-1.0.0.tar.gz.

File metadata

  • Download URL: telegram_wallet_pay-1.0.0.tar.gz
  • Upload date:
  • Size: 21.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for telegram_wallet_pay-1.0.0.tar.gz
Algorithm Hash digest
SHA256 3cdf310d8281e24a4c805000695cce4be0c6c4f3fbbcf48a5eeb6110348165a3
MD5 59f34dcde43a7aa213e485b2acff5fc1
BLAKE2b-256 ca69b18e20496106bcf0156514728f77522ff884361f72b35b7338356a0032ed

See more details on using hashes here.

File details

Details for the file telegram_wallet_pay-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for telegram_wallet_pay-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 27cb79b642df978b55f7abad9903f961f6f0734a7ef1b81602e321cbac7e680d
MD5 3e4499d5269fcff742de7149b2c09fed
BLAKE2b-256 18249c953f77a1d731fe9f42f47437f3301a5a3bac4135f051746b6802040bc5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page