Skip to main content
This SDK is coming soon. Subscribe to our changelog to be notified when it’s released.
The official Python SDK for FYATU API v3, with async support and full type hints.

Requirements

  • Python 3.9 or higher

Installation

pip install fyatu
# or
poetry add fyatu

Quick Start

from fyatu import Fyatu

fyatu = Fyatu(
    app_id="your_app_id",
    secret_key="your_secret_key"
)

# Create a collection
collection = fyatu.collections.create(
    amount=10.00,
    currency="USD",
    reference="order_123",
    description="Payment for Order #123",
    customer={
        "email": "[email protected]",
        "name": "John Doe"
    },
    redirect_url="https://yoursite.com/payment/success",
    webhook_url="https://yoursite.com/webhooks/fyatu"
)

print(collection.checkout_url)

Async Support

import asyncio
from fyatu import AsyncFyatu

async def main():
    fyatu = AsyncFyatu(
        app_id="your_app_id",
        secret_key="your_secret_key"
    )

    # Create multiple collections concurrently
    collections = await asyncio.gather(
        fyatu.collections.create(amount=10, currency="USD", reference="order_1"),
        fyatu.collections.create(amount=20, currency="USD", reference="order_2"),
        fyatu.collections.create(amount=30, currency="USD", reference="order_3"),
    )

    for collection in collections:
        print(f"Created: {collection.id}")

    await fyatu.close()

asyncio.run(main())

Features

  • Full Type Hints - Complete type annotations for IDE support
  • Async/Await Support - Both sync and async clients available
  • Pydantic Models - Response objects with validation
  • Automatic Token Management - Handles JWT refresh automatically
  • Context Manager - Proper resource cleanup

Configuration Options

fyatu = Fyatu(
    app_id="your_app_id",
    secret_key="your_secret_key",

    # Optional configuration
    base_url="https://api.fyatu.com/api/v3",
    timeout=30.0,
    max_retries=3,
)

Available Modules

ModuleDescription
fyatu.collectionsAccept payments via checkout
fyatu.refundsManage refunds
fyatu.payoutsSend money to recipients
fyatu.cardholdersManage cardholders
fyatu.cardsIssue and manage virtual cards
fyatu.esimPurchase and manage eSIMs
fyatu.accountAccess account information

Error Handling

from fyatu import Fyatu
from fyatu.exceptions import (
    FyatuError,
    ValidationError,
    AuthenticationError,
    InsufficientBalanceError
)

fyatu = Fyatu(app_id="your_app_id", secret_key="your_secret_key")

try:
    payout = fyatu.payouts.create(
        amount=100,
        currency="USD",
        recipient_id="invalid_id"
    )
except ValidationError as e:
    print(f"Validation failed: {e.details}")
except AuthenticationError as e:
    print(f"Authentication failed: {e.message}")
except InsufficientBalanceError as e:
    print(f"Insufficient balance: {e.message}")
except FyatuError as e:
    print(f"API error [{e.code}]: {e.message}")

Webhook Verification

from fyatu.webhooks import verify_signature

# Flask example
from flask import Flask, request

app = Flask(__name__)

@app.route("/webhooks/fyatu", methods=["POST"])
def handle_webhook():
    signature = request.headers.get("X-Fyatu-Signature", "")

    is_valid = verify_signature(
        payload=request.data,
        signature=signature,
        secret="your_webhook_secret"
    )

    if not is_valid:
        return "Invalid signature", 401

    event = request.json
    print(f"Received event: {event['type']}")

    return "OK", 200

Django Integration

# settings.py
FYATU_APP_ID = "your_app_id"
FYATU_SECRET_KEY = "your_secret_key"

# views.py
from django.conf import settings
from fyatu import Fyatu

fyatu = Fyatu(
    app_id=settings.FYATU_APP_ID,
    secret_key=settings.FYATU_SECRET_KEY
)

Resources