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.5.0.tar.gz
(14.4 kB
view hashes)
Built Distribution
Close
Hashes for telegram_wallet_pay-0.5.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86276b5359e00f654076f15d10ed6539fca86c5d1e5ca17e265d20fb547cfb80 |
|
MD5 | ce9076b92959e87ff6231d59336107cf |
|
BLAKE2b-256 | b23aabb2a20f035557d07d94f3fd274fd66e0533fbdb9b1de0b2fcb2ad3c8ad2 |
Close
Hashes for telegram_wallet_pay-0.5.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d37f49891779e0b84e88b3bbea981e4ceb66ba681244e5940c63e85bd57c010 |
|
MD5 | 29f8eba0c04d62d5e931e23554c207ef |
|
BLAKE2b-256 | f8cc7a843642de00c096487f8325518bfb06d3228304f9a73ad5ceed5972d5ee |