Skip to content

Business logic

Account Holders

AccountHolderLogic

AccountHolderLogic(
    account_holder_queries, account_holder_actions
)

This class is the public interface to the account holder logic.

Implements the following Nullable patterns: - Nullables: https://www.jamesshore.com/v2/projects/nullables/testing-without-mocks#nullables ⧉ - Parameterless instantiation: https://www.jamesshore.com/v2/projects/nullables/testing-without-mocks#instantiation ⧉

Source code in components/payment_gateway/subcomponents/accounts/protected/business_logic/account_holders.py
def __init__(
    self,
    account_holder_queries: AccountHolderQueries,
    account_holder_actions: AccountHolderActions,
) -> None:
    self.account_holder_queries = account_holder_queries
    self.account_holder_actions = account_holder_actions

account_holder_actions instance-attribute

account_holder_actions = account_holder_actions

account_holder_queries instance-attribute

account_holder_queries = account_holder_queries

create classmethod

create()

Normal factory

Source code in components/payment_gateway/subcomponents/accounts/protected/business_logic/account_holders.py
@classmethod
def create(cls) -> "AccountHolderLogic":
    """Normal factory"""
    return cls(
        AccountHolderQueries(),
        AccountHolderActions.create(),
    )

create_null classmethod

create_null()

Null factory

Source code in components/payment_gateway/subcomponents/accounts/protected/business_logic/account_holders.py
@classmethod
def create_null(
    cls,
) -> "AccountHolderLogic":
    """Null factory"""
    return cls(
        AccountHolderQueries(),
        AccountHolderActions.create_null(),
    )

declare_account_holder

declare_account_holder(
    session, /, description, external_id, reference=None
)

Declare an account holder.

Source code in components/payment_gateway/subcomponents/accounts/protected/business_logic/account_holders.py
@obs.api_call()
def declare_account_holder(
    self,
    session: Session,
    /,
    description: str,
    external_id: str,
    reference: str | None = None,
) -> AccountHolderId:
    """
    Declare an account holder.
    """
    return self.account_holder_actions.declare_account_holder(
        session,
        description=description,
        external_id=external_id,
        reference=reference,
    )

get_account_holder

get_account_holder(session, /, id)

Get an account holder entity from its ID.

Source code in components/payment_gateway/subcomponents/accounts/protected/business_logic/account_holders.py
@obs.api_call()
def get_account_holder(
    self,
    session: Session,
    /,
    id: AccountHolderId,
) -> AccountHolder:
    """
    Get an account holder entity from its ID.
    """
    return self.account_holder_queries.get_account_holder(
        session,
        id,
    )

get_account_holder_id_by_external_id

get_account_holder_id_by_external_id(
    session, /, provider, external_id
)

Get an account holder entity from its external ID.

Source code in components/payment_gateway/subcomponents/accounts/protected/business_logic/account_holders.py
@obs.api_call()
def get_account_holder_id_by_external_id(
    self,
    session: Session,
    /,
    provider: PaymentServiceProvider,
    external_id: str,
) -> AccountHolderId:
    """
    Get an account holder entity from its external ID.
    """
    return self.account_holder_queries.get_account_holder_id_by_external_id(
        session,
        provider=provider,
        external_id=external_id,
    )

terminate_account_holder

terminate_account_holder(session, /, id)

Terminate an account holder.

Account holders in terminal state cannot be modified or used anymore.

Source code in components/payment_gateway/subcomponents/accounts/protected/business_logic/account_holders.py
@obs.api_call()
def terminate_account_holder(
    self,
    session: Session,
    /,
    id: AccountHolderId,
) -> None:
    """
    Terminate an account holder.

    Account holders in terminal state cannot be modified or used anymore.
    """
    self.account_holder_actions.terminate_account_holder(
        session,
        id,
    )
update_account_holder_legal_name(
    session, /, id, legal_name
)

Update the legal name of an account holder.

Source code in components/payment_gateway/subcomponents/accounts/protected/business_logic/account_holders.py
@obs.api_call()
def update_account_holder_legal_name(
    self,
    session: Session,
    /,
    id: AccountHolderId,
    legal_name: str,
) -> None:
    """
    Update the legal name of an account holder.
    """
    return self.account_holder_actions.update_account_holder_legal_name(
        session,
        id=id,
        legal_name=legal_name,
    )

Accounts

AccountLogic

AccountLogic(account_queries, account_actions)

This class is the public interface to the account logic.

Implements the following Nullable patterns: - Nullables: https://www.jamesshore.com/v2/projects/nullables/testing-without-mocks#nullables ⧉ - Parameterless instantiation: https://www.jamesshore.com/v2/projects/nullables/testing-without-mocks#instantiation ⧉

Source code in components/payment_gateway/subcomponents/accounts/protected/business_logic/accounts.py
def __init__(
    self, account_queries: AccountQueries, account_actions: AccountActions
) -> None:
    self.account_queries = account_queries
    self.account_actions = account_actions

account_actions instance-attribute

account_actions = account_actions

account_queries instance-attribute

account_queries = account_queries

activate_account

activate_account(session, /, id)

Activate an account.

Source code in components/payment_gateway/subcomponents/accounts/protected/business_logic/accounts.py
@obs.api_call()
def activate_account(
    self,
    session: Session,
    /,
    id: AccountId,
) -> None:
    """
    Activate an account.
    """
    self.account_actions.activate_account(
        session,
        id,
    )

create classmethod

create()

Normal factory

Source code in components/payment_gateway/subcomponents/accounts/protected/business_logic/accounts.py
@classmethod
def create(cls) -> "AccountLogic":
    """Normal factory"""
    return cls(
        AccountQueries(),
        AccountActions.create(),
    )

create_account

create_account(
    session,
    /,
    account_holder_id,
    description,
    reference=None,
)

Create an account for an account holder.

Source code in components/payment_gateway/subcomponents/accounts/protected/business_logic/accounts.py
@obs.api_call()
def create_account(
    self,
    session: Session,
    /,
    account_holder_id: AccountHolderId,
    description: str,
    reference: str | None = None,
) -> AccountId:
    """
    Create an account for an account holder.
    """
    return self.account_actions.create_account(
        session,
        account_holder_id=account_holder_id,
        description=description,
        reference=reference,
    )

create_null classmethod

create_null(track_adyen_requests=None)

Null factory

Source code in components/payment_gateway/subcomponents/accounts/protected/business_logic/accounts.py
@classmethod
def create_null(
    cls,
    track_adyen_requests: list[tuple[str, dict, dict]] | None = None,  # type: ignore[type-arg]
) -> "AccountLogic":
    """Null factory"""
    return cls(
        AccountQueries(),
        AccountActions.create_null(track_adyen_requests=track_adyen_requests),
    )

deactivate_account

deactivate_account(session, /, id)

Deactivate an account.

Source code in components/payment_gateway/subcomponents/accounts/protected/business_logic/accounts.py
@obs.api_call()
def deactivate_account(
    self,
    session: Session,
    /,
    id: AccountId,
) -> None:
    """
    Deactivate an account.
    """
    self.account_actions.deactivate_account(
        session,
        id,
    )

get_account

get_account(session, /, id)

Get an account entity from its ID.

Source code in components/payment_gateway/subcomponents/accounts/protected/business_logic/accounts.py
@obs.api_call()
def get_account(
    self,
    session: Session,
    /,
    id: AccountId,
) -> Account:
    """
    Get an account entity from its ID.
    """
    return self.account_queries.get_account(
        session,
        id,
    )

get_account_id_by_external_id

get_account_id_by_external_id(
    session, /, provider, external_id
)

Find an account using its external id.

Source code in components/payment_gateway/subcomponents/accounts/protected/business_logic/accounts.py
@obs.api_call()
def get_account_id_by_external_id(
    self,
    session: Session,
    /,
    provider: PaymentServiceProvider,
    external_id: str,
) -> AccountId:
    """
    Find an account using its external id.
    """
    return self.account_queries.get_account_id_by_external_id(
        session,
        provider=provider,
        external_id=external_id,
    )

get_account_ids_for_account_holder

get_account_ids_for_account_holder(
    session, /, account_holder_id
)

Get all the account IDs for an account holder.

Source code in components/payment_gateway/subcomponents/accounts/protected/business_logic/accounts.py
@obs.api_call()
def get_account_ids_for_account_holder(
    self,
    session: Session,
    /,
    account_holder_id: AccountHolderId,
) -> list[AccountId]:
    """
    Get all the account IDs for an account holder.
    """
    return self.account_queries.get_account_ids_for_account_holder(
        session,
        account_holder_id,
    )

get_accounts_for_account_holder

get_accounts_for_account_holder(
    session, /, account_holder_id
)

Get all the accounts for an account holder.

Source code in components/payment_gateway/subcomponents/accounts/protected/business_logic/accounts.py
@obs.api_call()
def get_accounts_for_account_holder(
    self,
    session: Session,
    /,
    account_holder_id: AccountHolderId,
) -> list[Account]:
    """
    Get all the accounts for an account holder.
    """
    return self.account_queries.get_accounts_for_account_holder(
        session,
        account_holder_id,
    )

terminate_account

terminate_account(session, /, id)

Terminate an account.

Accounts in terminal state cannot be modified or used anymore.

Source code in components/payment_gateway/subcomponents/accounts/protected/business_logic/accounts.py
@obs.api_call()
def terminate_account(
    self,
    session: Session,
    /,
    id: AccountId,
) -> None:
    """
    Terminate an account.

    Accounts in terminal state cannot be modified or used anymore.
    """
    self.account_actions.terminate_account(
        session,
        id,
    )

update_account

update_account(session, /, id, description, reference=None)

Update the account description and reference

Source code in components/payment_gateway/subcomponents/accounts/protected/business_logic/accounts.py
@obs.api_call()
def update_account(
    self,
    session: Session,
    /,
    id: AccountId,
    description: str,
    reference: str | None = None,
) -> None:
    """
    Update the account description and reference
    """
    return self.account_actions.update_account(
        session,
        id=id,
        description=description,
        reference=reference,
    )