Metadata-Version: 2.4
Name: 4mica-x402
Version: 1.0.1
Summary: Python integration for x402 Payment Protocol with 4mica credit flow
Author: 4mica
License: MIT
Project-URL: Homepage, https://github.com/4mica-Network/x402-4mica
Project-URL: Repository, https://github.com/4mica-Network/x402-4mica
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: x402>=2.0.0
Requires-Dist: sdk-4mica>=0.5.1
Provides-Extra: fastapi
Requires-Dist: fastapi[standard]>=0.115.0; extra == "fastapi"
Requires-Dist: starlette>=0.27.0; extra == "fastapi"
Provides-Extra: flask
Requires-Dist: flask>=3.0.0; extra == "flask"
Provides-Extra: httpx
Requires-Dist: httpx>=0.27.0; extra == "httpx"
Provides-Extra: requests
Requires-Dist: requests>=2.32.0; extra == "requests"
Provides-Extra: dev
Requires-Dist: pytest>=8.0.0; extra == "dev"
Requires-Dist: ruff>=0.5.0; extra == "dev"
Requires-Dist: black>=24.0.0; extra == "dev"
Provides-Extra: all
Requires-Dist: fastapi[standard]>=0.115.0; extra == "all"
Requires-Dist: starlette>=0.27.0; extra == "all"
Requires-Dist: flask>=3.0.0; extra == "all"
Requires-Dist: httpx>=0.27.0; extra == "all"
Requires-Dist: requests>=2.32.0; extra == "all"

# 4mica-x402

Python integration for the x402 Payment Protocol with 4mica credit flow support.

## Install

```bash
pip install 4mica-x402
```

Optional extras:
- `fastapi` (FastAPI middleware)
- `flask` (Flask middleware)
- `httpx` (async HTTP client wrapper)
- `requests` (sync HTTP client wrapper)
- `all` (everything)

## Quick Start (Server)

```python
from fastapi import FastAPI
from fourmica_x402.http import fastapi_payment_middleware_from_config

app = FastAPI()

routes = {
    "GET /premium": {
        "accepts": {
            "scheme": "4mica-credit",
            "price": "$0.01",
            "network": "eip155:11155111",
            "payTo": "0xRecipient",
        }
    }
}

middleware = fastapi_payment_middleware_from_config(
    routes,
    tab_endpoint="https://api.example.com/payment/tab",
)

@app.middleware("http")
async def x402_mw(request, call_next):
    return await middleware(request, call_next)
```

## Quick Start (Client)

```python
from x402 import x402ClientSync
from x402.http.clients import x402_requests
from fourmica_x402.client_scheme import FourMicaEvmScheme

client = x402ClientSync()
client.register("eip155:11155111", FourMicaEvmScheme("0xYourPrivateKey"))

session = x402_requests(client)
resp = session.get("https://api.example.com/premium")
print(resp.status_code, resp.text)
```

## Development

```bash
python -m build
python -m pytest
```

Install dev tools:

```bash
pip install -e .[dev]
```
