Qiwi payments for humans(for healthy humans)
Supports most of qiwi apis: qiwi-maps, bills, wallet
pip install "https://github.com/uwinx/aioqiwi/archive/master.zip"
aioqiwi uses only aiohttp
and that's enough, but in case you want increase perfomance of serialization and deserialization, you can install ujson
or rapidjson
aioqiwi is a convenient tool with one-night solved architecture and its models generated from API-docs
import asyncio
from aioqiwi import Wallet
from aioqiwi.utils import BeautifulSum
async def qiwi():
async with Wallet("TOKEN from https://qiwi.com/api") as wallet:
wallet.phone_number = '+7878787878' # phone number is not required by default, but some methods need it
balance = await wallet.balance()
print("ACCOUNTS:")
for acc in balance.Accounts:
print(acc.alias, BeautifulSum(acc.Balance).pretty)
asyncio.run(qiwi())
aioqiwi provides user-friendly webhooks handler
from aioqiwi.wallet import QiwiUpdate, Wallet
from aioqiwi.utils import BeautifulSum
wallet = Wallet("...")
@wallet.on_update(incoming=True)
async def payments_handler(event: QiwiUpdate):
print(f"{event.Payment.account} sent you {BeautifulSum(event.Payment).pretty}")
@wallet.on_update(incoming=True, comment_regex=r"^(special_code|another_special_code)+$")
async def secret_payments_handler(event: QiwiUpdate):
print("*tovarish mayor suspiciously*",
f"- WHO THE HECK IS `{event.Payment.account}`, HOW DID HE GET OUR CODE?",
sep="\n",)
wallet.idle(port=6969)
import asyncio
from aioqiwi import Wallet
from aioqiwi.utils import BeautifulSum
async def txn():
async with Wallet('...') as wallet:
payment = await wallet.transaction(14.88, '+7899966669')
print(BeautifulSum(payment.Sum).pretty)
asyncio.run(txn())
Cool qiwi bills!
import asyncio
from aioqiwi import QiwiKassa
async def kassa():
async with QiwiKassa("SECRET KEY from p2p.qiwi.com or kassa.qiwi.com") as kassa:
sent_invoice = await kassa.new_bill(14.88, lifetime=44)
# setting lifetime to 44 ahead today [default is 10] 45 - is max
print("Url to pay:", sent_invoice.pay_url)
asyncio.run(kassa())
sent_invoice.pay_url will redirect us to something like:
from aioqiwi.kassa import QiwiKassa, BillUpdate
kassa = QiwiKassa('PRIVATE_KEY')
@kassa.on_update(lambda bill: bill.Bill.Amount.currency == 'RUB')
async def my_shiny_rubles_handler(bill_update: BillUpdate):
# do something
pass
kassa.idle()
aioqiwi covers qiwi's MAPS api in aioqiwi.terminals module
import asyncio
from aioqiwi import Wallet
async def json():
async with Wallet('...') as wallet:
wallet.as_model = False
print(await wallet.balance())
asyncio.run(json())
You can find examples in examples/
directory in github repository. For start examples above should be enough.
It'd great if you issue some design components. Meantime api-designs are awful, I know.
- Error handling 🔥
- Tests 🔥
- Documentation
My group