Metadata-Version: 2.4
Name: devport
Version: 0.1.1
Summary: Python SDK for the Ilambit DevPort API — BharatPe payment verification & history
Project-URL: Homepage, https://devport.ilambit.in
Project-URL: Documentation, https://devport.ilambit.in/docs
Author-email: Ilambit <dev@ilambit.in>
License-Expression: LicenseRef-Proprietary
Keywords: api,bharatpe,devport,payment,sdk
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python :: 3
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: Programming Language :: Python :: 3.13
Classifier: Typing :: Typed
Requires-Python: >=3.9
Requires-Dist: httpx<1,>=0.27
Provides-Extra: dev
Requires-Dist: build>=1.0; extra == 'dev'
Requires-Dist: pytest-httpx>=0.35; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Description-Content-Type: text/markdown

# devport

Python SDK for the [Ilambit DevPort API](https://devport.ilambit.in) — BharatPe payment verification & history.

> **Private package** — All rights reserved.

## Installation

```bash
pip install devport
```

Or install from the built wheel:

```bash
pip install dist/devport-0.1.0-py3-none-any.whl
```

## Quick Start

### Verify a payment

```python
from devport import bharatpe

result = bharatpe.payment_status(
    api_key="ilm_live_your_api_key_here",
    transaction_id="432112345678",
)

if result.verified:
    print(f"✅ Payment verified! Amount: ₹{result.transaction.amount}")
    print(f"   Payer: {result.transaction.payer_name}")
    print(f"   Status: {result.transaction.status}")
elif result.found:
    print(f"⏳ Transaction found but status is: {result.transaction.status}")
else:
    print("❌ Transaction not found.")
```

### Payment history

```python
from devport import bharatpe

history = bharatpe.payment_history(
    api_key="ilm_live_your_api_key_here",
    days=3,  # 1–7 days
)

print(f"Found {history.total} transactions in the last {history.lookback_days} days:")
for txn in history.transactions:
    print(f"  {txn.bank_reference_no}: ₹{txn.amount} — {txn.status}")
```

### Using the client class (avoid repeating your API key)

```python
from devport import DevPort

client = DevPort(api_key="ilm_live_your_api_key_here")

# Same functions, no need to pass api_key each time
result = client.bharatpe.payment_status(transaction_id="432112345678")
history = client.bharatpe.payment_history(days=3)
```

## Error Handling

Every API error is mapped to a specific exception:

```python
from devport import bharatpe
from devport import (
    DevPortError,         # Base — catches all API errors
    AuthenticationError,  # Invalid/revoked API key
    RateLimitError,       # Too many requests (has .retry_after)
    CreditError,          # No credits remaining
    NetworkError,         # Can't reach the server
)

try:
    result = bharatpe.payment_status(
        api_key="ilm_live_...",
        transaction_id="432112345678",
    )
except RateLimitError as e:
    print(f"Rate limited — retry after {e.retry_after}s")
except AuthenticationError as e:
    print(f"Auth failed: {e.code} — {e.message}")
except CreditError:
    print("No credits remaining. Purchase a package.")
except DevPortError as e:
    print(f"API error: {e}")
except NetworkError:
    print("Cannot reach DevPort API. Check your connection.")
```

## Configuration

| Parameter  | Default                          | Description                     |
|------------|----------------------------------|---------------------------------|
| `api_key`  | *(required)*                     | Your DevPort API key            |
| `base_url` | `https://devport.ilambit.in`     | API base URL (override for dev) |
| `timeout`  | `30.0`                           | Request timeout in seconds      |

### Local development

Point the SDK at your local gateway:

```python
from devport import DevPort

client = DevPort(
    api_key="ilm_live_...",
    base_url="http://localhost:3000",
)
```

## Response Types

All functions return typed dataclasses:

- **`PaymentStatusResult`** — `.verified`, `.found`, `.message`, `.transaction`, `.meta`
- **`PaymentHistoryResult`** — `.transactions`, `.total`, `.lookback_days`, `.meta`
- **`BharatPeTransaction`** — `.transaction_id`, `.bank_reference_no`, `.amount`, `.status`, `.mode`, `.payer_vpa`, `.payer_name`, `.transaction_date`, `.extra`
- **`ResponseMeta`** — `.requests_remaining`, `.latency_ms`, `.timestamp`

## Building from source

```bash
# Install build dependencies
pip install build

# Build wheel + sdist
python -m build

# Output is in dist/
#   devport-0.1.0-py3-none-any.whl
#   devport-0.1.0.tar.gz
```

## Publishing (private)

```bash
# Upload to a private PyPI registry
pip install twine
twine upload --repository-url https://your-private-pypi/ dist/*
```

## Requirements

- Python 3.9+
- [httpx](https://www.python-httpx.org/) (installed automatically)
