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
# 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
telegram_wallet_pay-0.8.1.tar.gz
(20.9 kB
view hashes)
Built Distribution
Close
Hashes for telegram_wallet_pay-0.8.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26958605d68a0ab18e5473729da4ba7c6dfbea985cde7a7f288a44e7919b1a67 |
|
MD5 | 3dbff89fbf89445a9c3d8b154f1074e7 |
|
BLAKE2b-256 | 49c9793e81756167bf8dd735a6aa3201dbcf3b54afd237396877169ce3a97dca |
Close
Hashes for telegram_wallet_pay-0.8.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec36bf38b9ea7907f2622a4a16cf9a510e815597c3853881bc9e51baeb53836c |
|
MD5 | 118df6f7e443b736104a9c1383440f52 |
|
BLAKE2b-256 | 7b59d0a8cd435efa3c4d452c5afb2fad9cc0fb243cb087863a4606afe08b075b |