Metadata-Version: 2.4
Name: plategaio
Version: 1.0.0
Summary: A simple and unofficial SDK for the Platega.io API.
Author-email: ploki1337 <ploki1337@gmail.com>
License: MIT 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.
        
Project-URL: Homepage, https://github.com/ploki1337/plategaio
Keywords: platega,plategaio,api,sdk,payment,async,asyncio,httpx
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Developers
Classifier: Framework :: AsyncIO
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx>=0.27.0
Requires-Dist: pydantic>=2.7.0
Dynamic: license-file

# 🟢 Platega SDK (Unofficial)

[![PyPI](https://img.shields.io/pypi/v/plategaio.svg)](https://pypi.org/project/plategaio/)  
[![Python](https://img.shields.io/pypi/pyversions/plategaio.svg)](https://pypi.org/project/plategaio/)  

> 🛠️ A simple and unofficial Python SDK for the [Platega.io](https://app.platega.io) API.  
> Provides convenient methods to create transactions, fetch statuses, and get rates.

---

## ✨ Features

- Minimalistic and clean API wrapper  
- Built-in request/response validation with **Pydantic**  
- Proper error handling with custom exceptions  
- Supports Python **3.8+**  

---

## 📦 Installation

```bash
pip install plategaio
```

---

## 🚀 Quick Start

```python
from plategaio import PlategaClient, CreateTransactionRequest, PaymentDetails
from uuid import uuid4

# init client
client = PlategaClient(
    merchant_id="YOUR_MERCHANT_ID",
    secret="YOUR_SECRET_KEY",
)

# create a transaction
tx = client.create_transaction(
    CreateTransactionRequest(
        paymentMethod=2,
        id=uuid4(),
        paymentDetails=PaymentDetails(amount=100.0, currency="RUB"),
        description="test order",
        return_url="https://your.site/success", # put your link after success payment
        failedUrl="https://your.site/failed", # put your link after failed payment
    )
)
print("Redirect user to:", tx.redirect)

# get transaction status
status = client.get_transaction_status(tx.transactionId)
print("Transaction status:", status.status)

# get conversion rate
rate = client.get_rate(payment_method=2, currency_from="USDT", currency_to="RUB")
print("USDT Rate:", rate.rate)
```

---

## ⚠️ Error Handling

SDK raises custom exceptions:

- `PlategaError` – Base exception  
- `PlategaHTTPError` – Non-200 API response  

Example:

```python
from plategaio import PlategaHTTPError

try:
    tx = client.create_transaction(...)
except PlategaHTTPError as e:
    print(f"Request failed: {e.status_code} {e.message}")
```

---

## 📚 API Reference

### `PlategaClient`
- `create_transaction(payload: CreateTransactionRequest) -> CreateTransactionResponse`  
- `get_transaction_status(transaction_id: str) -> TransactionStatusResponse`  
- `get_rate(payment_method: int, currency_from: str, currency_to: str, merchant_id: Optional[str] = None) -> RateResponse`

---

## 🌍 Links

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