aiomoney


Nameaiomoney JSON
Version 3.0.1 PyPI version JSON
download
home_pageNone
SummaryПростая асинхронная библиотека для работы с API ЮMoney
upload_time2024-12-04 19:48:51
maintainerNone
docs_urlNone
authorfofmow
requires_python<4.0,>=3.12
licenseMIT
keywords yoomoney python async
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # aiomoney — простая асинхронная библиотека для работы с API ЮMoney

### Авторизация приложения

1. Зарегистрируйте новое приложение YooMoney по ссылке https://yoomoney.ru/myservices/new
   (без указания чекбокса OAuth2!).
2. Получите и скопируйте `client_id` после создания приложения
3. Создайте запрос на получение api-токена.
   [О правах приложения](https://yoomoney.ru/docs/wallet/using-api/authorization/protocol-rights)

   ```python
   import asyncio
   from aiomoney import authorize_app
   
   
   async def main():
       await authorize_app(
           client_id="YOUR_CLIENT_ID",
           redirect_uri="YOUR_REDIRECT_URI",
           app_permissions=[
               "account-info",
               "operation-history",
               "operation-details",
               "incoming-transfers",
               "payment-p2p",
               "payment-shop",
           ]
       )
   
   
   if __name__ == "__main__":
       asyncio.run(main())
   ```

4. Во время перенаправления по `redirect_uri` в адресной строке появится параметр `code=`.
   Скопируйте значение и вставьте его в консоль
5. Если авторизация прошла успешно, в консоли отобразится Ваш api-token.
   Сохраните его в переменную окружения

### Получение основной информации об аккаунте

```python
import asyncio
from collections import deque

from aiomoney import YooMoney
from aiomoney.schemas import AccountInfo, Operation, OperationDetails


async def main():
    account = YooMoney(access_token="ACCESS_TOKEN")

    account_info: AccountInfo = await account.account_info
    operation_history: deque[Operation] = await account.get_operation_history()
    operation_details: OperationDetails = await account.get_operation_details(operation_id="999")

    print(account_info, operation_history, operation_details, sep="\n\n")


if __name__ == "__main__":
    asyncio.run(main())
```

### Создание платёжной формы и проверка оплаты

```python
import asyncio

from aiomoney import YooMoney
from aiomoney.schemas import InvoiceSource


async def main():
    wallet = YooMoney(access_token="ACCESS_TOKEN")

    payment_form = await wallet.create_invoice(
        amount_rub=990,
        label="abcdefg",
        payment_source=InvoiceSource.YOOMONEY_WALLET,
        success_redirect_url="https://t.me/fofmow (nonono =/)"
    )
    # проверка платежа по label
    is_paid: bool = await wallet.is_payment_successful(payment_form.label)

    print(f"Ссылка на оплату:\n{payment_form.url}\n\n"
          f"Форма оплачена: {'Да' if is_paid else 'Нет'}")


if __name__ == "__main__":
    asyncio.run(main())

```

## Если библиотека полезна для вас - [Donates ❤️](https://yoomoney.ru/fundraise/16P5TIMSNLK.241127)



            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "aiomoney",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.12",
    "maintainer_email": null,
    "keywords": "yoomoney, python, async",
    "author": "fofmow",
    "author_email": "fofmow@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/26/45/0d71d04f747bbceb30dbdaa4b11e3b13394473174233b7c7e7d096ffee39/aiomoney-3.0.1.tar.gz",
    "platform": null,
    "description": "# aiomoney \u2014 \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 API \u042eMoney\n\n### \u0410\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\n\n1. \u0417\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0439\u0442\u0435 \u043d\u043e\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 YooMoney \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 https://yoomoney.ru/myservices/new\n   (\u0431\u0435\u0437 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0447\u0435\u043a\u0431\u043e\u043a\u0441\u0430 OAuth2!).\n2. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0438 \u0441\u043a\u043e\u043f\u0438\u0440\u0443\u0439\u0442\u0435 `client_id` \u043f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\n3. \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 api-\u0442\u043e\u043a\u0435\u043d\u0430.\n   [\u041e \u043f\u0440\u0430\u0432\u0430\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f](https://yoomoney.ru/docs/wallet/using-api/authorization/protocol-rights)\n\n   ```python\n   import asyncio\n   from aiomoney import authorize_app\n   \n   \n   async def main():\n       await authorize_app(\n           client_id=\"YOUR_CLIENT_ID\",\n           redirect_uri=\"YOUR_REDIRECT_URI\",\n           app_permissions=[\n               \"account-info\",\n               \"operation-history\",\n               \"operation-details\",\n               \"incoming-transfers\",\n               \"payment-p2p\",\n               \"payment-shop\",\n           ]\n       )\n   \n   \n   if __name__ == \"__main__\":\n       asyncio.run(main())\n   ```\n\n4. \u0412\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e `redirect_uri` \u0432 \u0430\u0434\u0440\u0435\u0441\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 `code=`.\n   \u0421\u043a\u043e\u043f\u0438\u0440\u0443\u0439\u0442\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438 \u0432\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0435\u0433\u043e \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c\n5. \u0415\u0441\u043b\u0438 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0448\u043b\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e, \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u0441\u044f \u0412\u0430\u0448 api-token.\n   \u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u0435 \u0435\u0433\u043e \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f\n\n### \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e\u0431 \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0435\n\n```python\nimport asyncio\nfrom collections import deque\n\nfrom aiomoney import YooMoney\nfrom aiomoney.schemas import AccountInfo, Operation, OperationDetails\n\n\nasync def main():\n    account = YooMoney(access_token=\"ACCESS_TOKEN\")\n\n    account_info: AccountInfo = await account.account_info\n    operation_history: deque[Operation] = await account.get_operation_history()\n    operation_details: OperationDetails = await account.get_operation_details(operation_id=\"999\")\n\n    print(account_info, operation_history, operation_details, sep=\"\\n\\n\")\n\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n```\n\n### \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u043b\u0430\u0442\u0451\u0436\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u044b \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043e\u043f\u043b\u0430\u0442\u044b\n\n```python\nimport asyncio\n\nfrom aiomoney import YooMoney\nfrom aiomoney.schemas import InvoiceSource\n\n\nasync def main():\n    wallet = YooMoney(access_token=\"ACCESS_TOKEN\")\n\n    payment_form = await wallet.create_invoice(\n        amount_rub=990,\n        label=\"abcdefg\",\n        payment_source=InvoiceSource.YOOMONEY_WALLET,\n        success_redirect_url=\"https://t.me/fofmow (nonono =/)\"\n    )\n    # \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u043b\u0430\u0442\u0435\u0436\u0430 \u043f\u043e label\n    is_paid: bool = await wallet.is_payment_successful(payment_form.label)\n\n    print(f\"\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u043f\u043b\u0430\u0442\u0443:\\n{payment_form.url}\\n\\n\"\n          f\"\u0424\u043e\u0440\u043c\u0430 \u043e\u043f\u043b\u0430\u0447\u0435\u043d\u0430: {'\u0414\u0430' if is_paid else '\u041d\u0435\u0442'}\")\n\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n\n```\n\n## \u0415\u0441\u043b\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043f\u043e\u043b\u0435\u0437\u043d\u0430 \u0434\u043b\u044f \u0432\u0430\u0441 - [Donates \u2764\ufe0f](https://yoomoney.ru/fundraise/16P5TIMSNLK.241127)\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "\u041f\u0440\u043e\u0441\u0442\u0430\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 API \u042eMoney",
    "version": "3.0.1",
    "project_urls": {
        "homepage": "https://github.com/fofmow/aiomoney",
        "repository": "https://github.com/fofmow/aiomoney"
    },
    "split_keywords": [
        "yoomoney",
        " python",
        " async"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a8ec7f594edf0a283f0d359ab736f3a6142e686d3204fa893103b5c91e5a1469",
                "md5": "78dde09661fdb598e2248c448a978acc",
                "sha256": "f3eae599e82f5ef5a0189e7272b4df73c1bb70dee8dd8f47ce1b8032fee6a931"
            },
            "downloads": -1,
            "filename": "aiomoney-3.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "78dde09661fdb598e2248c448a978acc",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.12",
            "size": 8072,
            "upload_time": "2024-12-04T19:48:50",
            "upload_time_iso_8601": "2024-12-04T19:48:50.361571Z",
            "url": "https://files.pythonhosted.org/packages/a8/ec/7f594edf0a283f0d359ab736f3a6142e686d3204fa893103b5c91e5a1469/aiomoney-3.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "26450d71d04f747bbceb30dbdaa4b11e3b13394473174233b7c7e7d096ffee39",
                "md5": "ebd15b7d03d4cc9fa36cca63f0fb22db",
                "sha256": "0aa9e197940de54d2288760bfabb0402ac93308ec946876ee71da2481507b4fa"
            },
            "downloads": -1,
            "filename": "aiomoney-3.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "ebd15b7d03d4cc9fa36cca63f0fb22db",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.12",
            "size": 6159,
            "upload_time": "2024-12-04T19:48:51",
            "upload_time_iso_8601": "2024-12-04T19:48:51.623687Z",
            "url": "https://files.pythonhosted.org/packages/26/45/0d71d04f747bbceb30dbdaa4b11e3b13394473174233b7c7e7d096ffee39/aiomoney-3.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-04 19:48:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "fofmow",
    "github_project": "aiomoney",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "aiomoney"
}
        
Elapsed time: 0.39457s