components.payment_gateway.public.transfers ¶
This module defines the public API for the transfers subcomponent.
Only business logic is exposed here. Basic entities and enums are exposed in separate modules to avoid loading the entire subcomponent with its models and dependencies when they are not needed.
Classes¶
AccountTransferRouter ¶
Bases: ABC
Router for the account transfer processor to route the account transfers (a.k.a. Adyen's "internalTransfer") to the appropriate entities
Note: the source or the destination account must be a known account to the Payment Gateway
Functions¶
route
abstractmethod
¶
Route an account transfer to the appropriate entities.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
direction
|
TransferDirection
|
The transfer direction |
required |
reference
|
str
|
The transfer reference; this is mostly used for tracking and reconciliation |
required |
account_id
|
AccountId
|
The ID of the account involved in the transfer |
required |
effective_date
|
datetime
|
The effective date at which the transfer occurred |
required |
Returns:
| Type | Description |
|---|---|
AccountTransferRoutingResult
|
The entities with which the transfer should be associated. |
Source code in components/payment_gateway/subcomponents/transfers/protected/routers.py
AccountTransferRoutingException ¶
Bases: PaymentGatewayException
Exception raised for errors in the account transfer routing process.
Attributes:
| Name | Type | Description |
|---|---|---|
message |
Explanation of the error |
Source code in components/payment_gateway/subcomponents/transfers/protected/exceptions.py
AccountTransferRoutingResult
dataclass
¶
BankTransferLogic ¶
Business logic related to bank transfers like payouts.
Source code in components/payment_gateway/subcomponents/transfers/protected/business_logic/bank_transfers.py
Attributes¶
payout_service_provider_registry
instance-attribute
¶
Functions¶
create
classmethod
¶
Creates a BankTransferLogic instance with real payout service providers.
Source code in components/payment_gateway/subcomponents/transfers/protected/business_logic/bank_transfers.py
create_null
classmethod
¶
Creates a BankTransferLogic instance with null (no-op) payout service providers.
Source code in components/payment_gateway/subcomponents/transfers/protected/business_logic/bank_transfers.py
initiate_payout_bank_transfer ¶
initiate_payout_bank_transfer(
debtor_account_id,
payout_request_id,
amount_in_cents,
currency,
creditor_bank_account,
recipient,
payment_description=None,
)
Initiates a payout bank transfer through the appropriate payout service provider.
Source code in components/payment_gateway/subcomponents/transfers/protected/business_logic/bank_transfers.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | |
BankTransferRouter ¶
Bases: ABC
Router for the bank transfer processor to route the bank transfers (a.k.a. Adyen's "bankTransfer") to the appropriate entities
Functions¶
route
abstractmethod
¶
Route a bank transfer to the appropriate entities.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
direction
|
TransferDirection
|
The transfer direction |
required |
account_id
|
AccountId
|
The ID of the account involved in the transfer |
required |
effective_date
|
datetime
|
The effective date at which the transfer occurred |
required |
Returns:
| Type | Description |
|---|---|
BankTransferRoutingResult
|
The entities with which the transfer should be associated. |
Source code in components/payment_gateway/subcomponents/transfers/protected/routers.py
BankTransferRoutingException ¶
Bases: PaymentGatewayException
Exception raised for errors in the bank transfer routing process.
Attributes:
| Name | Type | Description |
|---|---|---|
message |
Explanation of the error |
Source code in components/payment_gateway/subcomponents/transfers/protected/exceptions.py
BankTransferRoutingResult
dataclass
¶
Result of the bank transfer routing.
Attributes¶
ledger_id
class-attribute
instance-attribute
¶
Ledger ID the transfer should affect.
Can be None if the transfer does not affect a Ledger, or if the Transfer
History is not associated with a Ledger.
transfer_history_id
instance-attribute
¶
Transfer History ID the transfer should belong to.
CardTransferRouter ¶
Bases: ABC
Router for the card transfer processor to route the card transfers (a.k.a. Adyen's "payment") to the appropriate entities
Functions¶
route
abstractmethod
¶
Route a card transfer to the appropriate entities.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
card_id
|
CardId
|
The ID of the card involved in the transfer |
required |
merchant_info
|
MerchantInfo
|
Info about the merchant involved in the transfer |
required |
effective_date
|
datetime
|
The effective date at which the transfer occurred |
required |
transfer_status
|
str
|
The status of the transfer |
required |
transfer_external_id
|
str
|
The external ID of the transfer |
required |
Returns:
| Type | Description |
|---|---|
CardTransferRoutingResult
|
The entities with which the transfer should be associated. |
Source code in components/payment_gateway/subcomponents/transfers/protected/routers.py
CardTransferRoutingException ¶
Bases: PaymentGatewayException
Exception raised for errors in the card transfer routing process.
Attributes:
| Name | Type | Description |
|---|---|---|
message |
Explanation of the error |
Source code in components/payment_gateway/subcomponents/transfers/protected/exceptions.py
CardTransferRoutingResult
dataclass
¶
CardTransferRoutingResult(
transfer_history_id,
ledger_id=None,
expense_category_ids=None,
line_of_credit_ids=None,
)
Result of the card transfer routing.
Attributes¶
expense_category_ids
class-attribute
instance-attribute
¶
Expense Category IDs the transfer should match.
Can be None if the transfer does not belong to any Expense Category, which
can happen for declined or refused transfer.
ledger_id
class-attribute
instance-attribute
¶
Ledger ID the transfer should affect.
Can be None if the transfer does not affect a Ledger, or if the Transfer
History is not associated with a Ledger.
line_of_credit_ids
class-attribute
instance-attribute
¶
Line of Credit IDs the transfer should affect.
Can be None if the transfer does not match any Line of Credit, which can
happen for unknown cards or unsupported Expense Categories.
transfer_history_id
instance-attribute
¶
Transfer History ID the transfer should belong to.
TransferLogic ¶
Functions¶
audit_accounting_report ¶
Audits an accounting report against the Payment Gateway database.
:param account_id: The account id to audit :param accounting_report_document: The accounting report file in CSV format extracted from Payment provider :param start_date: The start date to filter the transfers
Note: This currently works for Adyen accounting reports only
Source code in components/payment_gateway/subcomponents/transfers/protected/api.py
create_internal_transfer ¶
create_internal_transfer(
session,
/,
*,
source,
destination,
amount,
effective_date,
description,
reference,
)
Create a double-entry internal transfer.
This will create a pair of internal transfers with opposite amounts, one negative for the source and one postitive for the destination.
Source code in components/payment_gateway/subcomponents/transfers/protected/api.py
create_internal_transfer_entry ¶
create_internal_transfer_entry(
session,
/,
*,
transfer_history_id,
amount,
effective_date,
description,
reference,
)
Create a single-entry internal transfer.
Source code in components/payment_gateway/subcomponents/transfers/protected/api.py
create_transfer_history ¶
Source code in components/payment_gateway/subcomponents/transfers/protected/api.py
get_account_transfer_balance_within_period ¶
get_account_transfer_balance_within_period(
session,
/,
transfer_history_id,
*,
period_start_date,
period_end_date,
)
Source code in components/payment_gateway/subcomponents/transfers/protected/api.py
get_all_transfers ¶
Source code in components/payment_gateway/subcomponents/transfers/protected/api.py
get_balance ¶
Source code in components/payment_gateway/subcomponents/transfers/protected/api.py
get_bank_transfer_balance_within_period ¶
get_bank_transfer_balance_within_period(
session,
/,
transfer_history_id,
*,
period_start_date,
period_end_date,
)
Source code in components/payment_gateway/subcomponents/transfers/protected/api.py
get_card_transfers_by_card_ids ¶
Retrieves a list of CardTransfer objects associated with a specific card ID, optionally filtering for those without a transfer history.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
The session to use for the database operations. |
required |
card_ids
|
Iterable[CardId]
|
The ID of the card for which to retrieve associated CardTransfer objects. |
required |
without_transfer_history_only
|
bool
|
If True, the method will return only those CardTransfer objects that have no associated transfer history. Defaults to False. |
False
|
- list[CardTransfer]: A list of CardTransfer objects matching the provided criteria. This list may be empty if no matching objects are found.
Note: - The returned CardTransfer objects are ordered by their effective date in descending order, meaning the most recent payments are returned first.
Source code in components/payment_gateway/subcomponents/transfers/protected/api.py
get_internal_transfer_balance_within_period ¶
get_internal_transfer_balance_within_period(
session,
/,
transfer_history_id,
*,
period_start_date,
period_end_date,
)
Source code in components/payment_gateway/subcomponents/transfers/protected/api.py
get_transfer_by_ref ¶
Source code in components/payment_gateway/subcomponents/transfers/protected/api.py
get_transfer_histories ¶
Source code in components/payment_gateway/subcomponents/transfers/protected/api.py
get_transfer_history_id_by_private_ref ¶
Source code in components/payment_gateway/subcomponents/transfers/protected/api.py
get_transfers_by_effective_date ¶
get_transfers_by_effective_date(
session,
/,
transfer_history_ids,
*,
start_effective_date,
end_effective_date=None,
)
Source code in components/payment_gateway/subcomponents/transfers/protected/api.py
get_transfers_by_event_date ¶
get_transfers_by_event_date(
session,
/,
transfer_history_ids,
*,
start_effective_date,
end_effective_date,
transfer_types=None,
)
Use when dealing with card transfers and
you are not only interested in the date at which the card transfer was originated, but want to fetch the individual events associated to it. A Card payment can be theoretically opened for 30 days on mastercard (on Adyen is even more, we have cases of years, a bug on their side). During this period, each event can performa a balance change, therefore the date at which you made a balance change can be different of that of when the card transfer was originated. In Spain, for healthy benefits we have a real time approach for card transfers, therefore the flag filter_by_event_dates allows to retrieve events that happened during a given period, not just card transfers for which we only have the date at which it was started. NON card transfers are more simple and don't need to be treated differently for real time cases vs non-real time.
This method returns each type of transfer ordered by created_at, then it orders by effective_at
Source code in components/payment_gateway/subcomponents/transfers/protected/api.py
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 | |
Functions¶
calculate_amount_from_events ¶
Calculate the amount from a list of transfer events We include the received balance if including_received is True.