Skip to content

Entities

ExpenseLimitRuleId module-attribute

ExpenseLimitRuleId = NewType('ExpenseLimitRuleId', UUID)

RuleCriterion module-attribute

RuleCriterion = (
    CountryCriterion
    | ProcessingTypeCriterion
    | MCCCriterion
    | MerchantCriterion
    | CurrencyCriterion
)

Criterion to match against a payment.

All criteria must be met for a rule to apply.

The order of the criteria doesn't matter, however each type of criterion should be used at most once.

UsageRestrictionRuleId module-attribute

UsageRestrictionRuleId = NewType(
    "UsageRestrictionRuleId", UUID
)

CountryCriterion dataclass

CountryCriterion(
    condition, country_codes, _type="CountryCriterion"
)

Bases: DataClassJsonMixin

Matches payments based on the merchant country code.

condition instance-attribute

condition

country_codes instance-attribute

country_codes

CurrencyCriterion dataclass

CurrencyCriterion(same_as_card, _type='CurrencyCriterion')

Bases: DataClassJsonMixin

Matches payments against the card currency.

same_as_card instance-attribute

same_as_card

ExpenseLimitRule dataclass

ExpenseLimitRule(
    id,
    card_id,
    description,
    reference,
    amount,
    currency,
    period,
    criteria,
    is_active,
    first_day,
    start,
    end,
    external_id,
)

Expense limit rule that applies on payments made with a card.

Expense limits set a limit on the total amount that can be spent with a card over a given period (day, month, ...). Once this limit is reached, the card can't be used anymore until the period ends.

Expense limits are immutable except for their amount once created, they can't be changed or deleted. However, they can be activated or deactivated at any time.

The amount can also be changed at any time, however this can have unexpected effects in the middle of a validity period (for example, monthly expense caps). It is best to change the amount outside at the beginning or end of a period or on an inactive one.

All criteria must be met for the rule to apply.

All active rules apply simultaneously on each payment made with the card. The order in which they are created doesn't matter. If a payment exceeds any active limit then it is blocked.

amount instance-attribute

amount

card_id instance-attribute

card_id

criteria instance-attribute

criteria

currency instance-attribute

currency

description instance-attribute

description

end instance-attribute

end

external_id instance-attribute

external_id

Opaque identifier of the rule in the payment service provider.

first_day instance-attribute

first_day

id instance-attribute

id

is_active instance-attribute

is_active

period instance-attribute

period

reference instance-attribute

reference

start instance-attribute

start

MCCCriterion dataclass

MCCCriterion(condition, mccs, _type='MCCCriterion')

Bases: DataClassJsonMixin

Matches payments based on the merchant category code.

condition instance-attribute

condition

mccs instance-attribute

mccs

__eq__

__eq__(other)
Source code in components/payment_gateway/subcomponents/rules/protected/entities.py
def __eq__(self, other: object) -> bool:  # noqa: D105
    if isinstance(other, MCCCriterion):
        return (
            set(self.mccs) == set(other.mccs) and self.condition == other.condition
        )

    return False

MerchantCriterion dataclass

MerchantCriterion(
    condition, merchants, _type="MerchantCriterion"
)

Bases: DataClassJsonMixin

Matches payments based on the merchant identifiers.

condition instance-attribute

condition

merchants instance-attribute

merchants

__eq__

__eq__(other)
Source code in components/payment_gateway/subcomponents/rules/protected/entities.py
def __eq__(self, other: object) -> bool:  # noqa: D105
    if isinstance(other, MerchantCriterion):
        return (
            set(self.merchants) == set(other.merchants)
            and self.condition == other.condition
        )

    return False

MerchantIdPair dataclass

MerchantIdPair(acquirer_id, merchant_id)

Bases: DataClassJsonMixin

Merchant identifiers.

acquirer_id instance-attribute

acquirer_id

merchant_id instance-attribute

merchant_id

__eq__

__eq__(other)
Source code in components/payment_gateway/subcomponents/rules/protected/entities.py
def __eq__(self, other: object) -> bool:  # noqa: D105
    if isinstance(other, MerchantIdPair):
        return (
            self.acquirer_id == other.acquirer_id
            and self.merchant_id == other.merchant_id
        )

    return False

ProcessingTypeCriterion dataclass

ProcessingTypeCriterion(
    condition,
    processing_types,
    _type="ProcessingTypeCriterion",
)

Bases: DataClassJsonMixin

Matches payments based on the processing type.

condition instance-attribute

condition

processing_types instance-attribute

processing_types

UsageRestrictionRule dataclass

UsageRestrictionRule(
    id,
    account_id,
    description,
    reference,
    criteria,
    is_active,
    start,
    end,
    external_id,
)

Usage restriction rule that applies on payments made with any card linked to an account.

Usage restrictions are immutable; once created, they can't be changed or deleted. However, they can be activated or deactivated at any time.

All criteria must be met for the rule to apply.

All active rules apply simultaneously on each payment made with a card linked to the account. The order in which they are created doesn't matter. If a payment matches any active rule then it is blocked.

account_id instance-attribute

account_id

criteria instance-attribute

criteria

description instance-attribute

description

end instance-attribute

end

external_id instance-attribute

external_id

Opaque identifier of the rule in the payment service provider.

id instance-attribute

id

is_active instance-attribute

is_active

reference instance-attribute

reference

start instance-attribute

start