Metadata-Version: 2.4
Name: finswitz
Version: 1.0.0
Summary: Official Python SDK for the Finswitz API
Author: Finswitz
License: MIT
Keywords: payments,fintech,finswitz,api
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown

# Finswitz Python SDK

Python client for the Finswitz API.

## Installation

The Python SDK is currently distributed as a source client. Add `finswitz.py` to your application package, then import `Finswitz`.

When a package is published, this README should be updated with the package manager install command.

## Requirements

- Python 3.9 or newer
- A Finswitz test or live secret key

## Quick Start

```python
import os
from finswitz import Finswitz

client = Finswitz(api_key=os.environ["FINSWITZ_SECRET_KEY"])

link = client.create_payment_link(
    {
        "amount": 5000,
        "currency": "NGN",
        "title": "Order #1234",
        "email": "buyer@example.com",
        "callback_url": "https://merchant.example/complete",
    },
    idempotency_key="order-1234-link",
)

print(link["checkoutUrl"])
```

## Custom Base URL

```python
client = Finswitz(
    api_key=os.environ["FINSWITZ_SECRET_KEY"],
    base_url="http://localhost:4000",
)
```

## Payments

```python
client.transfer(
    {
        "amount": 5000,
        "currency": "NGN",
        "bank_code": "058",
        "account_number": "0123456789",
        "narration": "Vendor payout",
    },
    idempotency_key="transfer-001",
)

client.mobile_money(
    {
        "amount": 1500,
        "currency": "GHS",
        "phone": "+233501112222",
        "country": "GH",
    },
    idempotency_key="momo-001",
)

transaction = client.get_transaction("reference")
```

## Dashboard JWT Helpers

```python
client = Finswitz(
    api_key=os.environ["FINSWITZ_SECRET_KEY"],
    dashboard_token=os.environ["FINSWITZ_DASHBOARD_TOKEN"],
)

client.update_webhooks(
    {
        "mode": "test",
        "url": "https://merchant.example/webhooks/finswitz",
    }
)

wallets = client.wallets()
treasury = client.treasury()
```

## Collections

```python
collection = client.public_collection("school-fees")

payment = client.pay_collection(
    "school-fees",
    {
        "fullName": "Grace Johnson",
        "email": "grace@example.com",
        "amount": 10000,
        "phone": "+2348012345678",
    },
)
```

## Error Handling

```python
from finswitz import FinswitzApiError

try:
    client.get_transaction("missing-reference")
except FinswitzApiError as error:
    print(error.status)
    print(error.response)
    raise
```

