Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

4.0 KB
Raw Blame
from products.warehouse_sources.sources.sdk import frozen

BASE_URL = "https://api.fintoc.com"
API_VERSION = "2026-02-01"


@frozen
class FintocEndpoint:
    path: str
    page_size_param: str | None = "limit"
    primary_keys: tuple[str, ...] = ("id",)
    partition_key: str | None = "created_at"
    requires_link_token: bool = False
    # Name of the account endpoint whose IDs fill `{account_id}` in the path.
    parent: str | None = None
    webhook_object: str | None = None
    webhook_events: tuple[str, ...] = ()


# Creation-date filters miss later status changes; timestamp filtering also needs live verification.
ENDPOINTS: dict[str, FintocEndpoint] = {
    "payment_intents": FintocEndpoint(
        path="/v2/payment_intents",
        webhook_object="payment_intent",
        webhook_events=tuple(
            f"payment_intent.{status}" for status in ("succeeded", "rejected", "failed", "pending", "expired")
        ),
    ),
    "transfers": FintocEndpoint(
        path="/v2/transfers",
        webhook_object="transfer",
        webhook_events=(
            "transfer.inbound.succeeded",
            "transfer.inbound.returned",
            "transfer.inbound.return_failed",
            "transfer.inbound.rejected",
            "transfer.inbound.reversed",
            "transfer.outbound.succeeded",
            "transfer.outbound.partially_succeeded",
            "transfer.outbound.failed",
            "transfer.outbound.returned",
            "transfer.outbound.reversed",
        ),
    ),
    "transfer_batches": FintocEndpoint(path="/v2/transfer_batches"),
    "refunds": FintocEndpoint(
        path="/v1/refunds",
        page_size_param="per_page",
        webhook_object="refund",
        webhook_events=("refund.succeeded", "refund.failed", "refund.in_progress"),
    ),
    "charges": FintocEndpoint(
        path="/v1/charges",
        page_size_param="per_page",
        webhook_object="charge",
        webhook_events=("charge.succeeded", "charge.failed"),
    ),
    "checkout_sessions": FintocEndpoint(
        path="/v2/checkout_sessions",
        webhook_object="checkout_session",
        webhook_events=("checkout_session.finished", "checkout_session.expired"),
    ),
    "subscriptions": FintocEndpoint(path="/v2/subscriptions"),
    "invoices": FintocEndpoint(
        path="/v2/invoices",
        webhook_object="invoice",
        webhook_events=tuple(
            f"invoice.{status}"
            for status in (
                "created",
                "finalized",
                "paid",
                "payment_created",
                "payment_failed",
                "payment_succeeded",
                "voided",
            )
        ),
    ),
    "customers": FintocEndpoint(path="/v2/customers"),
    "links": FintocEndpoint(path="/v1/links", page_size_param="per_page"),
    "accounts": FintocEndpoint(
        path="/v1/accounts",
        page_size_param="per_page",
        partition_key=None,
        requires_link_token=True,
    ),
    "movements": FintocEndpoint(
        path="/v1/accounts/{account_id}/movements",
        page_size_param="per_page",
        primary_keys=("account_id", "id"),
        partition_key=None,
        requires_link_token=True,
        parent="accounts",
    ),
    "payment_methods": FintocEndpoint(path="/v2/payment_methods"),
    # The disputes list documents no pagination parameters.
    "disputes": FintocEndpoint(path="/v1/disputes", page_size_param=None),
    "business_accounts": FintocEndpoint(path="/v2/accounts", partition_key=None),
    "business_account_movements": FintocEndpoint(
        path="/v2/accounts/{account_id}/movements",
        primary_keys=("account_id", "id"),
        partition_key="transaction_date",
        parent="business_accounts",
    ),
}

AUTH_ERROR = "Your Fintoc API key or link token is invalid or expired. Check your credentials and reconnect."
PERMISSION_ERROR = "Your Fintoc API key cannot access this resource. Check your Fintoc product permissions."
LINK_TOKEN_ERROR = (
    "Add link tokens to import open-banking accounts and movements. Fintoc does not return tokens when listing links."
)