inttegro

Public typing surface for the Inttegro SDK.

  1"""Official Python client for the Inttegro API.
  2
  3Domain types live in singular resource namespaces. For example, import
  4``inttegro.payment.Payment`` or ``inttegro.product.Type`` instead of relying on
  5a flat package-level model namespace.
  6"""
  7
  8from .async_client import AsyncInttegroClient
  9from .async_http_client import AsyncHTTPClient
 10from .client import InttegroClient
 11from .custom_data import CustomData, CustomDataInput, CustomDataPatch
 12from .response import InttegroResponse
 13from .error_reporting import (
 14    APIErrorReportContext,
 15    ErrorReport,
 16    ErrorReporter,
 17    ErrorReportingPolicy,
 18    HTTPReportContext,
 19    SDKReportContext,
 20    TraceReportContext,
 21)
 22from .errors import (
 23    APIError,
 24    AuthenticationError,
 25    InttegroError,
 26    NetworkError,
 27    RateLimitError,
 28    TimeoutError,
 29)
 30from . import (
 31    app,
 32    children_policy,
 33    balance,
 34    balance_transaction,
 35    bank_account,
 36    broadcast,
 37    checkout,
 38    chime,
 39    customer,
 40    file,
 41    file_link,
 42    file_reference,
 43    financial_account,
 44    message_template,
 45    money,
 46    order,
 47    otp,
 48    operating_policy,
 49    payment,
 50    payment_method,
 51    payout,
 52    price,
 53    product,
 54    purchase_intent,
 55    request,
 56    refund,
 57    schedule,
 58    search,
 59    secret_key,
 60    shared,
 61    upload_request,
 62    wallet,
 63)
 64
 65__all__ = [
 66    "APIError",
 67    "APIErrorReportContext",
 68    "AsyncHTTPClient",
 69    "AsyncInttegroClient",
 70    "AuthenticationError",
 71    "CustomData",
 72    "CustomDataInput",
 73    "CustomDataPatch",
 74    "ErrorReport",
 75    "ErrorReporter",
 76    "ErrorReportingPolicy",
 77    "HTTPReportContext",
 78    "InttegroClient",
 79    "InttegroResponse",
 80    "InttegroError",
 81    "NetworkError",
 82    "RateLimitError",
 83    "SDKReportContext",
 84    "TimeoutError",
 85    "TraceReportContext",
 86    "app",
 87    "children_policy",
 88    "balance",
 89    "balance_transaction",
 90    "bank_account",
 91    "broadcast",
 92    "checkout",
 93    "chime",
 94    "customer",
 95    "file",
 96    "file_link",
 97    "file_reference",
 98    "financial_account",
 99    "message_template",
100    "money",
101    "order",
102    "otp",
103    "operating_policy",
104    "payment",
105    "payment_method",
106    "payout",
107    "price",
108    "product",
109    "purchase_intent",
110    "request",
111    "refund",
112    "schedule",
113    "search",
114    "secret_key",
115    "shared",
116    "upload_request",
117    "wallet",
118]
class APIError(inttegro.InttegroError):
37class APIError(InttegroError):
38    """Raised for API errors (HTTP >= 400)."""
39
40    status: int
41    code: str | None
42    type: str | None
43    url: str | None
44    detail: str | None
45    fix_code: str | None
46    cause: str | None
47    body: str | None
48    data: JSONValue
49    request_id: str | None
50
51    def __init__(
52        self,
53        message: str,
54        status: int,
55        code: str | None = None,
56        error_type: str | None = None,
57        url: str | None = None,
58        detail: str | None = None,
59        fix_code: str | None = None,
60        cause: str | None = None,
61        body: str | None = None,
62        data: JSONValue = None,
63        request_id: str | None = None,
64    ) -> None:
65        super().__init__(message)
66        self.status = status
67        self.code = code
68        self.type = error_type
69        self.url = url
70        self.detail = detail
71        self.fix_code = fix_code
72        self.cause = cause
73        self.body = body
74        self.data = data
75        self.request_id = request_id

Raised for API errors (HTTP >= 400).

APIError( message: str, status: int, code: str | None = None, error_type: str | None = None, url: str | None = None, detail: str | None = None, fix_code: str | None = None, cause: str | None = None, body: str | None = None, data: str | int | float | bool | None | list[ForwardRef('JSONValue')] | dict[str, ForwardRef('JSONValue')] = None, request_id: str | None = None)
51    def __init__(
52        self,
53        message: str,
54        status: int,
55        code: str | None = None,
56        error_type: str | None = None,
57        url: str | None = None,
58        detail: str | None = None,
59        fix_code: str | None = None,
60        cause: str | None = None,
61        body: str | None = None,
62        data: JSONValue = None,
63        request_id: str | None = None,
64    ) -> None:
65        super().__init__(message)
66        self.status = status
67        self.code = code
68        self.type = error_type
69        self.url = url
70        self.detail = detail
71        self.fix_code = fix_code
72        self.cause = cause
73        self.body = body
74        self.data = data
75        self.request_id = request_id
status: int
code: str | None
type: str | None
url: str | None
detail: str | None
fix_code: str | None
cause: str | None
body: str | None
data: str | int | float | bool | None | list[ForwardRef('JSONValue')] | dict[str, ForwardRef('JSONValue')]
request_id: str | None
@dataclass(frozen=True)
class APIErrorReportContext:
27@dataclass(frozen=True)
28class APIErrorReportContext:
29    type: str | None = None
30    code: str | None = None
31    fix_code: str | None = None
APIErrorReportContext( type: str | None = None, code: str | None = None, fix_code: str | None = None)
type: str | None = None
code: str | None = None
fix_code: str | None = None
class AsyncHTTPClient(typing.Protocol):
38class AsyncHTTPClient(Protocol):
39    """Minimal transport protocol implemented by ``httpx.AsyncClient``."""
40
41    async def request(
42        self,
43        method: str,
44        url: str,
45        *,
46        headers: Mapping[str, str],
47        content: bytes | None,
48        timeout: float,
49    ) -> AsyncHTTPResponse:
50        raise NotImplementedError
51
52    async def aclose(self) -> None:
53        raise NotImplementedError

Minimal transport protocol implemented by httpx.AsyncClient.

AsyncHTTPClient(*args, **kwargs)
1771def _no_init_or_replace_init(self, *args, **kwargs):
1772    cls = type(self)
1773
1774    if cls._is_protocol:
1775        raise TypeError('Protocols cannot be instantiated')
1776
1777    # Already using a custom `__init__`. No need to calculate correct
1778    # `__init__` to call. This can lead to RecursionError. See bpo-45121.
1779    if cls.__init__ is not _no_init_or_replace_init:
1780        return
1781
1782    # Initially, `__init__` of a protocol subclass is set to `_no_init_or_replace_init`.
1783    # The first instantiation of the subclass will call `_no_init_or_replace_init` which
1784    # searches for a proper new `__init__` in the MRO. The new `__init__`
1785    # replaces the subclass' old `__init__` (ie `_no_init_or_replace_init`). Subsequent
1786    # instantiation of the protocol subclass will thus use the new
1787    # `__init__` and no longer call `_no_init_or_replace_init`.
1788    for base in cls.__mro__:
1789        init = base.__dict__.get('__init__', _no_init_or_replace_init)
1790        if init is not _no_init_or_replace_init:
1791            cls.__init__ = init
1792            break
1793    else:
1794        # should not happen
1795        cls.__init__ = object.__init__
1796
1797    cls.__init__(self, *args, **kwargs)
async def request( self, method: str, url: str, *, headers: Mapping[str, str], content: bytes | None, timeout: float) -> inttegro.async_http_client.AsyncHTTPResponse:
41    async def request(
42        self,
43        method: str,
44        url: str,
45        *,
46        headers: Mapping[str, str],
47        content: bytes | None,
48        timeout: float,
49    ) -> AsyncHTTPResponse:
50        raise NotImplementedError
async def aclose(self) -> None:
52    async def aclose(self) -> None:
53        raise NotImplementedError
class AsyncInttegroClient:
 38class AsyncInttegroClient:
 39    """Asynchronous Inttegro API client for event-loop based applications.
 40
 41    Use one long-lived client per application and close it during shutdown, or
 42    use ``async with`` for a bounded lifecycle. Every resource operation must
 43    be awaited. ``InttegroClient`` remains available for synchronous programs.
 44
 45    Example::
 46
 47        async with AsyncInttegroClient(api_key="sk_live_...") as client:
 48            order = await client.orders.create({...})
 49    """
 50
 51    http: AsyncHttpClient
 52    orders: AsyncOrders
 53    payment_methods: AsyncPaymentMethods
 54    payouts: AsyncPayouts
 55    balance_transactions: AsyncBalanceTransactions
 56    financial_accounts: AsyncFinancialAccounts
 57    files: AsyncFiles
 58    file_links: AsyncFileLinks
 59    file_references: AsyncFileReferences
 60    customers: AsyncCustomers
 61    products: AsyncProducts
 62    prices: AsyncPrices
 63    purchase_intents: AsyncPurchaseIntents
 64    refunds: AsyncRefunds
 65    chimes: AsyncChimes
 66    schedules: AsyncSchedules
 67    broadcasts: AsyncBroadcasts
 68    message_templates: AsyncMessageTemplates
 69    otp: AsyncOtp
 70    apps: AsyncApps
 71    keys: AsyncKeys
 72    spec: AsyncSpec
 73    balances: AsyncBalances
 74    upload_requests: AsyncUploadRequests
 75    children_policies: AsyncChildrenPolicies
 76    operating_policies: AsyncOperatingPolicies
 77
 78    def __init__(
 79        self,
 80        api_key: str,
 81        base_url: str = "https://api.inttegro.com",
 82        timeout: float = 30.0,
 83        transport: AsyncTransport | None = None,
 84        telemetry_enabled: bool = True,
 85        tracer_provider: TracerProvider | None = None,
 86        error_reporter: ErrorReporter | None = None,
 87        error_reporting_policy: ErrorReportingPolicy = "unexpected",
 88        http_client: AsyncHTTPClient | None = None,
 89    ) -> None:
 90        """Initialize a non-blocking client and its shared connection pool.
 91
 92        ``transport`` is the lightweight SDK test/adapter seam. Use
 93        ``http_client`` to supply an application-owned ``httpx.AsyncClient``
 94        with custom proxy, TLS, limits, or retry configuration. Do not pass
 95        both unless the transport deliberately replaces network I/O.
 96        """
 97
 98        self.http = AsyncHttpClient(
 99            api_key=api_key,
100            base_url=base_url,
101            timeout=timeout,
102            transport=transport,
103            telemetry_enabled=telemetry_enabled,
104            tracer_provider=tracer_provider,
105            error_reporter=error_reporter,
106            error_reporting_policy=error_reporting_policy,
107            http_client=http_client,
108        )
109        self.orders = AsyncOrders(self.http)
110        self.payment_methods = AsyncPaymentMethods(self.http)
111        self.payouts = AsyncPayouts(self.http)
112        self.balance_transactions = AsyncBalanceTransactions(self.http)
113        self.financial_accounts = AsyncFinancialAccounts(self.http)
114        self.files = AsyncFiles(self.http)
115        self.file_links = AsyncFileLinks(self.http)
116        self.file_references = AsyncFileReferences(self.http)
117        self.customers = AsyncCustomers(self.http)
118        self.products = AsyncProducts(self.http)
119        self.prices = AsyncPrices(self.http)
120        self.purchase_intents = AsyncPurchaseIntents(self.http)
121        self.refunds = AsyncRefunds(self.http)
122        self.chimes = AsyncChimes(self.http)
123        self.schedules = AsyncSchedules(self.http)
124        self.broadcasts = AsyncBroadcasts(self.http)
125        self.message_templates = AsyncMessageTemplates(self.http)
126        self.otp = AsyncOtp(self.http)
127        self.apps = AsyncApps(self.http)
128        self.keys = AsyncKeys(self.http)
129        self.spec = AsyncSpec(self.http)
130        self.balances = AsyncBalances(self.http)
131        self.upload_requests = AsyncUploadRequests(self.http)
132        self.children_policies = AsyncChildrenPolicies(self.http)
133        self.operating_policies = AsyncOperatingPolicies(self.http)
134
135    async def __aenter__(self) -> AsyncInttegroClient:
136        return self
137
138    async def __aexit__(self, exc_type: object, exc: object, traceback: object) -> None:
139        await self.aclose()
140
141    async def aclose(self) -> None:
142        """Close the SDK-owned connection pool."""
143
144        await self.http.aclose()

Asynchronous Inttegro API client for event-loop based applications.

Use one long-lived client per application and close it during shutdown, or use async with for a bounded lifecycle. Every resource operation must be awaited. InttegroClient remains available for synchronous programs.

Example::

async with AsyncInttegroClient(api_key="sk_live_...") as client:
    order = await client.orders.create({...})
AsyncInttegroClient( api_key: str, base_url: str = 'https://api.inttegro.com', timeout: float = 30.0, transport: Callable[[urllib.request.Request, float | None], Awaitable[tuple[int, typing.Dict[str, str], str | bytes]]] | None = None, telemetry_enabled: bool = True, tracer_provider: opentelemetry.trace.TracerProvider | None = None, error_reporter: Optional[Callable[[ErrorReport], NoneType]] = None, error_reporting_policy: Literal['unexpected', 'all'] = 'unexpected', http_client: AsyncHTTPClient | None = None)
 78    def __init__(
 79        self,
 80        api_key: str,
 81        base_url: str = "https://api.inttegro.com",
 82        timeout: float = 30.0,
 83        transport: AsyncTransport | None = None,
 84        telemetry_enabled: bool = True,
 85        tracer_provider: TracerProvider | None = None,
 86        error_reporter: ErrorReporter | None = None,
 87        error_reporting_policy: ErrorReportingPolicy = "unexpected",
 88        http_client: AsyncHTTPClient | None = None,
 89    ) -> None:
 90        """Initialize a non-blocking client and its shared connection pool.
 91
 92        ``transport`` is the lightweight SDK test/adapter seam. Use
 93        ``http_client`` to supply an application-owned ``httpx.AsyncClient``
 94        with custom proxy, TLS, limits, or retry configuration. Do not pass
 95        both unless the transport deliberately replaces network I/O.
 96        """
 97
 98        self.http = AsyncHttpClient(
 99            api_key=api_key,
100            base_url=base_url,
101            timeout=timeout,
102            transport=transport,
103            telemetry_enabled=telemetry_enabled,
104            tracer_provider=tracer_provider,
105            error_reporter=error_reporter,
106            error_reporting_policy=error_reporting_policy,
107            http_client=http_client,
108        )
109        self.orders = AsyncOrders(self.http)
110        self.payment_methods = AsyncPaymentMethods(self.http)
111        self.payouts = AsyncPayouts(self.http)
112        self.balance_transactions = AsyncBalanceTransactions(self.http)
113        self.financial_accounts = AsyncFinancialAccounts(self.http)
114        self.files = AsyncFiles(self.http)
115        self.file_links = AsyncFileLinks(self.http)
116        self.file_references = AsyncFileReferences(self.http)
117        self.customers = AsyncCustomers(self.http)
118        self.products = AsyncProducts(self.http)
119        self.prices = AsyncPrices(self.http)
120        self.purchase_intents = AsyncPurchaseIntents(self.http)
121        self.refunds = AsyncRefunds(self.http)
122        self.chimes = AsyncChimes(self.http)
123        self.schedules = AsyncSchedules(self.http)
124        self.broadcasts = AsyncBroadcasts(self.http)
125        self.message_templates = AsyncMessageTemplates(self.http)
126        self.otp = AsyncOtp(self.http)
127        self.apps = AsyncApps(self.http)
128        self.keys = AsyncKeys(self.http)
129        self.spec = AsyncSpec(self.http)
130        self.balances = AsyncBalances(self.http)
131        self.upload_requests = AsyncUploadRequests(self.http)
132        self.children_policies = AsyncChildrenPolicies(self.http)
133        self.operating_policies = AsyncOperatingPolicies(self.http)

Initialize a non-blocking client and its shared connection pool.

transport is the lightweight SDK test/adapter seam. Use http_client to supply an application-owned httpx.AsyncClient with custom proxy, TLS, limits, or retry configuration. Do not pass both unless the transport deliberately replaces network I/O.

http: inttegro.async_http_client.AsyncHttpClient
async def aclose(self) -> None:
141    async def aclose(self) -> None:
142        """Close the SDK-owned connection pool."""
143
144        await self.http.aclose()

Close the SDK-owned connection pool.

class AuthenticationError(inttegro.APIError):
78class AuthenticationError(APIError):
79    """Raised on 401 responses."""

Raised on 401 responses.

class CustomData(collections.abc.Mapping[str, typing.Any]):
69class CustomData(_CustomDataMapping):
70    """Read-only merchant-defined string values returned by the API."""
71
72    def _normalize(self, values: Mapping[str, Any]) -> dict[str, str]:
73        normalized: dict[str, str] = {}
74        for key, value in values.items():
75            if not isinstance(key, str) or not isinstance(value, str):
76                raise TypeError("CustomData keys and values must be strings")
77            normalized[key] = value
78        return normalized
79
80    def with_value(self, key: str, value: str) -> CustomData:
81        return super().with_value(key, value)

Read-only merchant-defined string values returned by the API.

def with_value(self, key: str, value: str) -> CustomData:
80    def with_value(self, key: str, value: str) -> CustomData:
81        return super().with_value(key, value)
class CustomDataInput(collections.abc.Mapping[str, typing.Any]):
84class CustomDataInput(_CustomDataMapping):
85    """Open-ended JSON values accepted by create and replace requests."""

Open-ended JSON values accepted by create and replace requests.

class CustomDataPatch(collections.abc.Mapping[str, typing.Any]):
 88class CustomDataPatch(_CustomDataMapping):
 89    """Merge operations where an explicit ``None`` removes a stored key."""
 90
 91    def set(self, key: str, value: Any) -> CustomDataPatch:
 92        if value is None:
 93            raise ValueError("use unset() to remove a custom-data value")
 94        return self.with_value(key, value)
 95
 96    def unset(self, key: str) -> CustomDataPatch:
 97        return self.with_value(key, None)
 98
 99    def remove_change(self, key: str) -> CustomDataPatch:
100        return self.without(key)

Merge operations where an explicit None removes a stored key.

def set(self, key: str, value: Any) -> CustomDataPatch:
91    def set(self, key: str, value: Any) -> CustomDataPatch:
92        if value is None:
93            raise ValueError("use unset() to remove a custom-data value")
94        return self.with_value(key, value)
def unset(self, key: str) -> CustomDataPatch:
96    def unset(self, key: str) -> CustomDataPatch:
97        return self.with_value(key, None)
def remove_change(self, key: str) -> CustomDataPatch:
 99    def remove_change(self, key: str) -> CustomDataPatch:
100        return self.without(key)
@dataclass(frozen=True)
class ErrorReport:
40@dataclass(frozen=True)
41class ErrorReport:
42    """A privacy-safe description of a failed Inttegro SDK operation."""
43
44    schema_version: Literal[1]
45    event_id: str
46    occurred_at: str
47    severity: Literal["error"]
48    category: str
49    operation: str
50    sdk: SDKReportContext
51    http: HTTPReportContext
52    exception_type: str
53    fingerprint: str
54    api_error: APIErrorReportContext | None = None
55    trace: TraceReportContext | None = None
56
57    def to_dict(self) -> dict[str, object]:
58        """Return a JSON-serializable payload for a collector."""
59        return cast(dict[str, object], asdict(self))

A privacy-safe description of a failed Inttegro SDK operation.

ErrorReport( schema_version: Literal[1], event_id: str, occurred_at: str, severity: Literal['error'], category: str, operation: str, sdk: SDKReportContext, http: HTTPReportContext, exception_type: str, fingerprint: str, api_error: APIErrorReportContext | None = None, trace: TraceReportContext | None = None)
schema_version: Literal[1]
event_id: str
occurred_at: str
severity: Literal['error']
category: str
operation: str
exception_type: str
fingerprint: str
api_error: APIErrorReportContext | None = None
trace: TraceReportContext | None = None
def to_dict(self) -> dict[str, object]:
57    def to_dict(self) -> dict[str, object]:
58        """Return a JSON-serializable payload for a collector."""
59        return cast(dict[str, object], asdict(self))

Return a JSON-serializable payload for a collector.

ErrorReporter = typing.Callable[[ErrorReport], NoneType]
ErrorReportingPolicy = typing.Literal['unexpected', 'all']
@dataclass(frozen=True)
class HTTPReportContext:
17@dataclass(frozen=True)
18class HTTPReportContext:
19    method: str
20    server_address: str
21    duration_ms: int
22    route: str | None = None
23    status_code: int | None = None
24    request_id: str | None = None
HTTPReportContext( method: str, server_address: str, duration_ms: int, route: str | None = None, status_code: int | None = None, request_id: str | None = None)
method: str
server_address: str
duration_ms: int
route: str | None = None
status_code: int | None = None
request_id: str | None = None
class InttegroClient:
 38class InttegroClient:
 39    """
 40    Main SDK client for the Inttegro API.
 41
 42    The Inttegro client provides access to all API resources including orders,
 43    payment methods, payouts, financial accounts, and more. Initialize with
 44    your API key from the Inttegro dashboard.
 45
 46    Attributes:
 47        orders: Orders resource for creating and managing orders, processing payments
 48        payment_methods: Payment methods resource for tokenizing and managing payment instruments
 49        payouts: Payouts resource for scheduling and managing fund transfers
 50        balance_transactions: Balance transactions resource for viewing account activity
 51        financial_accounts: Financial accounts resource for connecting bank and mobile money accounts
 52        customers: Customers resource for creating and managing customers
 53        products: Products resource for managing catalog products
 54        prices: Prices resource for managing catalog prices
 55        refunds: Refunds resource for creating and managing refunds
 56        chimes: Chimes resource for sending transactional notifications
 57        schedules: Schedules resource for looking up and canceling scheduled chimes
 58        broadcasts: Broadcasts resource for looking up and canceling broadcasts
 59        otp: OTP resource for one-time password verification
 60        apps: Apps resource for creating, looking up, and updating applications
 61        spec: Spec resource for retrieving supported countries and currencies
 62
 63    Example:
 64        ```python
 65        import os
 66        from inttegro import InttegroClient
 67
 68        # Initialize client with API key
 69        client = InttegroClient(api_key=os.environ["INTTEGRO_API_KEY"])
 70
 71        # Create and process an order
 72        result = client.orders.create({
 73            "customer_data": {
 74                "name": "Akua Asantewaa",
 75                "phone_number": "+233541234567",
 76                "email_address": "akua@example.com"
 77            },
 78            "line_items": [{
 79                "type": "product",
 80                "product": {
 81                    "type": "digital",
 82                    "name": "Premium Subscription",
 83                    "quantity": 1,
 84                    "price": {"currency": "ghs", "value": 5000}
 85                }
 86            }],
 87            "billing_details": {
 88                "name": "Akua Asantewaa",
 89                "phone_number": "+233541234567"
 90            },
 91            "execute_payment": True
 92        })
 93        ```
 94
 95    Thread Safety:
 96        The client is thread-safe after initialization and can be safely shared
 97        across multiple threads.
 98    """
 99
100    http: HttpClient
101    orders: Orders
102    payment_methods: PaymentMethods
103    payouts: Payouts
104    balance_transactions: BalanceTransactions
105    financial_accounts: FinancialAccounts
106    files: Files
107    file_links: FileLinks
108    file_references: FileReferences
109    customers: Customers
110    products: Products
111    prices: Prices
112    purchase_intents: PurchaseIntents
113    refunds: Refunds
114    chimes: Chimes
115    schedules: Schedules
116    broadcasts: Broadcasts
117    message_templates: MessageTemplates
118    otp: Otp
119    apps: Apps
120    keys: Keys
121    spec: Spec
122    balances: Balances
123    upload_requests: UploadRequests
124    children_policies: ChildrenPolicies
125    operating_policies: OperatingPolicies
126
127    def __init__(
128        self,
129        api_key: str,
130        base_url: str = "https://api.inttegro.com",
131        timeout: float = 30.0,
132        transport: Transport | None = None,
133        telemetry_enabled: bool = True,
134        tracer_provider: TracerProvider | None = None,
135        error_reporter: ErrorReporter | None = None,
136        error_reporting_policy: ErrorReportingPolicy = "unexpected",
137    ) -> None:
138        """
139        Initialize a new Inttegro client.
140
141        Args:
142            api_key: Your Inttegro API key (required). Get this from your dashboard
143                at https://studio.inttegro.com/settings/keys. Use test keys (sk_test_...)
144                for development and live keys (sk_live_...) for production.
145            base_url: API base URL. Defaults to production (https://api.inttegro.com).
146                Override for testing or staging environments.
147            timeout: Request timeout in seconds. Defaults to 30.0. Increase for
148                long-running operations or slow networks.
149            transport: Custom HTTP transport adapter. Pass a requests.Session or
150                custom transport for connection pooling, retries, or proxies.
151            telemetry_enabled: Emit spans to the configured OpenTelemetry provider.
152                Defaults to True. The SDK never configures an exporter.
153            tracer_provider: Optional OpenTelemetry tracer provider override.
154            error_reporter: Optional application-owned callback for privacy-safe final-failure reports.
155            error_reporting_policy: Report unexpected failures by default, or use ``"all"``.
156
157        Raises:
158            ValueError: If api_key is empty or invalid
159
160        Example:
161            ```python
162            # Production usage
163            client = InttegroClient(api_key="sk_live_...")
164
165            # Development with custom timeout
166            client = InttegroClient(
167                api_key="sk_test_...",
168                timeout=60.0
169            )
170
171            # Testing with mock server
172            client = InttegroClient(
173                api_key="sk_test_...",
174                base_url="http://localhost:8080"
175            )
176            ```
177        """
178        self.http = HttpClient(
179            api_key=api_key,
180            base_url=base_url,
181            timeout=timeout,
182            transport=transport,
183            telemetry_enabled=telemetry_enabled,
184            tracer_provider=tracer_provider,
185            error_reporter=error_reporter,
186            error_reporting_policy=error_reporting_policy,
187        )
188
189        self.orders = Orders(self.http)
190        self.payment_methods = PaymentMethods(self.http)
191        self.payouts = Payouts(self.http)
192        self.balance_transactions = BalanceTransactions(self.http)
193        self.financial_accounts = FinancialAccounts(self.http)
194        self.files = Files(self.http)
195        self.file_links = FileLinks(self.http)
196        self.file_references = FileReferences(self.http)
197        self.customers = Customers(self.http)
198        self.products = Products(self.http)
199        self.prices = Prices(self.http)
200        self.purchase_intents = PurchaseIntents(self.http)
201        self.refunds = Refunds(self.http)
202        self.chimes = Chimes(self.http)
203        self.schedules = Schedules(self.http)
204        self.broadcasts = Broadcasts(self.http)
205        self.message_templates = MessageTemplates(self.http)
206        self.otp = Otp(self.http)
207        self.apps = Apps(self.http)
208        self.keys = Keys(self.http)
209        self.spec = Spec(self.http)
210        self.balances = Balances(self.http)
211        self.upload_requests = UploadRequests(self.http)
212        self.children_policies = ChildrenPolicies(self.http)
213        self.operating_policies = OperatingPolicies(self.http)

Main SDK client for the Inttegro API.

The Inttegro client provides access to all API resources including orders, payment methods, payouts, financial accounts, and more. Initialize with your API key from the Inttegro dashboard.

Attributes:
  • orders: Orders resource for creating and managing orders, processing payments
  • payment_methods: Payment methods resource for tokenizing and managing payment instruments
  • payouts: Payouts resource for scheduling and managing fund transfers
  • balance_transactions: Balance transactions resource for viewing account activity
  • financial_accounts: Financial accounts resource for connecting bank and mobile money accounts
  • customers: Customers resource for creating and managing customers
  • products: Products resource for managing catalog products
  • prices: Prices resource for managing catalog prices
  • refunds: Refunds resource for creating and managing refunds
  • chimes: Chimes resource for sending transactional notifications
  • schedules: Schedules resource for looking up and canceling scheduled chimes
  • broadcasts: Broadcasts resource for looking up and canceling broadcasts
  • otp: OTP resource for one-time password verification
  • apps: Apps resource for creating, looking up, and updating applications
  • spec: Spec resource for retrieving supported countries and currencies
Example:
import os
from inttegro import InttegroClient

# Initialize client with API key
client = InttegroClient(api_key=os.environ["INTTEGRO_API_KEY"])

# Create and process an order
result = client.orders.create({
    "customer_data": {
        "name": "Akua Asantewaa",
        "phone_number": "+233541234567",
        "email_address": "akua@example.com"
    },
    "line_items": [{
        "type": "product",
        "product": {
            "type": "digital",
            "name": "Premium Subscription",
            "quantity": 1,
            "price": {"currency": "ghs", "value": 5000}
        }
    }],
    "billing_details": {
        "name": "Akua Asantewaa",
        "phone_number": "+233541234567"
    },
    "execute_payment": True
})
Thread Safety:

The client is thread-safe after initialization and can be safely shared across multiple threads.

InttegroClient( api_key: str, base_url: str = 'https://api.inttegro.com', timeout: float = 30.0, transport: Optional[Callable[[urllib.request.Request, float | None], tuple[int, Dict[str, str], str | bytes]]] = None, telemetry_enabled: bool = True, tracer_provider: opentelemetry.trace.TracerProvider | None = None, error_reporter: Optional[Callable[[ErrorReport], NoneType]] = None, error_reporting_policy: Literal['unexpected', 'all'] = 'unexpected')
127    def __init__(
128        self,
129        api_key: str,
130        base_url: str = "https://api.inttegro.com",
131        timeout: float = 30.0,
132        transport: Transport | None = None,
133        telemetry_enabled: bool = True,
134        tracer_provider: TracerProvider | None = None,
135        error_reporter: ErrorReporter | None = None,
136        error_reporting_policy: ErrorReportingPolicy = "unexpected",
137    ) -> None:
138        """
139        Initialize a new Inttegro client.
140
141        Args:
142            api_key: Your Inttegro API key (required). Get this from your dashboard
143                at https://studio.inttegro.com/settings/keys. Use test keys (sk_test_...)
144                for development and live keys (sk_live_...) for production.
145            base_url: API base URL. Defaults to production (https://api.inttegro.com).
146                Override for testing or staging environments.
147            timeout: Request timeout in seconds. Defaults to 30.0. Increase for
148                long-running operations or slow networks.
149            transport: Custom HTTP transport adapter. Pass a requests.Session or
150                custom transport for connection pooling, retries, or proxies.
151            telemetry_enabled: Emit spans to the configured OpenTelemetry provider.
152                Defaults to True. The SDK never configures an exporter.
153            tracer_provider: Optional OpenTelemetry tracer provider override.
154            error_reporter: Optional application-owned callback for privacy-safe final-failure reports.
155            error_reporting_policy: Report unexpected failures by default, or use ``"all"``.
156
157        Raises:
158            ValueError: If api_key is empty or invalid
159
160        Example:
161            ```python
162            # Production usage
163            client = InttegroClient(api_key="sk_live_...")
164
165            # Development with custom timeout
166            client = InttegroClient(
167                api_key="sk_test_...",
168                timeout=60.0
169            )
170
171            # Testing with mock server
172            client = InttegroClient(
173                api_key="sk_test_...",
174                base_url="http://localhost:8080"
175            )
176            ```
177        """
178        self.http = HttpClient(
179            api_key=api_key,
180            base_url=base_url,
181            timeout=timeout,
182            transport=transport,
183            telemetry_enabled=telemetry_enabled,
184            tracer_provider=tracer_provider,
185            error_reporter=error_reporter,
186            error_reporting_policy=error_reporting_policy,
187        )
188
189        self.orders = Orders(self.http)
190        self.payment_methods = PaymentMethods(self.http)
191        self.payouts = Payouts(self.http)
192        self.balance_transactions = BalanceTransactions(self.http)
193        self.financial_accounts = FinancialAccounts(self.http)
194        self.files = Files(self.http)
195        self.file_links = FileLinks(self.http)
196        self.file_references = FileReferences(self.http)
197        self.customers = Customers(self.http)
198        self.products = Products(self.http)
199        self.prices = Prices(self.http)
200        self.purchase_intents = PurchaseIntents(self.http)
201        self.refunds = Refunds(self.http)
202        self.chimes = Chimes(self.http)
203        self.schedules = Schedules(self.http)
204        self.broadcasts = Broadcasts(self.http)
205        self.message_templates = MessageTemplates(self.http)
206        self.otp = Otp(self.http)
207        self.apps = Apps(self.http)
208        self.keys = Keys(self.http)
209        self.spec = Spec(self.http)
210        self.balances = Balances(self.http)
211        self.upload_requests = UploadRequests(self.http)
212        self.children_policies = ChildrenPolicies(self.http)
213        self.operating_policies = OperatingPolicies(self.http)

Initialize a new Inttegro client.

Arguments:
  • api_key: Your Inttegro API key (required). Get this from your dashboard at https://studio.inttegro.com/settings/keys. Use test keys (sk_test_...) for development and live keys (sk_live_...) for production.
  • base_url: API base URL. Defaults to production (https://api.inttegro.com). Override for testing or staging environments.
  • timeout: Request timeout in seconds. Defaults to 30.0. Increase for long-running operations or slow networks.
  • transport: Custom HTTP transport adapter. Pass a requests.Session or custom transport for connection pooling, retries, or proxies.
  • telemetry_enabled: Emit spans to the configured OpenTelemetry provider. Defaults to True. The SDK never configures an exporter.
  • tracer_provider: Optional OpenTelemetry tracer provider override.
  • error_reporter: Optional application-owned callback for privacy-safe final-failure reports.
  • error_reporting_policy: Report unexpected failures by default, or use "all".
Raises:
  • ValueError: If api_key is empty or invalid
Example:
# Production usage
client = InttegroClient(api_key="sk_live_...")

# Development with custom timeout
client = InttegroClient(
    api_key="sk_test_...",
    timeout=60.0
)

# Testing with mock server
client = InttegroClient(
    api_key="sk_test_...",
    base_url="http://localhost:8080"
)
http: inttegro.http_client.HttpClient
@dataclass(frozen=True)
class InttegroResponse(typing.Generic[~T]):
12@dataclass(frozen=True)
13class InttegroResponse(Generic[T]):
14    """Decoded SDK value plus response-only HTTP metadata."""
15
16    data: T
17    status: int
18    headers: Mapping[str, str]
19    meta: Mapping[str, Any] | None = None
20
21    @property
22    def request_id(self) -> str | None:
23        return _header(self.headers, "x-request-id")
24
25    @property
26    def retry_after(self) -> str | None:
27        return _header(self.headers, "retry-after")

Decoded SDK value plus response-only HTTP metadata.

InttegroResponse( data: ~T, status: int, headers: Mapping[str, str], meta: Mapping[str, typing.Any] | None = None)
data: ~T
status: int
headers: Mapping[str, str]
meta: Mapping[str, typing.Any] | None = None
request_id: str | None
21    @property
22    def request_id(self) -> str | None:
23        return _header(self.headers, "x-request-id")
retry_after: str | None
25    @property
26    def retry_after(self) -> str | None:
27        return _header(self.headers, "retry-after")
class InttegroError(builtins.Exception):
13class InttegroError(Exception):
14    """Base error for the Inttegro SDK."""
15
16    report: "ErrorReport | None"
17
18    def __init__(self, message: str) -> None:
19        super().__init__(message)
20        self.report = None

Base error for the Inttegro SDK.

InttegroError(message: str)
18    def __init__(self, message: str) -> None:
19        super().__init__(message)
20        self.report = None
report: ErrorReport | None
class NetworkError(inttegro.InttegroError):
23class NetworkError(InttegroError):
24    """Raised for network connectivity errors."""
25
26    original: Exception | None
27
28    def __init__(self, message: str, original: Exception | None = None) -> None:
29        super().__init__(message)
30        self.original = original

Raised for network connectivity errors.

NetworkError(message: str, original: Exception | None = None)
28    def __init__(self, message: str, original: Exception | None = None) -> None:
29        super().__init__(message)
30        self.original = original
original: Exception | None
class RateLimitError(inttegro.APIError):
 82class RateLimitError(APIError):
 83    """Raised on 429 responses."""
 84
 85    retry_after: int | None
 86
 87    def __init__(
 88        self,
 89        message: str,
 90        status: int,
 91        code: str | None = None,
 92        error_type: str | None = None,
 93        url: str | None = None,
 94        detail: str | None = None,
 95        fix_code: str | None = None,
 96        cause: str | None = None,
 97        body: str | None = None,
 98        data: JSONValue = None,
 99        retry_after: int | None = None,
100        request_id: str | None = None,
101    ) -> None:
102        super().__init__(
103            message,
104            status=status,
105            code=code,
106            error_type=error_type,
107            url=url,
108            detail=detail,
109            fix_code=fix_code,
110            cause=cause,
111            body=body,
112            data=data,
113            request_id=request_id,
114        )
115        self.retry_after = retry_after

Raised on 429 responses.

RateLimitError( message: str, status: int, code: str | None = None, error_type: str | None = None, url: str | None = None, detail: str | None = None, fix_code: str | None = None, cause: str | None = None, body: str | None = None, data: str | int | float | bool | None | list[ForwardRef('JSONValue')] | dict[str, ForwardRef('JSONValue')] = None, retry_after: int | None = None, request_id: str | None = None)
 87    def __init__(
 88        self,
 89        message: str,
 90        status: int,
 91        code: str | None = None,
 92        error_type: str | None = None,
 93        url: str | None = None,
 94        detail: str | None = None,
 95        fix_code: str | None = None,
 96        cause: str | None = None,
 97        body: str | None = None,
 98        data: JSONValue = None,
 99        retry_after: int | None = None,
100        request_id: str | None = None,
101    ) -> None:
102        super().__init__(
103            message,
104            status=status,
105            code=code,
106            error_type=error_type,
107            url=url,
108            detail=detail,
109            fix_code=fix_code,
110            cause=cause,
111            body=body,
112            data=data,
113            request_id=request_id,
114        )
115        self.retry_after = retry_after
retry_after: int | None
@dataclass(frozen=True)
class SDKReportContext:
11@dataclass(frozen=True)
12class SDKReportContext:
13    language: Literal["python"]
14    version: str
SDKReportContext(language: Literal['python'], version: str)
language: Literal['python']
version: str
class TimeoutError(inttegro.NetworkError):
33class TimeoutError(NetworkError):
34    """Raised when a request times out."""

Raised when a request times out.

@dataclass(frozen=True)
class TraceReportContext:
34@dataclass(frozen=True)
35class TraceReportContext:
36    trace_id: str
37    span_id: str
TraceReportContext(trace_id: str, span_id: str)
trace_id: str
span_id: str