Models
components.payment_gateway.subcomponents.cards.models.card ¶
Card ¶
Bases: BaseModel
__table_args__
class-attribute
instance-attribute
¶
__table_args__ = (
UniqueConstraint(
"provider",
"external_id",
name="card__unique_external_id_per_provider",
),
{"schema": PAYMENT_GATEWAY_SCHEMA_NAME},
)
account
class-attribute
instance-attribute
¶
account_id
class-attribute
instance-attribute
¶
all_card_provisioning
class-attribute
instance-attribute
¶
all_card_provisioning = relationship(
"CardProvisioning",
back_populates="card",
order_by="CardProvisioning.provisioning_date.desc()",
uselist=True,
viewonly=True,
)
card_holder
class-attribute
instance-attribute
¶
card_holder_id
class-attribute
instance-attribute
¶
current_status_log
class-attribute
instance-attribute
¶
current_status_log = relationship(
"CardStatusLog",
uselist=False,
viewonly=True,
primaryjoin="and_( CardStatusLog.card_id == Card.id, CardStatusLog.created_at == ( select(func.max(CardStatusLog.created_at)) .where(CardStatusLog.card_id == Card.id) .correlate(Card) .scalar_subquery() ))",
)
display_name
class-attribute
instance-attribute
¶
display_name = mapped_column_with_privacy(
Text,
nullable=False,
privacy_properties=PrivacyProperties(
some_name,
NoneOrRedactedHashed(),
NoneOrEncrypted(),
FakeFullname(),
PassThrough(),
NoneOrPrefixRedactedHashed(),
),
)
expiration_date
class-attribute
instance-attribute
¶
external_id
class-attribute
instance-attribute
¶
ID used by the external payment service provider to identify the card.
issuance_reason
class-attribute
instance-attribute
¶
last_four_digits
class-attribute
instance-attribute
¶
payments
class-attribute
instance-attribute
¶
payments = relationship(
"CardTransfer",
back_populates="card",
order_by="CardTransfer.created_at.desc()",
uselist=True,
viewonly=True,
)
provider
class-attribute
instance-attribute
¶
The payment service provider that issued the card.
status_history
class-attribute
instance-attribute
¶
status_history = relationship(
"CardStatusLog",
back_populates="card",
order_by="CardStatusLog.created_at.desc()",
uselist=True,
viewonly=True,
)
terminated_at
class-attribute
instance-attribute
¶
Termination is done at the initiative of the business layer. Cards in terminal state cannot be modified or used anymore.
validate_provider
class-attribute
instance-attribute
¶
CardStatusLog ¶
Bases: BaseModel
__repr__ ¶
__table_args__
class-attribute
instance-attribute
¶
card
class-attribute
instance-attribute
¶
card_id
class-attribute
instance-attribute
¶
status
class-attribute
instance-attribute
¶
suspension_source
class-attribute
instance-attribute
¶
suspension_source = mapped_column(
AlanBaseEnumTypeDecorator(CardSuspensionSource),
nullable=True,
)
components.payment_gateway.subcomponents.cards.models.card_holder ¶
CardHolder ¶
Bases: BaseModel
__table_args__
class-attribute
instance-attribute
¶
__table_args__ = (
UniqueConstraint(
"provider",
"external_id",
name="card_holder__unique_external_id_per_provider",
),
CheckConstraint(
"(external_id IS NULL) = (provider IN ('adyen'))",
name="card_holder__no_external_id_for_adyen",
),
{"schema": PAYMENT_GATEWAY_SCHEMA_NAME},
)
cards
class-attribute
instance-attribute
¶
cards = relationship(
"Card",
back_populates="card_holder",
order_by="Card.created_at.desc()",
uselist=True,
)
display_name
class-attribute
instance-attribute
¶
display_name = mapped_column_with_privacy(
Text,
nullable=True,
privacy_properties=PrivacyProperties(
some_name,
NoneOrRedactedHashed(),
NoneOrEncrypted(),
FakeFullname(),
PassThrough(),
NoneOrPrefixRedactedHashed(),
),
)
Display name is usually a simple combination of the first and last names, but can be shorter or abbreviated to fit on a card or any related document.
If too long, it will be truncated with no attempt at making it more readable. If that causes issues, the short name should be used instead. But in many cases truncation will be good enough, like for shipping labels.
Display name is optional because it will be derived from first and last names by default. However providing it here gives the flexibility to override the default for a better rendering in specific contexts.
external_id
class-attribute
instance-attribute
¶
ID used by the external payment service provider to identify the account holder. Optional as this concept does not exist for all providers.
first_name
class-attribute
instance-attribute
¶
first_name = mapped_column_with_privacy(
Text,
nullable=False,
privacy_properties=PrivacyProperties(
first_name,
NoneOrRedactedHashed(),
NoneOrEncrypted(),
FakeFirstName(),
PassThrough(),
NoneOrPrefixRedactedHashed(),
),
)
last_name
class-attribute
instance-attribute
¶
last_name = mapped_column_with_privacy(
Text,
nullable=False,
privacy_properties=PrivacyProperties(
last_name,
NoneOrRedactedHashed(),
NoneOrEncrypted(),
FakeLastName(),
PassThrough(),
NoneOrPrefixRedactedHashed(),
),
)
provider
class-attribute
instance-attribute
¶
The payment service provider the card holder is declared to.
short_name
class-attribute
instance-attribute
¶
short_name = mapped_column_with_privacy(
String(18),
nullable=True,
privacy_properties=PrivacyProperties(
some_name,
NoneOrRedactedHashed(),
NoneOrEncrypted(),
FakeFullname(),
PassThrough(),
NoneOrPrefixRedactedHashed(),
),
)
Short name is a shorter version of the display name to meet specific constraints, like fitting on a card in vertical format. In these cases, the name must still be both readable and recognizable.
Like the display name, the short name is optional because it can be derived from the first and last names, however its very short length makes automatic generation less reliablem so it is better to provide it explicitly.
terminated_at
class-attribute
instance-attribute
¶
Termination is done at the initiative of the business layer. Card holders in terminal state cannot be modified or used anymore.
validate_provider
class-attribute
instance-attribute
¶
components.payment_gateway.subcomponents.cards.models.card_order ¶
components.payment_gateway.subcomponents.cards.models.card_provisioning ¶
CardProvisioning ¶
Bases: BaseModel
__table_args__
class-attribute
instance-attribute
¶
__table_args__ = (
UniqueConstraint(
"provider",
"external_id",
name="card_provisioning__unique_external_id_per_provider",
),
{"schema": PAYMENT_GATEWAY_SCHEMA_NAME},
)