Skip to content

felloh-org/python-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Felloh Python SDK

Official Python SDK for the Felloh payment API.

Installation

pip install felloh

Quick Start

import asyncio
from felloh import FellohClient
from felloh.types import FellohConfig

client = FellohClient(FellohConfig(
    public_key="your_public_key",
    private_key="your_private_key",
))

async def main():
    # List bookings
    bookings = await client.bookings.list({"organisation": "org-id"})
    print(bookings["data"])

    # Create a booking
    booking = await client.bookings.create({
        "organisation": "org-id",
        "booking_reference": "REF-001",
        "customer_name": "Jane Smith",
        "email": "[email protected]",
    })
    print(booking["data"]["id"])

    await client.close()

asyncio.run(main())

Context Manager

async with FellohClient(FellohConfig(
    public_key="your_public_key",
    private_key="your_private_key",
)) as client:
    bookings = await client.bookings.list({"organisation": "org-id"})

Pagination

Iterate through all results automatically:

from felloh import to_array

# Async iteration
async for booking in client.bookings.list_all({"organisation": "org-id"}):
    print(booking["id"])

# Or collect all into a list
all_bookings = await to_array(client.bookings.list_all({"organisation": "org-id"}))

Resources

Resource Methods
organisations list
bookings list, list_all, get, create, update, delete, update_reference
booking_components create, delete
transactions list, list_all, get, refund, complete, reverse, reassign
customers list, list_all, create
payment_links list, list_all, get, create, delete, assign
ecommerce list, list_all, get, create, delete, assign
refunds list, list_all, authorise, decline
charges list, list_all
chargebacks list, list_all
credit_notes list, list_all, get, create, assign
suppliers list, list_all, create
beneficiaries list, list_all, create, activate
disbursements list, list_all, get
ledger list, list_all
batches list, list_all, get
api_keys list, create, delete
audit list, list_all
aisp accounts, transactions, statistics
scheduled_payments list, list_all, available_tokens, create_payment, approval_link, delete
enums list

Error Handling

from felloh import (
    FellohError,
    FellohAuthenticationError,
    FellohNotFoundError,
    FellohValidationError,
    FellohRateLimitError,
    FellohServerError,
    FellohNetworkError,
)

try:
    await client.bookings.get("nonexistent-id")
except FellohNotFoundError as e:
    print(f"Not found: {e}")
except FellohAuthenticationError:
    print("Invalid credentials")
except FellohError as e:
    print(f"API error {e.status_code}: {e}")

Webhook Verification

from felloh import verify_webhook_signature, assert_webhook_signature

# Returns True/False
is_valid = verify_webhook_signature(
    payload=request_body,
    signature=request.headers["X-Signature"],
    secret="your_webhook_secret",
)

# Or raise FellohWebhookSignatureError
assert_webhook_signature(
    payload=request_body,
    signature=request.headers["X-Signature"],
    secret="your_webhook_secret",
)

Configuration

FellohConfig(
    public_key="pk_...",
    private_key="sk_...",
    base_url="https://api.felloh.com",       # default
    timeout=30.0,                              # seconds, default
    max_retries=2,                             # default
    token_refresh_buffer=60,                   # seconds before expiry, default
    logger=lambda entry: print(entry),         # optional request logger
)

Development

pip install -e ".[dev]"
pytest                              # unit + resource tests
pytest -m integration               # integration tests (requires env vars)

Integration tests require:

  • FELLOH_PUBLIC_KEY
  • FELLOH_PRIVATE_KEY
  • FELLOH_ORGANISATION_ID

License

MIT

About

Python SDK for Felloh Payments

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages