Inttegro.FinancialAccounts (inttegro v0.2.0)

Copy Markdown View Source

Creates, connects, and controls the accounts an application uses to move money.

A financial account represents a wallet, Ghana bank account, or Dosh account. The account owns its identity and verification state; push and pull are separate capabilities layered on top:

  • Push allows Inttegro to send payouts and other supported transfers to the account.
  • Pull allows supported payments to collect funds from the account. Enabling it records a mandate using the payer's real IP address and user agent.

Use create/3 when Inttegro should provision or manage the account and connect/3 when the account already exists outside Inttegro. Both accept one of the concrete request types linked from Inttegro.FinancialAccounts.CreateRequest.t/0. Connecting an account does not imply that every money-movement capability is enabled; inspect push_configuration, pull_configuration, and verification on the returned account.

Typical lifecycle

create or connect
  -> complete any required verification
  -> enable push, pull, or both
  -> use the account for supported activity
  -> disable a capability or disconnect the account

disconnect/3 stops new activity without erasing the account's history. reconnect/3 restores the relationship, but callers should still inspect which capabilities are active afterward.

All state-changing calls accept request options as their last argument. Supply a stable :idempotency_key when retrying the same logical change after a timeout or connection failure.

Summary

Functions

Attaches an existing wallet, Ghana bank account, or Dosh account to the application.

Provisions a new wallet, Ghana bank account, or Dosh account managed through Inttegro.

Stops new supported payments from pulling funds from the account.

Prevents the account from receiving new payouts and supported transfers.

Disconnects the financial account from new Inttegro activity without deleting its history.

Enables supported payments to collect funds from the account.

Enables the account to receive payouts and other supported transfers from Inttegro.

Retrieves the current state of one financial account owned by the authenticated application.

Retrieves one numbered page of financial accounts owned by the authenticated application.

Reconnects a previously disconnected financial account.

Changes mutable metadata on an existing financial account.

Functions

connect(client, request, options \\ [])

Attaches an existing wallet, Ghana bank account, or Dosh account to the application.

Use connect/3 for an account that already exists outside Inttegro. It records the relationship and may initiate provider verification. It does not silently grant every capability: read the returned account's verification, push, and pull configuration before using it.

Example: connect a mobile-money wallet

mobile_money =
  Inttegro.FinancialAccounts.WalletRequestWalletMobileMoney.new!(
    account_number: "0244000042",
    network: :mtn
  )

wallet =
  Inttegro.FinancialAccounts.WalletRequestWallet.new!(
    type: :mobile_money,
    mobile_money: mobile_money
  )

request =
  Inttegro.FinancialAccounts.WalletRequest.new!(
    currency: "ghs",
    label: "Operations wallet",
    owner: owner,
    reference: "operations-wallet-001",
    type: :wallet,
    wallet: wallet
  )

Inttegro.FinancialAccounts.connect(client, request,
  idempotency_key: "connect-operations-wallet-001"
)

Returns {:ok, account} when the relationship is recorded, or {:error, exception} when the request is invalid, rejected by a provider, or cannot be completed. A successful response can still require later verification.

create(client, request, options \\ [])

Provisions a new wallet, Ghana bank account, or Dosh account managed through Inttegro.

Use this operation when Inttegro should create or establish the financial account. To attach an account that already exists, use connect/3 instead. Choose the concrete request struct that matches the account type; Inttegro.FinancialAccounts.CreateRequest.t/0 links all supported variants.

The returned Inttegro.FinancialAccounts.FinancialAccount is the current account snapshot. Creation does not guarantee that push or pull is ready: inspect verification, push_configuration, and pull_configuration before offering the account for money movement.

Example: create a mobile-money wallet

owner =
  Inttegro.FinancialAccounts.OwnerInput.new!(
    name: "Ama Mensah",
    address:
      Inttegro.FinancialAccounts.OwnerInputAddress.new!(country: "GH")
  )

mobile_money =
  Inttegro.FinancialAccounts.WalletRequestWalletMobileMoney.new!(
    account_number: "0244000042",
    network: :mtn
  )

wallet =
  Inttegro.FinancialAccounts.WalletRequestWallet.new!(
    type: :mobile_money,
    mobile_money: mobile_money
  )

request =
  Inttegro.FinancialAccounts.WalletRequest.new!(
    currency: "ghs",
    label: "Primary collections wallet",
    owner: owner,
    reference: "wallet-primary-001",
    type: :wallet,
    wallet: wallet
  )

Inttegro.FinancialAccounts.create(client, request,
  idempotency_key: "create-wallet-primary-001"
)

Returns {:ok, account} or {:error, exception}. Reuse the idempotency key only when retrying this same creation intent.

disable_pull(client, request, options \\ [])

Stops new supported payments from pulling funds from the account.

The operation removes the active pull configuration and its mandate. It does not cancel or reverse payment activity already submitted. Push remains independent and is unchanged.

Example

request =
  Inttegro.FinancialAccounts.IDRequest.new!(account_id: "fa_...")

Inttegro.FinancialAccounts.disable_pull(client, request,
  idempotency_key: "disable-pull-fa-001"
)

Returns the updated account as {:ok, account} or {:error, exception}.

disable_push(client, request, options \\ [])

Prevents the account from receiving new payouts and supported transfers.

Disabling push does not reverse transfers already submitted. If the account is configured as a payout destination, the operation is rejected unless unset_as_payout_destination is true; this avoids silently leaving payout routing pointed at a disabled account.

Example

request =
  Inttegro.FinancialAccounts.DisableRequest.new!(
    account_id: "fa_...",
    unset_as_payout_destination: true
  )

Inttegro.FinancialAccounts.disable_push(client, request,
  idempotency_key: "disable-push-fa-001"
)

Returns the updated account as {:ok, account} or {:error, exception}.

disconnect(client, request, options \\ [])

Disconnects the financial account from new Inttegro activity without deleting its history.

Use this when the relationship should be suspended but historical payments, payouts, and audit records must remain referentially intact. If the account is currently a payout destination, set unset_as_payout_destination: true or the request is rejected.

Example

request =
  Inttegro.FinancialAccounts.DisableRequest.new!(
    account_id: "fa_...",
    unset_as_payout_destination: true
  )

Inttegro.FinancialAccounts.disconnect(client, request,
  idempotency_key: "disconnect-fa-001"
)

Returns {:ok, account} with its disconnection state or {:error, exception}. Disconnecting does not reverse activity already submitted.

enable_pull(client, request, options \\ [])

Enables supported payments to collect funds from the account.

Pull describes money moving from this account. Enabling it creates a mandate. Pass the real payer IP address and user agent captured by your application; Inttegro deliberately does not infer them from the server-to-server SDK request. Do not substitute your backend's network identity for the payer context.

Example

request =
  Inttegro.FinancialAccounts.EnablePullRequest.new!(
    account_id: "fa_...",
    ip_address: payer_ip_address,
    user_agent: payer_user_agent
  )

Inttegro.FinancialAccounts.enable_pull(client, request,
  idempotency_key: "enable-pull-fa-001"
)

Returns {:ok, account} with a populated pull_configuration and mandate when enabled, or {:error, exception} when the account or supplied mandate context is ineligible.

enable_push(client, request, options \\ [])

Enables the account to receive payouts and other supported transfers from Inttegro.

Push describes money moving to this account. Enabling it does not enable collections from the account; that is the separate pull capability. Provider support and verification can vary, so inspect push_configuration on the returned account rather than assuming the capability was available from the account type alone.

Example

request =
  Inttegro.FinancialAccounts.IDRequest.new!(account_id: "fa_...")

Inttegro.FinancialAccounts.enable_push(client, request,
  idempotency_key: "enable-push-fa-001"
)

Returns {:ok, account} when the capability is enabled, or {:error, exception} when account state, verification, or provider policy prevents it.

lookup(client, request, options \\ [])

Retrieves the current state of one financial account owned by the authenticated application.

Lookup has no account-side effect. Use it after creation, connection, capability changes, or verification to refresh the authoritative state. In particular, inspect verification, disconnected_at, push_configuration, and pull_configuration instead of inferring readiness from an earlier request.

Example

request =
  Inttegro.FinancialAccounts.IDRequest.new!(account_id: "fa_...")

case Inttegro.FinancialAccounts.lookup(client, request) do
  {:ok, %Inttegro.FinancialAccounts.FinancialAccount{} = account} ->
    {:ok, account}

  {:error, %Inttegro.Errors.APIError{status: 404}} ->
    {:error, :financial_account_not_found}

  {:error, error} ->
    {:error, error}
end

Returns {:ok, account} or {:error, exception}.

page(client, request, options \\ [])

Retrieves one numbered page of financial accounts owned by the authenticated application.

page_number starts at 1; page_size controls the maximum number of accounts returned. The response's size is the number returned in this page, not a total across the application. When building an inventory or calculating totals, continue requesting pages until a page is empty.

Example

request =
  Inttegro.FinancialAccounts.PageRequest.new!(
    page_number: 1,
    page_size: 100
  )

with {:ok, page} <- Inttegro.FinancialAccounts.page(client, request) do
  Enum.each(page.accounts, &IO.inspect(&1.id))
end

Returns {:ok, %Inttegro.FinancialAccounts.Page{}} or {:error, exception}.

reconnect(client, request, options \\ [])

Reconnects a previously disconnected financial account.

Reconnection restores the relationship but does not promise that every previous capability or verification remains active. Inspect the returned account and explicitly enable any required push or pull capability that is absent.

Example

request =
  Inttegro.FinancialAccounts.IDRequest.new!(account_id: "fa_...")

case Inttegro.FinancialAccounts.reconnect(client, request,
       idempotency_key: "reconnect-fa-001"
     ) do
  {:ok, account} ->
    {:ok, account.push_configuration, account.pull_configuration}

  {:error, error} ->
    {:error, error}
end

Returns {:ok, account} or {:error, exception}.

update(client, request, options \\ [])

Changes mutable metadata on an existing financial account.

The request can update the label, description, external reference, owner details, or custom_data. It does not replace account credentials, change the account type, or enable push or pull. Use the dedicated capability operations for those state changes.

Example

request =
  Inttegro.FinancialAccounts.UpdateRequest.new!(
    account_id: "fa_...",
    label: "Treasury payouts",
    reference: "treasury-payouts-2026"
  )

Inttegro.FinancialAccounts.update(client, request,
  idempotency_key: "rename-fa-treasury-payouts-2026"
)

Returns the updated account snapshot as {:ok, account} or an error tuple. A transport error leaves the outcome unknown, so retry the same intent with the same idempotency key.