Metadata-Version: 2.4
Name: openrelay
Version: 0.1.0
Summary: OpenRelay Python SDK — the open payment network
Project-URL: Homepage, https://openrelay.site
Project-URL: Repository, https://github.com/lacasoft/openrelay
License: Apache-2.0
Requires-Python: >=3.11
Requires-Dist: httpx>=0.27.0
Requires-Dist: pydantic>=2.7.0
Provides-Extra: dev
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Description-Content-Type: text/markdown

# openrelay — Python SDK

The OpenRelay Python SDK — **Stripe-compatible payments for the open web**.
Accept **USDC on Base** with no gatekeepers: gasless settlement (ERC-3009), webhooks, and
x402 micropayments. ~1% protocol fee (0.7% nodeit / 0.3% treasury), settled trustlessly on-chain.

- ⛽ **Gasless for payers** — they sign an ERC-3009 authorization; the nodeit pays the gas.
- 🧩 **Stripe-like DX** — `payment_intents.create`, `webhooks.verify`.
- 🌐 **Open network** — no lock-in, self-host or use any nodeit.

## Install

```bash
pip install openrelay
```

Requires Python ≥ 3.11. Depends on `httpx` and `pydantic`.

## Quick start

The client is **async** (built on `httpx.AsyncClient`):

```python
import asyncio
from openrelay import OpenRelay


async def main():
    # Use a SECRET key, server-side only — never ship it to a client.
    async with OpenRelay(api_key="sk_live_...") as relay:
        intent = await relay.payment_intents.create(
            amount=10_000_000,            # 10.00 USDC (6 decimals → 1 USDC = 1_000_000)
            currency="usdc",
            chain="base",
            metadata={"order_id": "123"},
        )
        print(intent["id"], intent["status"])  # "pi_…", "created"


asyncio.run(main())
```

Other payment-intent methods: `retrieve(id)`, `list(limit=10)`, `cancel(id)`.

## Webhooks

```python
event = relay.webhooks.verify(
    payload,                                  # raw request body (str)
    signature=request.headers["openrelay-signature"],
    secret="whsec_...",
)
if event["type"] == "payment_intent.settled":
    fulfill_order(event["data"]["metadata"]["order_id"])
```

## Configuration

```python
OpenRelay(
    api_key="sk_live_...",                 # required — secret key, server-side only
    base_url="https://api.openrelay.site",  # optional — your OpenRelay API host
    timeout=30.0,                           # optional — seconds
)
```

## Links

- Repo, docs & protocol spec: https://github.com/lacasoft/openrelay
- Source: [`packages/sdk-python`](https://github.com/lacasoft/openrelay/tree/master/packages/sdk-python)
- License: Apache-2.0
