Metadata-Version: 2.4
Name: casso-pg
Version: 1.0.0
Summary: Official Casso API v2 SDK for Python
Author-email: Casso Developer <developer@tenmiencuaban.com>
Keywords: casso,banking,vietnam,vietqr,webhook,fintech,payment
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Office/Business :: Financial
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.25.0
Dynamic: license-file

# Casso API v2 SDK for Python

A lightweight Python SDK to integrate with the [Casso API v2](https://casso.vn) bank transaction synchronization platform.

## Installation

Install using pip:

```bash
pip install casso-pg
```

## Features

- **Double Authentication Method**: Supports both API Keys and OAuth 2.0.
- **Transactions Sync**: Easily query bank transactions with advanced filters or manually trigger transaction syncs.
- **Webhook Management**: Register webhook endpoints programmatically.
- **Webhook Verification**: Verify incoming webhook calls using your configured secure token.

## Quick Start

### 1. Initialize Client

Initialize using your API Key:

```python
from casso_pg import CassoClient

casso = CassoClient(
    api_key="YOUR_CASSO_API_KEY",
    secure_token="YOUR_WEBHOOK_SECURE_TOKEN"
)
```

### 2. Query Transactions

```python
filters = {
    "sort": "DESC",
    "page": 1,
    "pageSize": 10,
    "fromDate": "2026-07-01"
}

response = casso.get_transactions(filters)
for txn in response.get("data", {}).get("records", []):
    print(f"ID: {txn['id']}, Amount: {txn['amount']}, Description: {txn['description']}")
```

### 3. Sync Transactions Manually

```python
sync_res = casso.sync_transactions()
print("Manual sync triggered:", sync_res)
```

### 4. Verify Webhook Authenticity

When Casso posts transaction data to your webhook endpoint, check the token sent in the `secure-token` header:

```python
# Inside your Webhook API handler (Flask / FastAPI / Django):
received_token = request.headers.get("secure-token")

if casso.verify_webhook(received_token):
    # Webhook is verified, safe to parse payload
    payload = request.get_json()
    for item in payload.get("data", []):
        print(f"Transaction detected: {item['amount']} VND, Memo: {item['description']}")
else:
    print("Unauthorized webhook access attempts.")
```

## License

MIT License.
