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 tool, including ready-made
Depends
forFastAPI
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
# use your token from https://pay.wallet.tg/
TOKEN = os.getenv("TELEGRAM_WALLET_PAY_TOKEN")
async def main() -> None:
"""Create order."""
wallet = TelegramWalletPay(TOKEN)
# create your first order
response = await wallet.create_order(
amount=40,
currency_code="RUB",
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
TOKEN = os.getenv("TELEGRAM_WALLET_PAY_TOKEN")
async def main() -> None:
"""Get order preview."""
wallet = TelegramWalletPay(TOKEN)
response = await wallet.get_order_preview("<your-order-id>")
print("Response:", response)
print("Order Preview:", response.data)
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
telegram_wallet_pay-0.4.1.tar.gz
(13.8 kB
view hashes)
Built Distribution
Close
Hashes for telegram_wallet_pay-0.4.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6089719dcff860a53a448ba5da9506514ba05ed3b9b9894fd63a0e908e69d9e2 |
|
MD5 | bc39d7f07c32eb27f1ef98fcc2b67b21 |
|
BLAKE2b-256 | 63494abed9c331f88f3d3df02ca4c59a46b62c5ee0039e93f7dbbfad0e0a29c4 |
Close
Hashes for telegram_wallet_pay-0.4.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8be8c48328e31d27781b353fd322eabb745b70f49ca62cabd9a7698da56d6494 |
|
MD5 | 744867e2806925774d38a5ce996d220f |
|
BLAKE2b-256 | 8f24e4e90201263b634ad0407c920fcecdf7e87ae40f673094c6f4ff4021041f |