# Telegram Wallet Pay
Python async client for [Telegram Wallet Pay API](https://pay.wallet.tg)
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](https://img.shields.io/pypi/pyversions/telegram-wallet-pay.svg)](https://pypi.org/project/telegram-wallet-pay/)
[![pypi](https://img.shields.io/pypi/v/telegram-wallet-pay?label=pypi%20package)](https://pypi.org/project/telegram-wallet-pay/)
[![Tests](https://github.com/Olegt0rr/TelegramWalletPay/actions/workflows/tests.yml/badge.svg)](https://github.com/Olegt0rr/TelegramWalletPay/actions/workflows/tests.yml)
[![Coverage](https://img.shields.io/codecov/c/github/Olegt0rr/TelegramWalletPay)](https://app.codecov.io/gh/Olegt0rr/TelegramWalletPay)
[![Code linter: ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v1.json)](https://github.com/charliermarsh/ruff)
[![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org)
[![Gitmoji](https://img.shields.io/badge/gitmoji-%20😎-FFDD67.svg)](https://gitmoji.dev)
---
## 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
```python
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
```python
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
* [Telegram bot example (aiogram)](https://github.com/Olegt0rr/TelegramWalletPay/blob/main/examples/02_telegram_bot.py)
* [Webhook handler example (FastAPI)](https://github.com/Olegt0rr/TelegramWalletPay/blob/main/examples/03_webhook_handler_fastapi.py)
* [Webhook handler example (aiohttp)](https://github.com/Olegt0rr/TelegramWalletPay/blob/main/examples/04_webhook_handler_aiohttp.py)
Also, feel free to open the
[folder with examples](https://github.com/Olegt0rr/TelegramWalletPay/tree/main/examples),
and if there is something missing there, describe your needs
in [issue](https://github.com/Olegt0rr/TelegramWalletPay/issues/new/choose).
Raw data
{
"_id": null,
"home_page": null,
"name": "telegram-wallet-pay",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": "Oleg Abramov <oleg@trueweb.app>",
"keywords": "API, Pay, Telegram, Wallet, async",
"author": null,
"author_email": "Oleg Abramov <oleg@trueweb.app>",
"download_url": "https://files.pythonhosted.org/packages/ca/69/b18e20496106bcf0156514728f77522ff884361f72b35b7338356a0032ed/telegram_wallet_pay-1.0.0.tar.gz",
"platform": null,
"description": "# Telegram Wallet Pay\n\nPython async client for [Telegram Wallet Pay API](https://pay.wallet.tg)\nmade of `aiohttp` and `pydantic`\n\n**Also contains:**\n\n- `pydantic` models for every schema, even for incoming webhooks\n- signature validation tools:\n - ready-made `Depends` for `FastAPI`\n - ready-made decorator for `aiohttp` server\n\n[![Python](https://img.shields.io/pypi/pyversions/telegram-wallet-pay.svg)](https://pypi.org/project/telegram-wallet-pay/)\n[![pypi](https://img.shields.io/pypi/v/telegram-wallet-pay?label=pypi%20package)](https://pypi.org/project/telegram-wallet-pay/)\n[![Tests](https://github.com/Olegt0rr/TelegramWalletPay/actions/workflows/tests.yml/badge.svg)](https://github.com/Olegt0rr/TelegramWalletPay/actions/workflows/tests.yml)\n[![Coverage](https://img.shields.io/codecov/c/github/Olegt0rr/TelegramWalletPay)](https://app.codecov.io/gh/Olegt0rr/TelegramWalletPay)\n\n[![Code linter: ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v1.json)](https://github.com/charliermarsh/ruff)\n[![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org)\n[![Gitmoji](https://img.shields.io/badge/gitmoji-%20\ud83d\ude0e-FFDD67.svg)](https://gitmoji.dev)\n---\n\n## Get started\n\n### Read Telegram Wallet Pay API docs\n\nhttps://docs.wallet.tg/pay/#section/Get-started\n\n### Install our library\n\n```\npip install telegram-wallet-pay\n```\n\n### Create order\n\n```python\nimport asyncio\nimport os\nfrom uuid import uuid4\n\nfrom telegram_wallet_pay import TelegramWalletPay\n\n# store TELEGRAM_WALLET_PAY_TOKEN to your .env\n# wallet token can be issued via https://pay.wallet.tg/\nTOKEN = os.getenv(\"TELEGRAM_WALLET_PAY_TOKEN\")\n\n\nasync def main() -> None:\n \"\"\"Create order.\"\"\"\n # create wallet client instance\n wallet = TelegramWalletPay(TOKEN)\n\n # create your first order\n response = await wallet.create_order(\n amount=40,\n currency_code=\"EUR\",\n description=\"TestPayment\",\n external_id=str(uuid4()),\n timeout_seconds=5 * 60,\n customer_telegram_user_id=66812456,\n )\n\n # let's print creation response\n print(\"Response:\", response)\n print(\"Order:\", response.data)\n\n # don't forget close API-client instance on your app shutdown\n await wallet.close()\n\n\nif __name__ == \"__main__\":\n asyncio.run(main())\n\n```\n\n### Get order preview\n\n```python\nimport asyncio\nimport os\n\nfrom telegram_wallet_pay import TelegramWalletPay\n\n# store TELEGRAM_WALLET_PAY_TOKEN to your .env\n# wallet token can be issued via https://pay.wallet.tg/\nTOKEN = os.getenv(\"TELEGRAM_WALLET_PAY_TOKEN\")\n\n\nasync def main() -> None:\n \"\"\"Get order preview.\"\"\"\n # create wallet client instance\n wallet = TelegramWalletPay(TOKEN)\n\n # get order preview\n response = await wallet.get_order_preview(\"<your-order-id>\")\n\n # let's print received response\n print(\"Response:\", response)\n print(\"Order Preview:\", response.data)\n\n # don't forget close API-client instance on your app shutdown\n await wallet.close()\n\n\nif __name__ == \"__main__\":\n asyncio.run(main())\n\n```\n\n## Other examples\n\n* [Telegram bot example (aiogram)](https://github.com/Olegt0rr/TelegramWalletPay/blob/main/examples/02_telegram_bot.py)\n* [Webhook handler example (FastAPI)](https://github.com/Olegt0rr/TelegramWalletPay/blob/main/examples/03_webhook_handler_fastapi.py)\n* [Webhook handler example (aiohttp)](https://github.com/Olegt0rr/TelegramWalletPay/blob/main/examples/04_webhook_handler_aiohttp.py)\n\nAlso, feel free to open the\n[folder with examples](https://github.com/Olegt0rr/TelegramWalletPay/tree/main/examples),\nand if there is something missing there, describe your needs\nin [issue](https://github.com/Olegt0rr/TelegramWalletPay/issues/new/choose).\n",
"bugtrack_url": null,
"license": null,
"summary": "Async client for Telegram Wallet Pay API",
"version": "1.0.0",
"project_urls": {
"Documentation": "https://docs.wallet.tg/pay/",
"Repository": "https://github.com/Olegt0rr/TelegramWalletPay"
},
"split_keywords": [
"api",
" pay",
" telegram",
" wallet",
" async"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "18249c953f77a1d731fe9f42f47437f3301a5a3bac4135f051746b6802040bc5",
"md5": "3e4499d5269fcff742de7149b2c09fed",
"sha256": "27cb79b642df978b55f7abad9903f961f6f0734a7ef1b81602e321cbac7e680d"
},
"downloads": -1,
"filename": "telegram_wallet_pay-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3e4499d5269fcff742de7149b2c09fed",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 20061,
"upload_time": "2024-10-10T07:24:46",
"upload_time_iso_8601": "2024-10-10T07:24:46.996609Z",
"url": "https://files.pythonhosted.org/packages/18/24/9c953f77a1d731fe9f42f47437f3301a5a3bac4135f051746b6802040bc5/telegram_wallet_pay-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ca69b18e20496106bcf0156514728f77522ff884361f72b35b7338356a0032ed",
"md5": "59f34dcde43a7aa213e485b2acff5fc1",
"sha256": "3cdf310d8281e24a4c805000695cce4be0c6c4f3fbbcf48a5eeb6110348165a3"
},
"downloads": -1,
"filename": "telegram_wallet_pay-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "59f34dcde43a7aa213e485b2acff5fc1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 21686,
"upload_time": "2024-10-10T07:24:48",
"upload_time_iso_8601": "2024-10-10T07:24:48.682469Z",
"url": "https://files.pythonhosted.org/packages/ca/69/b18e20496106bcf0156514728f77522ff884361f72b35b7338356a0032ed/telegram_wallet_pay-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-10 07:24:48",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Olegt0rr",
"github_project": "TelegramWalletPay",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "telegram-wallet-pay"
}