Exemple #1
0
from aiohttp.web import Application

from aioqiwi.kassa import QiwiKassa, BillUpdate
from aioqiwi.wallet import Wallet, QiwiUpdate
from aioqiwi.utils import BeautifulSum

qiwi = Wallet("api_hash from qiwi.com/api")
kassa = QiwiKassa("secret_key from p2p.qiwi.com")


@qiwi.on_update()
async def payment_handler(payment: QiwiUpdate):
    print(BeautifulSum(payment.Payment.Sum).pretty)


@kassa.on_update()
async def kassa_update(bill: BillUpdate):
    print(BeautifulSum(bill.Bill.Amount).pretty)


async def caren():
    lifetime = 30  # days

    await qiwi.transaction(14.88, "*****@*****.**")

    bill = await kassa.new_bill(
        14.88,
        "7787787787",
        "*****@*****.**"
        "com",
        lifetime=lifetime,
Exemple #2
0
Before running install aiogram, cool telegram bot-api wrapper
    ::

        pip install aiogram

"""
import asyncio

from aiogram import Bot
from aioqiwi.wallet import Wallet, WebHook

ME = 124191486  # your telegram user id

loop = asyncio.get_event_loop()

qiwi = Wallet("MyQiwiToken", loop=loop)
bot = Bot("MyBotToken", validate_token=False)


@qiwi.hm()
async def special_payments_handler(event: WebHook):
    payment = event.payment
    text = f":D Woop-woop! {payment.account} sent you {payment.sum.amount}\n"

    await bot.send_message(chat_id=ME, text=text)


async def on_startup():
    # change hooks if you want
    # info = await qiwi.new_hooks("http://myNewWebHooksUrl.com", 2)
    info = await qiwi.hooks()
Exemple #3
0
import asyncio
import logging
import datetime

from aioqiwi.contrib import history_polling
from aioqiwi.wallet import Wallet, types

logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)

loop = asyncio.get_event_loop()
wallet = Wallet(api_hash="...", loop=loop, phone_number="+...")
poller = history_polling.HistoryPoll(
    wallet,
    timeout=10,
    from_date=datetime.datetime.now() - datetime.timedelta(days=30),
    limit=5,
    process_old_to_new=True,
)


@wallet.hm()
async def my_handler(event: types.PaymentData):
    print(event)


async def main():
    async def on_error(exception: asyncio.TimeoutError):
        logger.info(f"... hI {exception!s} Hi ...")
        print("Oops. Just got timeout error. Shall we sleep for a bit?")
        await asyncio.sleep(14.44)
Exemple #4
0
"""

Before running install aiogram, cool telegram bot-api wrapper
    ::

        pip install aiogram

"""
from aiogram import Bot

from aioqiwi.utils import BeautifulSum
from aioqiwi.wallet import Wallet, QiwiUpdate

ME = 124191486  # your telegram user id

qiwi = Wallet("token from qiwi")
bot = Bot("telegram bot token", parse_mode="markdown")


@qiwi.on_update(incoming=True)
async def new_payment(event: QiwiUpdate):
    payment = event.Payment
    text = f":D Woop-woop! {payment.account} sent you {BeautifulSum(payment.Sum).humanize}\n"
    text += f"Commentary: {payment.comment}" if payment.comment else ""

    await bot.send_message(ME, text)


async def on_startup():
    await bot.send_message(ME, "Bot is starting")
Exemple #5
0
"""
Before running install aiogram, cool telegram bot-api wrapper
"""
from aioqiwi.wallet import Wallet, QiwiUpdate
from aioqiwi.utils import BeautifulSum

from aiogram import Bot, Dispatcher, types
from aiogram.utils import markdown

ME = 124191486  # your telegram user id

qiwi = Wallet("qiwiToken")
bot = Bot("telegramBotToken", parse_mode="markdown")
disp = Dispatcher(bot)


@qiwi.on_update(incoming=True)
async def new_payment(event: QiwiUpdate):
    payment = event.Payment
    text = f":D Woop-woop! {payment.account} sent you {BeautifulSum(payment.Sum).humanize}\n"
    text += f"Commentary: {payment.comment}" if payment.comment else ""

    await bot.send_message(ME, text)


@disp.message_handler(commands=["send"], prefix="./!")
@disp.message_handler(regexp=r"^.send \d*\.?\d* (\(?\+?[0-9]*\)?)?[0-9_\- \(\)] .*")
async def send_money(event: types.Message):
    # process text with pattern: .send amount_float receiver_phone_number comments
    cmd, amount, peer, comment = event.text.split(maxsplit=3)
Exemple #6
0
import asyncio
import logging

from aiogram import Bot, types

import api
import config
import utils
from aioqiwi.wallet import QiwiUpdate, Wallet

logging.basicConfig(level=logging.DEBUG)

bot = Bot(token=config.token, parse_mode='HTML')
wallet = Wallet(api_hash=config.api_hash)
wallet.as_model = False
server_ip = utils.get_ip()
server_port = 7494
server_path = '/webhooks/qiwi/'
hook_url = f'http://{server_ip}:{server_port}{server_path}'


@wallet.on_update(incoming=True)
async def got_payment(event: QiwiUpdate):
    currency = event.Payment.Total.currency
    if currency != 643 and currency in config.allowed_currencies:
        in_rub = await utils.convert(event.Payment.Total.amount,
                                     config.allowed_currencies[currency])
    else:
        in_rub = event.Payment.Total.amount
    if event.Payment.comment.isdigit():
        user_id = int(event.Payment.comment)
Exemple #7
0
from aioqiwi.wallet import Wallet, types, enums
from aioqiwi.core.currencies import Currency

wallet = Wallet("api-key", phone_number="phone-number")


async def main():
    # using context manager to close wallet connector after we finish
    async with wallet:
        payment_type = types.P2PPayment(
            id=None,
            sum=types.payment.Sum(
                amount=0.18,
                currency=Currency.get("RUB").isoformat
            ),
            comment="hEy_IaM_uSiNg_AiOqIwI",
            paymentMethod=enums.PaymentMethodConst,
            fields=types.Fields(
                account="RECEIVER\'S PHONE NUMBER"
            )
        )

        txn = await wallet.transaction(
            provider_id=enums.Provider.QIWI_WALLET,
            payment_type=payment_type
        )

        print(txn)
import asyncio

from aiohttp.web import Application

from aioqiwi.kassa import QiwiKassa, Notification
from aioqiwi.wallet import Wallet, WebHook, types, enums
from aioqiwi.core.currencies import Currency

loop = asyncio.get_event_loop()
qiwi = Wallet("api_hash from qiwi.com/api", loop=loop)  #
kassa = QiwiKassa("secret_key from p2p.qiwi.com", loop=loop)  #


@qiwi.hm()
async def payment_handler(payment: WebHook):
    print(payment.payment.sum)


@kassa.hm()
async def kassa_update(bill: Notification):
    print(bill.bill.amount)


async def caren():
    lifetime = 30  # days

    await qiwi.transaction(
        provider_id=enums.Provider.QIWI_WALLET.value,
        payment_type=types.P2PPayment(
            id=None,
            sum=types.payment.Sum(