{"id":20975485,"url":"https://github.com/fsoky/crystalpayio","last_synced_at":"2025-09-05T07:35:01.908Z","repository":{"id":201080548,"uuid":"706675537","full_name":"Fsoky/crystalpayio","owner":"Fsoky","description":"Asynchronous wrapper for CrystalPay API","archived":false,"fork":false,"pushed_at":"2023-11-21T12:18:15.000Z","size":42,"stargazers_count":4,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-18T09:13:34.962Z","etag":null,"topics":["aiocrystalpay","api","asyncio","asyncio-api-wrapper","crystalpay","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Fsoky.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-10-18T12:15:14.000Z","updated_at":"2024-10-27T20:34:54.000Z","dependencies_parsed_at":"2023-10-19T11:40:04.720Z","dependency_job_id":"0d233510-942d-4f3b-acb6-cbf87365e53d","html_url":"https://github.com/Fsoky/crystalpayio","commit_stats":null,"previous_names":["fsoky/aiocrystalpay","fsoky/crystalpayio"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fsoky%2Fcrystalpayio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fsoky%2Fcrystalpayio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fsoky%2Fcrystalpayio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fsoky%2Fcrystalpayio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Fsoky","download_url":"https://codeload.github.com/Fsoky/crystalpayio/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225297639,"owners_count":17452010,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aiocrystalpay","api","asyncio","asyncio-api-wrapper","crystalpay","python"],"created_at":"2024-11-19T04:45:10.060Z","updated_at":"2024-11-19T04:45:10.628Z","avatar_url":"https://github.com/Fsoky.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n      \u003ca href=\"https://imgur.com/9t3fDgT\"\u003e\u003cimg src=\"https://i.imgur.com/9t3fDgT.png\" title=Logo\" width=\"500\"/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Version-1.0.5-blueviolet\" alt=\"Project Version\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/License-MIT-success\" alt=\"License\"\u003e\n\u003c/p\u003e\n\n## О библиотеке 💙\nБиблиотека **CrystalPayIO** предоставит удобное использование и интеграцию _[CrystalPay](https://crystalpay.io/) API_ в ваши проекты.\n\nВ данном репозитории вы найдете способы установки и использования библиотеки.\nЕсли вы обнаружите баги или какие-либо проблемы при использовании прошу отписать в [телеграм](https://t.me/fsoky_community). Данный модуль будет поддерживаться и обновляться. Спасибо, хорошего настроения!\n\u003e [!NOTE]\n\u003e Чтобы получить _AUTH_LOGIN_ \u0026 _AUTH_SECRET_ перейдите в [телеграм бота](https://t.me/CrystalPAY_bot) и создайте новую кассу. \\\n\u003e В настройках можете включить тестовые платежи.\n\u003e \n\u003e **Документация CrystalPAY:** https://docs.crystalpay.io/\n\n## Установка 🧡\n- Установка, используя пакетный менеджер pip\n```\n$ pip install crystalpayio\n```\n- Установка с GitHub *(требуется [git](https://git-scm.com/downloads))*\n```\n$ git clone https://github.com/Fsoky/crystalpayio\n$ cd crystalpayio\n$ python setup.py install\n```\n- Или\n```\n$ pip install git+https://github.com/Fsoky/crystalpayio\n```\n\n## Примеры использования 💜\n- Шаблон\n```py\nimport asyncio\nfrom crystalpayio import CrystalPayIO\n\n\nasync def main() -\u003e None:\n    async with CrystalPayIO(\"AUTH_LOGIN\", \"AUTH_SECRET\") as crystal:\n        ...\n\n\nif __name__ == \"__main__\":\n  asyncio.run(main())\n```\n- Доступные методы \\\n    `checkout` - Касса \\\n    `payment` - Платежи \\\n    `invoice` - Инвойсы (чеки) \\\n    `payoff` - Вывод средств \\\n    `ticker` - Доступные валюты и курс \\\n    `history` - История платежей/выводов/общая\n```py\nasync with CrystalPayIO(\"AUTH_LOGIN\", \"AUTH_SECRET\") as crystal:\n    # Каждый метод хранится в свойстве, например касса:\n    checkout = await crystal.checkout.me()\n```\n\n## Пример интеграции в телеграм-бота (aiogram 3.x) ❤\n```py\nimport asyncio\n\nfrom aiogram import Router, Bot, Dispatcher, F\nfrom aiogram.types import Message, CallbackQuery, InlineKeyboardMarkup, InlineKeyboardButton\nfrom aiogram.filters import CommandStart\n\nfrom crystalpayio import CrystalPayIO\n\nrouter = Router()\ncrystal = CrystalPayIO(\"AUTH_LOGIN\", \"AUTH_SECRET\")\n\n\nasync def create_invoice() -\u003e tuple:\n    invoice = await crystal.invoice.create(\n        100, # Цена\n        5, # Время жизни чека (в минутах)\n        amount_currency=\"RUB\" # Валюта\n    )\n    return (invoice.url, invoice.id)\n\n\nasync def invoice_handler(id: str, message: Message) -\u003e None:\n    while True:\n        invoice = await crystal.invoice.get(id)\n        \n        if invoice.state != \"notpayed\":\n            await message.answer(\"Счёт успешно оплачен!\")\n        await asyncio.sleep(15) # Задержка\n\n\n@router.message(CommandStart())\nasync def show_goods(message: Message) -\u003e None:\n    await message.answer(\n        \"🎃 Тыква - 100 РУБ.\",\n        reply_markup=InlineKeyboardMarkup(\n            inline_keyboard=[\n                [InlineKeyboardButton(text=\"КУПИТЬ\", callback_data=\"buy\")]\n            ]\n        )\n    )\n\n\n@router.callback_query(F.data == \"buy\")\nasync def buy_handler(query: CallbackQuery) -\u003e None:\n    invoice_task = asyncio.create_task(create_invoice())\n    invoice_result = await invoice_task\n\n    await query.message.answer(f\"Перейди по ссылке и оплати: {invoice_result[0]}\")\n    await query.answer()\n\n    asyncio.create_task(invoice_handler(invoice_result[1], query.message))\n\n\nasync def main() -\u003e None:\n    bot = Bot(\"TOKEN\")\n    dp = Dispatcher()\n\n    dp.include_router(router)\n\n    await bot.delete_webhook(True)\n    await dp.start_polling(bot)\n\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n```\n\n## Пример использования Webhook'ов 🕸\n```py\nimport asyncio\n\nfrom crystalpayio import CrystalPayIO, WebhookManager, PaymentEvent\n\nfrom fastapi import FastAPI # pip install fastapi[all]\nimport uvicorn # pip install uvicorn\n\nWEBHOOK_URL = \"https://xxx-xxx-xxx.ngrok-free.app\" # ngrok url\nWEBHOOK_ENDPOINT = \"/my-endpoint\"\n\napp = FastAPI()\ncrystal = CrystalPayIO(\"AUTH_LOGIN\", \"AUTH_SECRET\")\nwm = WebhookManager(app)\n\nwm.register_webhook_endpoint(WEBHOOK_ENDPOINT) # Регистрируем путь к вебхуку\n\n\n@wm.successfull_payment()\nasync def handle_successfull_event(event: PaymentEvent) -\u003e None:\n    print(event)\n\n\nasync def create_invoice() -\u003e None:\n    order = await crystal.invoice.create(\n        10, # Сумма (в рублях)\n        5, # Время жизни чека (в минутах)\n        callback_url=f\"{WEBHOOK_URL}{WEBHOOK_ENDPOINT}\"\n    )\n    print(order.url)\n\n\nif __name__ == \"__main__\":\n    asyncio.run(create_invoice()) # Запуск функции\n    uvicorn.run(\"test:app\")\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffsoky%2Fcrystalpayio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffsoky%2Fcrystalpayio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffsoky%2Fcrystalpayio/lists"}