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:
pydanticmodels for every schema, even for incoming webhooks- signature validation tools:
- ready-made
DependsforFastAPI - ready-made decorator for
aiohttpserver
- ready-made
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3cdf310d8281e24a4c805000695cce4be0c6c4f3fbbcf48a5eeb6110348165a3
|
|
| MD5 |
59f34dcde43a7aa213e485b2acff5fc1
|
|
| BLAKE2b-256 |
ca69b18e20496106bcf0156514728f77522ff884361f72b35b7338356a0032ed
|
File details
Details for the file telegram_wallet_pay-1.0.0-py3-none-any.whl.
File metadata
- Download URL: telegram_wallet_pay-1.0.0-py3-none-any.whl
- Upload date:
- Size: 20.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27cb79b642df978b55f7abad9903f961f6f0734a7ef1b81602e321cbac7e680d
|
|
| MD5 |
3e4499d5269fcff742de7149b2c09fed
|
|
| BLAKE2b-256 |
18249c953f77a1d731fe9f42f47437f3301a5a3bac4135f051746b6802040bc5
|