Skip to content

Models

components.payment_gateway.subcomponents.parties.models.ca_local_account_financial_instrument

CALocalAccountData dataclass

CALocalAccountData(
    *, institution_number, transit_number, account_number
)

Bases: DataClassJsonMixin

Unencrypted data for CALocalAccountFinancialInstrument

account_number instance-attribute

account_number

Up to 12-digit account number.

institution_number instance-attribute

institution_number

3-digit financial institution code.

transit_number instance-attribute

transit_number

5-digit branch transit code.

CALocalAccountFinancialInstrument

Bases: FinancialInstrument

A Canadian local account is a type of financial instrument identified by its Institution-Transit-Account numbers within the Canadian banking system.

__mapper_args__ class-attribute instance-attribute

__mapper_args__ = {"polymorphic_identity": CA_LOCAL_ACCOUNT}

__table_args__ class-attribute instance-attribute

__table_args__ = {'schema': PAYMENT_GATEWAY_SCHEMA_NAME}

__tablename__ class-attribute instance-attribute

__tablename__ = 'ca_local_account_financial_instrument'

__versioned__ class-attribute instance-attribute

__versioned__ = {'exclude': []}

ca_local_account_data class-attribute instance-attribute

ca_local_account_data = mapped_column(
    StringEncryptedTypeWithOnDemandDecryption(
        DataclassString(CALocalAccountData),
        get_financial_instruments_encryption_key,
        AesGcmEngine,
        "pkcs5",
    ),
    nullable=False,
)

id class-attribute instance-attribute

id = mapped_column(
    ForeignKey(id), primary_key=True, index=True
)

components.payment_gateway.subcomponents.parties.models.financial_instrument

FinancialInstrument

Bases: BaseModel

A financial instrument is a mechanism or identifier that enables a Party to send or receive money.

See

__mapper_args__ class-attribute instance-attribute

__mapper_args__ = {
    "polymorphic_abstract": True,
    "polymorphic_on": "instrument_type",
}

__table_args__ class-attribute instance-attribute

__table_args__ = {'schema': PAYMENT_GATEWAY_SCHEMA_NAME}

__tablename__ class-attribute instance-attribute

__tablename__ = 'financial_instrument'

description class-attribute instance-attribute

description = mapped_column(Text, nullable=True)

Human-readable description of the financial instrument.

instrument_type class-attribute instance-attribute

instrument_type = mapped_column(
    AlanBaseEnumTypeDecorator(FinancialInstrumentType),
    nullable=False,
)

Type of the financial instrument: IBAN account, local accounts, etc.

is_terminated property

is_terminated

legal_entity class-attribute instance-attribute

legal_entity = relationship(
    LegalEntity, foreign_keys=[legal_entity_id]
)

Legal Entity owning the financial instrument.

legal_entity_id class-attribute instance-attribute

legal_entity_id = mapped_column(
    ForeignKey(id), nullable=False, index=True
)

ID of the Legal Entity owning the financial instrument.

reference class-attribute instance-attribute

reference = mapped_column(Text, nullable=True)

Machine-readable reference of the financial instrument.

terminated_at class-attribute instance-attribute

terminated_at = mapped_column(DateTime, nullable=True)

Soft deletion timestamp (e.g. for GDPR compliance).

Termination is done at the initiative of the business layer. Financial instruments in terminal state cannot be modified or used anymore.

components.payment_gateway.subcomponents.parties.models.financial_instrument_provider_mapping

FinancialInstrumentProviderMapping

Bases: ProviderEntityMixin, BaseModel

__table_args__

__table_args__()
Source code in components/payment_gateway/subcomponents/parties/models/financial_instrument_provider_mapping.py
@declared_attr.directive
def __table_args__(cls) -> tuple[Any, ...]:
    from sqlalchemy import UniqueConstraint

    # Override the mixin's constraint with a shorter name to fit PostgreSQL's 63-char limit
    return (
        UniqueConstraint(
            "workspace_key",
            "external_id",
            name="financial_instrument_provider_map__uq_external_id_workspace",
        ),
        {"schema": PAYMENT_GATEWAY_SCHEMA_NAME},
    )

__tablename__ class-attribute instance-attribute

__tablename__ = 'financial_instrument_provider_mapping'

financial_instrument class-attribute instance-attribute

financial_instrument = relationship(
    FinancialInstrument,
    foreign_keys=[financial_instrument_id],
)

financial_instrument_id class-attribute instance-attribute

financial_instrument_id = mapped_column(
    UUID(as_uuid=True),
    ForeignKey(id),
    index=True,
    nullable=False,
)

components.payment_gateway.subcomponents.parties.models.helpers

FINANCIAL_INSTRUMENTS_ENCRYPTION_KEY_CONFIG_NAME module-attribute

FINANCIAL_INSTRUMENTS_ENCRYPTION_KEY_CONFIG_NAME = "PAYMENT_GATEWAY_FINANCIAL_INSTRUMENTS_ENCRYPTION_KEY_SECRET_NAME"

get_financial_instruments_encryption_key

get_financial_instruments_encryption_key()
Source code in components/payment_gateway/subcomponents/parties/models/helpers.py
def get_financial_instruments_encryption_key() -> str:
    return mandatory(
        raw_secret_from_config(FINANCIAL_INSTRUMENTS_ENCRYPTION_KEY_CONFIG_NAME)
    )

load_all_models

load_all_models()
Source code in components/payment_gateway/subcomponents/parties/models/helpers.py
def load_all_models() -> list[type[DbModel]]:
    from components.payment_gateway.subcomponents.parties.models.ca_local_account_financial_instrument import (
        CALocalAccountFinancialInstrument,
    )
    from components.payment_gateway.subcomponents.parties.models.financial_instrument import (
        FinancialInstrument,
    )
    from components.payment_gateway.subcomponents.parties.models.iban_account_financial_instrument import (
        IBANAccountFinancialInstrument,
    )
    from components.payment_gateway.subcomponents.parties.models.legal_entity import (
        LegalEntity,
    )

    return [
        LegalEntity,
        CALocalAccountFinancialInstrument,
        IBANAccountFinancialInstrument,
        FinancialInstrument,
        FinancialInstrumentProviderMapping,
    ]

components.payment_gateway.subcomponents.parties.models.iban_account_financial_instrument

IBANAccountData dataclass

IBANAccountData(*, iban, bank_country_code, bic)

Bases: DataClassJsonMixin

Unencrypted data for IBANAccountFinancialInstrument

bank_country_code instance-attribute

bank_country_code

Country code of the bank in ISO 3166-1 alpha-2 format.

bic instance-attribute

bic

BIC/SWIFT code of the bank.

iban instance-attribute

iban

IBAN of the bank account.

IBANAccountFinancialInstrument

Bases: FinancialInstrument

An IBAN account is a type of financial instrument identified by its IBAN.

__mapper_args__ class-attribute instance-attribute

__mapper_args__ = {'polymorphic_identity': IBAN_ACCOUNT}

__table_args__ class-attribute instance-attribute

__table_args__ = {'schema': PAYMENT_GATEWAY_SCHEMA_NAME}

__tablename__ class-attribute instance-attribute

__tablename__ = 'iban_account_financial_instrument'

__versioned__ class-attribute instance-attribute

__versioned__ = {'exclude': []}

iban_account_data class-attribute instance-attribute

iban_account_data = mapped_column(
    StringEncryptedTypeWithOnDemandDecryption(
        DataclassString(IBANAccountData),
        get_financial_instruments_encryption_key,
        AesGcmEngine,
        "pkcs5",
    ),
    nullable=False,
)

id class-attribute instance-attribute

id = mapped_column(
    ForeignKey(id), primary_key=True, index=True
)

components.payment_gateway.subcomponents.parties.models.legal_entity

LegalEntity

Bases: BaseModel

A legal entity is a person or organization with legal capacity to own assets, enter contracts, and conduct financial transactions.

See

__table_args__ class-attribute instance-attribute

__table_args__ = {'schema': PAYMENT_GATEWAY_SCHEMA_NAME}

__tablename__ class-attribute instance-attribute

__tablename__ = 'legal_entity'

address_city class-attribute instance-attribute

address_city = mapped_column_with_privacy(
    String(100),
    nullable=True,
    privacy_properties=PrivacyProperties(
        city,
        NoneOrRedactedHashed(),
        NoneOrEncrypted(),
        PassThrough(),
        PassThrough(),
    ),
)

City name.

address_country_code class-attribute instance-attribute

address_country_code = mapped_column_with_privacy(
    String(2),
    nullable=False,
    privacy_properties=PrivacyProperties(
        country,
        NoneOrRedactedHashed(),
        NoneOrEncrypted(),
        PassThrough(),
        PassThrough(),
        PassThrough(),
    ),
)

Country of the physical address in ISO 3166-1 alpha-2 format.

address_postal_code class-attribute instance-attribute

address_postal_code = mapped_column_with_privacy(
    String(20),
    nullable=True,
    privacy_properties=PrivacyProperties(
        postcode,
        NoneOrRedactedHashed(),
        NoneOrEncrypted(),
        PassThrough(),
        PassThrough(),
    ),
)

Postal/ZIP code.

address_street class-attribute instance-attribute

address_street = mapped_column_with_privacy(
    String(255),
    nullable=True,
    privacy_properties=PrivacyProperties(
        street,
        NoneOrRedactedHashed(),
        NoneOrEncrypted(),
        PassThrough(),
        PassThrough(),
    ),
)

Street address line.

address_street_2 class-attribute instance-attribute

address_street_2 = mapped_column_with_privacy(
    String(255),
    nullable=True,
    privacy_properties=PrivacyProperties(
        other,
        NoneOrRedactedHashed(),
        NoneOrEncrypted(),
        PassThrough(),
        PassThrough(),
    ),
)

Street address line 2 (apartment, floor, building, etc.).

address_subdivision_code class-attribute instance-attribute

address_subdivision_code = mapped_column_with_privacy(
    String(6),
    nullable=True,
    privacy_properties=PrivacyProperties(
        province,
        NoneOrRedactedHashed(),
        NoneOrEncrypted(),
        PassThrough(),
        PassThrough(),
        PassThrough(),
    ),
)

State/province/territory code in ISO 3166-2 format (e.g., "CA-ON", "FR-PF", "US-NY").

entity_type class-attribute instance-attribute

entity_type = mapped_column(
    AlanBaseEnumTypeDecorator(LegalEntityType),
    nullable=False,
)

Type of the legal entity: organization or person.

first_name class-attribute instance-attribute

first_name = mapped_column_with_privacy(
    String(100),
    nullable=True,
    privacy_properties=PrivacyProperties(
        first_name,
        NoneOrRedactedHashed(),
        NoneOrEncrypted(),
        FakeFirstName(),
        PassThrough(),
    ),
)

First name (persons only).

is_terminated property

is_terminated

last_name class-attribute instance-attribute

last_name = mapped_column_with_privacy(
    String(100),
    nullable=True,
    privacy_properties=PrivacyProperties(
        last_name,
        NoneOrRedactedHashed(),
        NoneOrEncrypted(),
        FakeLastName(),
        PassThrough(),
    ),
)

Last name (persons only).

legal_country_code class-attribute instance-attribute

legal_country_code = mapped_column_with_privacy(
    String(2),
    nullable=False,
    privacy_properties=PrivacyProperties(
        country,
        NoneOrRedactedHashed(),
        NoneOrEncrypted(),
        PassThrough(),
        PassThrough(),
        PassThrough(),
    ),
)

Country of legal registration/jurisdiction in ISO 3166-1 alpha-2 format.

legal_name class-attribute instance-attribute

legal_name = mapped_column_with_privacy(
    String(255),
    nullable=False,
    privacy_properties=PrivacyProperties(
        some_name,
        NoneOrRedactedHashed(),
        NoneOrEncrypted(),
        FakeFullname(),
        PassThrough(),
    ),
)

Official name (organization) or full name (person).

terminated_at class-attribute instance-attribute

terminated_at = mapped_column(DateTime, nullable=True)

Soft deletion timestamp (e.g. for GDPR compliance).

Termination is done at the initiative of the business layer. Legal entities in terminal state cannot be modified or used anymore.

unique_key class-attribute instance-attribute

unique_key = mapped_column(
    String(255), nullable=False, unique=True, index=True
)

Namespaced unique identifier for deduplication and idempotency.