plategaio


Nameplategaio JSON
Version 1.0.4 PyPI version JSON
download
home_pageNone
SummaryA simple and unofficial SDK for the Platega.io API.
upload_time2025-10-21 18:15:22
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT License Copyright (c) [2025] [ploki1337] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords platega plategaio api sdk payment async asyncio httpx
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 🟢 Platega Async SDK (Unofficial)

[![PyPI](https://img.shields.io/pypi/v/plategaio-async.svg)](https://pypi.org/project/plategaio/)
[![Python](https://img.shields.io/pypi/pyversions/plategaio-async.svg)](https://pypi.org/project/plategaio/)
[![License](https://img.shields.io/pypi/l/plategaio-async.svg)](https://github.com/ploki1337/plategaio/blob/main/LICENSE)

> 🛠️ A modern, unofficial **asynchronous** Python SDK for the [Platega.io](https://platega.io) API.  
> Built with `httpx` and `Pydantic` for high performance in async applications like `aiogram`, `FastAPI`, or `Django Ninja`.

---

## ✨ Features

-   **Fully Asynchronous**: Built with `httpx` to be non-blocking and perfect for modern async frameworks.
-   **Type-Safe**: Strict request/response validation with Pydantic V2 ensures your code is robust.
-   **Secure by Default**: Includes a helper to verify webhook signatures, protecting you from fake callbacks.
-   **Clean API**: A minimalistic and intuitive interface for creating transactions, fetching statuses, and getting rates.
-   **Robust Error Handling**: Clear, custom exceptions for network and API errors.
-   **Resource Management**: Uses an async context manager (`async with`) to handle client sessions gracefully.
-   **Modern Python**: Supports Python 3.8+.

---

## 📦 Installation

```bash
pip install plategaio
```

---

## 🚀 Quick Start

The client is designed to be used as an asynchronous context manager.

```python
import asyncio
from uuid import uuid4
from plategaio import (
    PlategaAsyncClient,
    CreateTransactionRequest,
    PaymentDetails,
    PlategaAPIError,
)

async def main():
    async with PlategaAsyncClient(
        merchant_id="YOUR_MERCHANT_ID",
        secret="YOUR_SECRET_KEY",
    ) as client:
        try:
            tx_request = CreateTransactionRequest(
                payment_method=2, # SBP
                id=uuid4(),
                payment_details=PaymentDetails(amount=150.50, currency="RUB"),
                description="Order #123",
                return_url="https://your.site/success",
                failed_url="https://your.site/failed",
            )
            tx_response = await client.create_transaction(tx_request)
            print(f"Redirect user to: {tx_response.redirect}")
            
            status = await client.get_transaction_status(tx_response.transaction_id)
            print(f"Transaction status: {status.status}")

            rate = await client.get_rate(
                payment_method=2, 
                currency_from="USDT", 
                currency_to="RUB"
            )
            print(f"Current USDT->RUB rate: {rate.rate}")

        except PlategaAPIError as e:
            print(f"API Error: {e.status_code} - {e.message}")
        except Exception as e:
            print(f"An unexpected error occurred: {e}")

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

---

## ⚠️ Error Handling

The SDK raises clear, specific exceptions:

-   `PlategaError`: Base exception for the library.
-   `PlategaNetworkError`: Raised for network issues like timeouts or connection errors.
-   `PlategaAPIError`: Raised for non-2xx API responses (e.g., 400, 401, 500). It contains `status_code`, `message`, and `response_body`.

Example:

```python
from plategaio import PlategaAPIError, PlategaNetworkError

try:
    # ... your API call
except PlategaAPIError as e:
    print(f"API returned an error: status={e.status_code}, message='{e.message}'")
except PlategaNetworkError as e:
    print(f"A network error occurred: {e}")
```

---

## 📚 API Reference

### `PlategaAsyncClient`

-   `async create_transaction(payload: CreateTransactionRequest) -> CreateTransactionResponse`
-   `async get_transaction_status(transaction_id: str) -> TransactionStatusResponse`
-   `async get_rate(payment_method: int, currency_from: str, currency_to: str) -> RateResponse`
-   `async close()`: Closes the client session. Called automatically when using `async with`.

---

## 🌍 Links

-   📦 [PyPI](https://pypi.org/project/plategaio/)
-   💻 [Source Code](https://github.com/ploki1337/plategaio)
-   🔗 [Platega.io](https://platega.io)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "plategaio",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "platega, plategaio, api, sdk, payment, async, asyncio, httpx",
    "author": null,
    "author_email": "ploki1337 <ploki1337@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/2e/50/2899362a08a9ae0a1aec09d9aca22423c38acdd43981c8fca64573d21763/plategaio-1.0.4.tar.gz",
    "platform": null,
    "description": "# \ud83d\udfe2 Platega Async SDK (Unofficial)\r\n\r\n[![PyPI](https://img.shields.io/pypi/v/plategaio-async.svg)](https://pypi.org/project/plategaio/)\r\n[![Python](https://img.shields.io/pypi/pyversions/plategaio-async.svg)](https://pypi.org/project/plategaio/)\r\n[![License](https://img.shields.io/pypi/l/plategaio-async.svg)](https://github.com/ploki1337/plategaio/blob/main/LICENSE)\r\n\r\n> \ud83d\udee0\ufe0f A modern, unofficial **asynchronous** Python SDK for the [Platega.io](https://platega.io) API.  \r\n> Built with `httpx` and `Pydantic` for high performance in async applications like `aiogram`, `FastAPI`, or `Django Ninja`.\r\n\r\n---\r\n\r\n## \u2728 Features\r\n\r\n-   **Fully Asynchronous**: Built with `httpx` to be non-blocking and perfect for modern async frameworks.\r\n-   **Type-Safe**: Strict request/response validation with Pydantic V2 ensures your code is robust.\r\n-   **Secure by Default**: Includes a helper to verify webhook signatures, protecting you from fake callbacks.\r\n-   **Clean API**: A minimalistic and intuitive interface for creating transactions, fetching statuses, and getting rates.\r\n-   **Robust Error Handling**: Clear, custom exceptions for network and API errors.\r\n-   **Resource Management**: Uses an async context manager (`async with`) to handle client sessions gracefully.\r\n-   **Modern Python**: Supports Python 3.8+.\r\n\r\n---\r\n\r\n## \ud83d\udce6 Installation\r\n\r\n```bash\r\npip install plategaio\r\n```\r\n\r\n---\r\n\r\n## \ud83d\ude80 Quick Start\r\n\r\nThe client is designed to be used as an asynchronous context manager.\r\n\r\n```python\r\nimport asyncio\r\nfrom uuid import uuid4\r\nfrom plategaio import (\r\n    PlategaAsyncClient,\r\n    CreateTransactionRequest,\r\n    PaymentDetails,\r\n    PlategaAPIError,\r\n)\r\n\r\nasync def main():\r\n    async with PlategaAsyncClient(\r\n        merchant_id=\"YOUR_MERCHANT_ID\",\r\n        secret=\"YOUR_SECRET_KEY\",\r\n    ) as client:\r\n        try:\r\n            tx_request = CreateTransactionRequest(\r\n                payment_method=2, # SBP\r\n                id=uuid4(),\r\n                payment_details=PaymentDetails(amount=150.50, currency=\"RUB\"),\r\n                description=\"Order #123\",\r\n                return_url=\"https://your.site/success\",\r\n                failed_url=\"https://your.site/failed\",\r\n            )\r\n            tx_response = await client.create_transaction(tx_request)\r\n            print(f\"Redirect user to: {tx_response.redirect}\")\r\n            \r\n            status = await client.get_transaction_status(tx_response.transaction_id)\r\n            print(f\"Transaction status: {status.status}\")\r\n\r\n            rate = await client.get_rate(\r\n                payment_method=2, \r\n                currency_from=\"USDT\", \r\n                currency_to=\"RUB\"\r\n            )\r\n            print(f\"Current USDT->RUB rate: {rate.rate}\")\r\n\r\n        except PlategaAPIError as e:\r\n            print(f\"API Error: {e.status_code} - {e.message}\")\r\n        except Exception as e:\r\n            print(f\"An unexpected error occurred: {e}\")\r\n\r\nif __name__ == \"__main__\":\r\n    asyncio.run(main())\r\n```\r\n\r\n---\r\n\r\n## \u26a0\ufe0f Error Handling\r\n\r\nThe SDK raises clear, specific exceptions:\r\n\r\n-   `PlategaError`: Base exception for the library.\r\n-   `PlategaNetworkError`: Raised for network issues like timeouts or connection errors.\r\n-   `PlategaAPIError`: Raised for non-2xx API responses (e.g., 400, 401, 500). It contains `status_code`, `message`, and `response_body`.\r\n\r\nExample:\r\n\r\n```python\r\nfrom plategaio import PlategaAPIError, PlategaNetworkError\r\n\r\ntry:\r\n    # ... your API call\r\nexcept PlategaAPIError as e:\r\n    print(f\"API returned an error: status={e.status_code}, message='{e.message}'\")\r\nexcept PlategaNetworkError as e:\r\n    print(f\"A network error occurred: {e}\")\r\n```\r\n\r\n---\r\n\r\n## \ud83d\udcda API Reference\r\n\r\n### `PlategaAsyncClient`\r\n\r\n-   `async create_transaction(payload: CreateTransactionRequest) -> CreateTransactionResponse`\r\n-   `async get_transaction_status(transaction_id: str) -> TransactionStatusResponse`\r\n-   `async get_rate(payment_method: int, currency_from: str, currency_to: str) -> RateResponse`\r\n-   `async close()`: Closes the client session. Called automatically when using `async with`.\r\n\r\n---\r\n\r\n## \ud83c\udf0d Links\r\n\r\n-   \ud83d\udce6 [PyPI](https://pypi.org/project/plategaio/)\r\n-   \ud83d\udcbb [Source Code](https://github.com/ploki1337/plategaio)\r\n-   \ud83d\udd17 [Platega.io](https://platega.io)\r\n",
    "bugtrack_url": null,
    "license": "MIT License\r\n        \r\n        Copyright (c) [2025] [ploki1337]\r\n        \r\n        Permission is hereby granted, free of charge, to any person obtaining a copy\r\n        of this software and associated documentation files (the \"Software\"), to deal\r\n        in the Software without restriction, including without limitation the rights\r\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n        copies of the Software, and to permit persons to whom the Software is\r\n        furnished to do so, subject to the following conditions:\r\n        \r\n        The above copyright notice and this permission notice shall be included in all\r\n        copies or substantial portions of the Software.\r\n        \r\n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\n        SOFTWARE.\r\n        ",
    "summary": "A simple and unofficial SDK for the Platega.io API.",
    "version": "1.0.4",
    "project_urls": {
        "Homepage": "https://github.com/ploki1337/plategaio"
    },
    "split_keywords": [
        "platega",
        " plategaio",
        " api",
        " sdk",
        " payment",
        " async",
        " asyncio",
        " httpx"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "542e5cd3ad2cbd85d7fb36386015090a1baaaf72ab9e7776d4847e4308016049",
                "md5": "b38eec6ccf918ec33b01d888e828875e",
                "sha256": "7b87ec0c49b85f0cdcf2ddf9996cfb2658333e12180bb9f23ead90f1acc82ac2"
            },
            "downloads": -1,
            "filename": "plategaio-1.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b38eec6ccf918ec33b01d888e828875e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 6185,
            "upload_time": "2025-10-21T18:15:18",
            "upload_time_iso_8601": "2025-10-21T18:15:18.908199Z",
            "url": "https://files.pythonhosted.org/packages/54/2e/5cd3ad2cbd85d7fb36386015090a1baaaf72ab9e7776d4847e4308016049/plategaio-1.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "2e502899362a08a9ae0a1aec09d9aca22423c38acdd43981c8fca64573d21763",
                "md5": "706c1a74cbead6b6d48c9447924b8421",
                "sha256": "b1e17f517f159f94bbc914981395801d87d49827b1e8566da76eb6f15ef00c0c"
            },
            "downloads": -1,
            "filename": "plategaio-1.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "706c1a74cbead6b6d48c9447924b8421",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 5436,
            "upload_time": "2025-10-21T18:15:22",
            "upload_time_iso_8601": "2025-10-21T18:15:22.830024Z",
            "url": "https://files.pythonhosted.org/packages/2e/50/2899362a08a9ae0a1aec09d9aca22423c38acdd43981c8fca64573d21763/plategaio-1.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-21 18:15:22",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ploki1337",
    "github_project": "plategaio",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "plategaio"
}
        
Elapsed time: 1.36656s