import json import aiohttp async def pay(amount, redirect, account, currency="RUB", description=""): """ amount - Amount in RUB, can be string account - Your PayAnyWay Business account number redirect - Redirect to (in any case) currency - Currency (default RUB) description - Description, can be empty Returns a dict with: url: string, a qr.nspk.ru URL transaction: int, Moneta.ru transaction ID id: int, Moneta.ru operation ID It might throw a random exception if you have issues with PayAnyWay or Moneta.ru fixed this :( """ async with aiohttp.ClientSession() as session: data = await ( await session.post( "https://moneta.ru/assistant.widget", data={ "MNT_ID": account, "MNT_CURRENCY_CODE": "RUB", "MNT_AMOUNT": str(round(float(amount), 2)), "MNT_SUCCESS_URL": redirect, "MNT_FAIL_URL": redirect, "MNT_RETURN_URL": redirect, "MNT_INPROGRESS_URL": redirect, "MNT_DESCRIPTION": description, "submit": "Pay order", }, ) ).text() lnk = data.split('const qrPayload = "')[-1].split('";')[0] return {"url": str(json.loads(f'"{lnk}"')), "transaction": int(data.split('?MNT_TRANSACTION_ID=')[-1].split('&')[0]), "id": int(data.split(';MNT_OPERATION_ID=')[-1].split('"')[0])}