pip install walletpay-sdk
import asyncio
from uuid import uuid4
from aiogram import Bot
from aiogram.types import InlineKeyboardButton, InlineKeyboardMarkup
from walletpay import Client
CUSTOMER_TELEGRAM_ID = 133777888
async def main():
api = Client("YoUrApIKey")
bot = Bot("1294789:YourBoTKey")
# Create order
order = await api.create_order(
"0.001",
external_id=str(uuid4()),
customer_telegram_user_id=CUSTOMER_TELEGRAM_ID,
description="Support me",
timeout_seconds=60,
)
# Send order to user
await bot.send_message(
CUSTOMER_TELEGRAM_ID,
"Pay",
reply_markup=InlineKeyboardMarkup(
inline_keyboard=[
[
InlineKeyboardButton(
text="👛 Pay via Wallet",
url=order.data.payLink,
)
]
]
)
)
await api.session.close()
await bot.session.close()
asyncio.run(main())
- Python >= 3.11
- Clone repo
- Install with dev dependencies
poetry install --with dev
- From the root dir run
pytest tests
- Clone repo
- Run
poetry install --group examples
- Add env vars:
3.1 Add WP_TEST_KEY with your API key
3.2 (FOR bot.py) Add WP_BOT_TOKEN with bot token bound to your api - Go to examples folder and run them like regular python scripts
WARNING! For development purposes only!
To run webhook example you need dedicated IP address
You can use ngrok to test your application:
- Download ngrok and log in
- Run
ngrok http 80
- Copy your temporary IP address
- Paste it in your merchant settings
- !AFTER DEVELOPMENT DON'T FORGET TO REMOVE ADDRESS IN WALLETPAY WEBHOOK SETTINGS PROVIDED FROM NGROK!