Adapters
Transfer adapters package.
This package contains adapters for converting between different data formats in the transfers subcomponent.
components.payment_gateway.subcomponents.transfers.adapters.adyen ¶
helpers ¶
associate_account_transfer_events_from_adyen_transfer_data ¶
Associate account transfer with its events, reordering them if needed. Idempotent.
Source code in components/payment_gateway/subcomponents/transfers/adapters/adyen/helpers.py
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 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 | |
associate_bank_transfer_events_from_adyen_transfer_data ¶
Associate bank transfer with its events, reordering them if needed. Idempotent.
Source code in components/payment_gateway/subcomponents/transfers/adapters/adyen/helpers.py
449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 | |
associate_card_transfer_events_from_adyen_transfer_data ¶
Associate card transfer with its events, reordering them if needed. Idempotent.
Source code in components/payment_gateway/subcomponents/transfers/adapters/adyen/helpers.py
531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 | |
compute_transfer_update_amount_from_adyen_account_transfer_data ¶
Compute the amount and currency for an account transfer from an Adyen TransferData webhook payload.
Warning
This function is critical for client code that relies on the amount and currency of transfers (for example payroll or billing). If you have to change it, you need to do the following, in this order:
- Call it from
transfer_update_model_to_dataclassontransfer_type=TransferUpdateTransferType.ACCOUNTto override the stored values of existing transfers; newly recorded transfers will always use the new values (note that this will induce a performance hit because of the need to rehydrate the original payload) - Backfill ALL the old account transfer updates
- Remove it from
transfer_update_model_to_dataclassonce the backfill is done.
Source code in components/payment_gateway/subcomponents/transfers/adapters/adyen/helpers.py
compute_transfer_update_amount_from_adyen_bank_transfer_data ¶
Compute the amount and currency for a bank transfer from an Adyen TransferData webhook payload.
Warning
This function is critical for client code that relies on the amount and currency of transfers (for example payroll or billing). If you have to change it, you need to do the following, in this order:
- Call it from
transfer_update_model_to_dataclassontransfer_type=TransferUpdateTransferType.BANKto override the stored values of existing transfers; newly recorded transfers will always use the new values (note that this will induce a performance hit because of the need to rehydrate the original payload) - Backfill ALL the old bank transfer updates
- Remove it from
transfer_update_model_to_dataclassonce the backfill is done.
Source code in components/payment_gateway/subcomponents/transfers/adapters/adyen/helpers.py
compute_transfer_update_amount_from_adyen_card_transfer_data ¶
Compute the amount and currency for a card transfer from an Adyen TransferData webhook payload.
Warning
This function is critical for client code that relies on the amount and currency of transfers (for example payroll or billing). If you have to change it, you need to do the following, in this order:
- Call it from
transfer_update_model_to_dataclassontransfer_type=TransferUpdateTransferType.CARDto override the stored values of existing transfers; newly recorded transfers will always use the new values (note that this will induce a performance hit because of the need to rehydrate the original payload) - Backfill ALL the old card transfer updates
- Remove it from
transfer_update_model_to_dataclassonce the backfill is done.
Source code in components/payment_gateway/subcomponents/transfers/adapters/adyen/helpers.py
get_account_from_adyen_transfer_data ¶
Get the account from an Adyen TransferData webhook payload.
Source code in components/payment_gateway/subcomponents/transfers/adapters/adyen/helpers.py
get_card_from_adyen_card_transfer_data ¶
Get the account from an Adyen TransferData webhook payload.
Source code in components/payment_gateway/subcomponents/transfers/adapters/adyen/helpers.py
get_payment_status_from_adyen_account_transfer_update ¶
Map Adyen account transfer statuses to terminal PaymentRequestStatus.
Source code in components/payment_gateway/subcomponents/transfers/adapters/adyen/helpers.py
get_payment_status_from_adyen_bank_transfer_update ¶
Source code in components/payment_gateway/subcomponents/transfers/adapters/adyen/helpers.py
get_payment_status_from_adyen_card_transfer_update ¶
Map Adyen card transfer statuses to terminal PaymentRequestStatus.
Source code in components/payment_gateway/subcomponents/transfers/adapters/adyen/helpers.py
record_account_transfer_from_adyen_account_transfer_data ¶
record_account_transfer_from_adyen_account_transfer_data(
session, /, *, data, account, transfer_history_id
)
Record an account transfer from an Adyen TransferData webhook payload. Idempotent.
Source code in components/payment_gateway/subcomponents/transfers/adapters/adyen/helpers.py
record_bank_transfer_from_adyen_bank_transfer_data ¶
record_bank_transfer_from_adyen_bank_transfer_data(
session, /, *, data, account, transfer_history_id
)
Record a bank transfer from an Adyen TransferData webhook payload. Idempotent.
Source code in components/payment_gateway/subcomponents/transfers/adapters/adyen/helpers.py
record_card_transfer_from_adyen_card_transfer_data ¶
record_card_transfer_from_adyen_card_transfer_data(
session,
/,
*,
data,
card,
account_id,
transfer_history_id,
merchant_info,
)
Record a card transfer from an Adyen TransferData webhook payload. Idempotent.
Source code in components/payment_gateway/subcomponents/transfers/adapters/adyen/helpers.py
record_transfer_event_from_adyen_transfer_event ¶
Record a transfer event from an Adyen TransferEvent webhook payload. Idempotent.
Source code in components/payment_gateway/subcomponents/transfers/adapters/adyen/helpers.py
record_transfer_update_from_adyen_account_transfer_data ¶
Record a transfer update from an Adyen TransferData webhook payload. Idempotent.
Source code in components/payment_gateway/subcomponents/transfers/adapters/adyen/helpers.py
record_transfer_update_from_adyen_bank_transfer_data ¶
Record a transfer update from an Adyen TransferData webhook payload. Idempotent.
Source code in components/payment_gateway/subcomponents/transfers/adapters/adyen/helpers.py
record_transfer_update_from_adyen_card_transfer_data ¶
Record a transfer update from an Adyen TransferData webhook payload. Idempotent.
Source code in components/payment_gateway/subcomponents/transfers/adapters/adyen/helpers.py
update_payment_request_from_adyen_bank_transfer_data ¶
Update the payment request matching the bank transfer if it exists.
Source code in components/payment_gateway/subcomponents/transfers/adapters/adyen/helpers.py
policies ¶
account_transfer_processor ¶
AccountTransferProcessingResult
dataclass
¶
AccountTransferProcessingResult(
account_transfer,
is_account_transfer_created,
transfer_update,
is_transfer_update_created,
new_transfer_events,
)
AdyenAccountTransferProcessorPolicy ¶
This class is responsible for processing account transfer events (a.k.a internal transfer from Adyen).
It processes Adyen transfer notifications of type internalTransfer or invoiceDeduction.
Source code in components/payment_gateway/subcomponents/transfers/adapters/adyen/policies/account_transfer_processor.py
on_account_transfer_received ¶
Source code in components/payment_gateway/subcomponents/transfers/adapters/adyen/policies/account_transfer_processor.py
bank_transfer_processor ¶
AdyenBankTransferProcessorPolicy ¶
This class is responsible for processing bank transfer events.
It processes Adyen transfer notifications of type bankTransfer or capture.
Source code in components/payment_gateway/subcomponents/transfers/adapters/adyen/policies/bank_transfer_processor.py
on_bank_transfer_received ¶
Source code in components/payment_gateway/subcomponents/transfers/adapters/adyen/policies/bank_transfer_processor.py
BankTransferProcessingResult
dataclass
¶
BankTransferProcessingResult(
bank_transfer,
is_bank_transfer_created,
transfer_update,
is_transfer_update_created,
new_transfer_events,
payment_request,
)
card_transfer_processor ¶
AdyenCardTransferProcessorPolicy ¶
AdyenCardTransferProcessorPolicy(
*,
workspace_key,
card_transfer_router,
merchant_registry_policy=None
)
This class is responsible for processing card transfer events.
It processes Adyen transfer notifications of type payment.
Source code in components/payment_gateway/subcomponents/transfers/adapters/adyen/policies/card_transfer_processor.py
merchant_registry_policy
instance-attribute
¶
on_payment_received ¶
Source code in components/payment_gateway/subcomponents/transfers/adapters/adyen/policies/card_transfer_processor.py
CardTransferProcessingResult
dataclass
¶
CardTransferProcessingResult(
card_transfer,
is_card_transfer_created,
transfer_update,
is_transfer_update_created,
new_transfer_events,
)
synthetic_webhook ¶
Build synthetic Adyen transfer webhook payloads to fill gaps in a sequence.
When an Adyen webhook is lost mid-sequence, the corresponding business logic never runs. This module reconstructs a plausible payload for the missing sequence from: - known sibling payloads (other sequences of the same transfer), and - optionally a redacted payload pasted from Adyen's webhook event log dashboard.
Output is a plain dict ready to be passed to
AdyenTransferNotificationRequest.from_dict(payload, infer_missing=True).
Caveats:
- The extrapolation marker is prepended to data.description. Adyen's
description field is unused by our transfer processors and typically empty
for card payments, so this is a safe forensics tag without losing whatever
real description value Adyen happens to send.
- data.events is reconstructed by slicing the next sibling's cumulative
events list to the first N entries (the genuine Adyen event ids and data
for sequences 1..N). The processors assert data.events is non-empty.
- data.balances is left None (the schema's "absent" representation) when
no dashboard is provided. We don't reconstruct from event mutations to
avoid arithmetic mistakes.
EXTRAPOLATION_MARKER_PREFIX
module-attribute
¶
Prefix on data.description flagging an extrapolated webhook.
Format: ALAN_EXTRAPOLATED_WEBHOOK from=<seq>[,<seq>...] [dashboard] | <original>.
Greppable via raw->>'description' LIKE 'ALAN_EXTRAPOLATED_WEBHOOK%' on JSONB.
extrapolate_missing_webhook_payload ¶
Build a synthetic webhook payload for a missing sequence from siblings.
Stable fields (transfer id, account holder, payment instrument, counterparty, ...) are copied from the closest sibling.
data.events is reconstructed by slicing the next sibling's events list to
the first N entries -- Adyen webhooks carry a cumulative event list, so
those are the genuine event ids and data for sequences 1..N. data.status
is set from the N-th event's status (same 1-1 mapping). When the mapping
breaks (sibling has too few events or no next sibling exists), data.events
is left empty and data.status falls back to the prior sibling's status --
a warning is emitted in both cases.
data.balances is left None (the schema's absent value): we don't
arithmetically reconstruct cumulative state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
missing_sequence_number
|
int
|
The sequence number to reconstruct (N >= 1). |
required |
sibling_payloads
|
list[dict]
|
The known raw payloads for this transfer. Need not
be sorted; must each carry |
required |
Returns:
| Type | Description |
|---|---|
dict
|
A payload dict shaped like an Adyen transfer webhook notification. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no siblings are provided. |
Source code in components/payment_gateway/subcomponents/transfers/adapters/adyen/synthetic_webhook.py
61 62 63 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 | |
is_redacted ¶
Whether a value looks redacted by Adyen's webhook event log dashboard.
Adyen replaces PII with "***". Some fields (e.g. arn) get partial
redaction like "************1726" -- still starts with ***.
Empty strings and None are also treated as missing.
False positives are benign: if a real Adyen value happened to start with
***, we'd fall back to the sibling's value for that field. Stable
fields carry the same value across siblings (so the fallback equals the
dashboard value), and current sequence-specific fields aren't free-form
strings -- so falling back is idempotent in practice.
Source code in components/payment_gateway/subcomponents/transfers/adapters/adyen/synthetic_webhook.py
merge_dashboard_payload ¶
Overlay non-redacted leaves of dashboard onto extrapolated.
The dashboard payload is the source of truth where its fields aren't
redacted. Redacted leaves fall back to whatever's already in
extrapolated (the sibling-derived base).
Events get special handling because they live in a list whose cardinality
differs between dashboard (N items for sequence N) and extrapolated (0).
The dashboard list is adopted wholesale, then per-event redacted leaves
(notably arn) are filled from sibling events with matching id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
extrapolated
|
dict
|
The base payload from |
required |
dashboard
|
dict
|
The redacted payload copied from Adyen's dashboard. |
required |
sibling_payloads
|
list[dict]
|
Used to look up unredacted values for redacted event leaves by event id. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
A new merged payload dict. |
Source code in components/payment_gateway/subcomponents/transfers/adapters/adyen/synthetic_webhook.py
topic_subscribers ¶
TransferTopicSubscriber ¶
TransferTopicSubscriber(
*,
card_transfer_processor_policy,
bank_transfer_processor_policy,
account_transfer_processor_policy
)
Bases: Subscriber
This class subscribes to the Adyen transfer notification topic messages and dispatch them to application-provided processors
Source code in components/payment_gateway/subcomponents/transfers/adapters/adyen/topic_subscribers.py
account_transfer_processor_policy
instance-attribute
¶
bank_transfer_processor_policy
instance-attribute
¶
card_transfer_processor_policy
instance-attribute
¶
receive ¶
Source code in components/payment_gateway/subcomponents/transfers/adapters/adyen/topic_subscribers.py
components.payment_gateway.subcomponents.transfers.adapters.jpmorgan ¶
helpers ¶
get_bank_transfer_from_jpmorgan_callback ¶
Source code in components/payment_gateway/subcomponents/transfers/adapters/jpmorgan/helpers.py
get_payment_request_from_jpmorgan_callback ¶
Get a Payment Request from a JPMorgan PaymentCallbackEvent webhook payload.
Source code in components/payment_gateway/subcomponents/transfers/adapters/jpmorgan/helpers.py
get_payment_status_from_jpmorgan_bank_transfer_update ¶
Source code in components/payment_gateway/subcomponents/transfers/adapters/jpmorgan/helpers.py
record_transfer_update_from_jpmorgan_callback ¶
Record a transfer update from a JPMorgan PaymentCallbackEvent webhook payload. Idempotent.
Source code in components/payment_gateway/subcomponents/transfers/adapters/jpmorgan/helpers.py
policies ¶
bank_transfer_processor ¶
JPMorganBankTransferProcessorPolicy ¶
This class is responsible for processing JPMorgan bank transfer events.
It processes JPMorgan payment callback events.
Source code in components/payment_gateway/subcomponents/transfers/adapters/jpmorgan/policies/bank_transfer_processor.py
on_payment_callback_received ¶
Source code in components/payment_gateway/subcomponents/transfers/adapters/jpmorgan/policies/bank_transfer_processor.py
PaymentCallbackProcessingResult
dataclass
¶
topic_subscribers ¶
JPMorganBankTransferTopicSubscriber ¶
Bases: Subscriber
Source code in components/payment_gateway/subcomponents/transfers/adapters/jpmorgan/topic_subscribers.py
bank_transfer_processor_policy
instance-attribute
¶
receive ¶
Source code in components/payment_gateway/subcomponents/transfers/adapters/jpmorgan/topic_subscribers.py
components.payment_gateway.subcomponents.transfers.adapters.models ¶
mappers ¶
account_transfer_model_to_dataclass ¶
Convert an AccountTransfer model to AccountTransfer dataclass.
Source code in components/payment_gateway/subcomponents/transfers/adapters/models/mappers.py
bank_transfer_model_to_dataclass ¶
Convert a BankTransfer model to BankTransfer dataclass.
Source code in components/payment_gateway/subcomponents/transfers/adapters/models/mappers.py
card_transfer_model_to_dataclass ¶
Convert a CardTransfer model to CardTransfer dataclass.
Source code in components/payment_gateway/subcomponents/transfers/adapters/models/mappers.py
internal_transfer_model_to_dataclass ¶
Convert an InternalTransfer model to InternalTransfer dataclass.
Source code in components/payment_gateway/subcomponents/transfers/adapters/models/mappers.py
transfer_event_model_to_dataclass ¶
Convert a TransferEvent model to TransferEvent dataclass.
Source code in components/payment_gateway/subcomponents/transfers/adapters/models/mappers.py
transfer_update_model_to_dataclass ¶
Convert a TransferUpdate model to TransferUpdate dataclass.
Source code in components/payment_gateway/subcomponents/transfers/adapters/models/mappers.py
components.payment_gateway.subcomponents.transfers.adapters.revolut ¶
helpers ¶
compute_bank_transfer_direction_from_revolut_transaction_created_event ¶
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/helpers.py
compute_bank_transfer_direction_from_revolut_transaction_info ¶
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/helpers.py
compute_transfer_update_amount_from_out_of_order_revolut_transaction_state_changed_event ¶
compute_transfer_update_amount_from_out_of_order_revolut_transaction_state_changed_event(
data, transaction_info
)
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/helpers.py
compute_transfer_update_amount_from_revolut_transaction_created_event ¶
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/helpers.py
compute_transfer_update_amount_from_revolut_transaction_state_changed_event ¶
compute_transfer_update_amount_from_revolut_transaction_state_changed_event(
data, transfer_update
)
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/helpers.py
get_account_from_revolut_transaction_created_event ¶
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/helpers.py
get_account_from_revolut_transaction_info ¶
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/helpers.py
get_bank_transfer_from_revolut_transaction_state_changed_event ¶
get_bank_transfer_from_revolut_transaction_state_changed_event(
session, /, *, workspace_key, data
)
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/helpers.py
get_payment_reference_from_revolut_transaction_created_event ¶
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/helpers.py
get_payment_reference_from_revolut_transaction_info ¶
get_payment_reference_from_revolut_transaction_info(
session, /, *, workspace_key, transaction_info
)
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/helpers.py
get_payment_request_from_revolut_refund_transaction_event ¶
Get original payment request from a Revolut refund transaction event payload.
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/helpers.py
get_payment_status_from_revolut_bank_transfer_update ¶
Map a TransferUpdate entity's status to PaymentRequestStatus.
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/helpers.py
get_payment_status_from_revolut_transfer_update_status ¶
Map a Revolut transaction state string to a PaymentRequestStatus.
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/helpers.py
link_payment_request_to_bank_transfer_from_revolut_transaction_event ¶
link_payment_request_to_bank_transfer_from_revolut_transaction_event(
session, /, *, data, bank_transfer
)
Link the payment request to its bank transfer if not already linked.
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/helpers.py
record_bank_transfer_from_out_of_order_revolut_transaction_state_changed_event ¶
record_bank_transfer_from_out_of_order_revolut_transaction_state_changed_event(
session, /, *, data, transaction_info, account
)
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/helpers.py
record_bank_transfer_from_revolut_transaction_created_event ¶
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/helpers.py
record_transfer_update_from_out_of_order_revolut_transaction_state_changed_event ¶
record_transfer_update_from_out_of_order_revolut_transaction_state_changed_event(
session,
/,
*,
data,
transaction_info,
bank_transfer,
payment_reference,
)
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/helpers.py
record_transfer_update_from_revolut_transaction_created_event ¶
record_transfer_update_from_revolut_transaction_created_event(
session, /, *, data, bank_transfer, payment_reference
)
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/helpers.py
record_transfer_update_from_revolut_transaction_state_changed_event ¶
record_transfer_update_from_revolut_transaction_state_changed_event(
session,
/,
*,
data,
bank_transfer,
failure_reason_code=None,
)
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/helpers.py
policies ¶
bank_transfer_processor ¶
RevolutBankTransferProcessorPolicy ¶
This class is responsible for processing Revolut bank transfer events.
It processes Revolut TransactionCreated (creates bank transfer) and RevolutTransactionStateChanged (updates existing bank transfer) events.
Implements the following Nullable patterns: - Nullables: https://www.jamesshore.com/v2/projects/nullables/testing-without-mocks#nullables ⧉
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/policies/bank_transfer_processor.py
create
classmethod
¶
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/policies/bank_transfer_processor.py
create_null
classmethod
¶
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/policies/bank_transfer_processor.py
on_transaction_created ¶
Process a TransactionCreated event.
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/policies/bank_transfer_processor.py
on_transaction_state_changed ¶
Process a TransactionStateChanged event.
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/policies/bank_transfer_processor.py
process_and_notify_state_change ¶
Process a state change event and notify downstream systems.
Returns True if a new TransferUpdate was created, False otherwise.
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/policies/bank_transfer_processor.py
process_and_notify_transaction_created ¶
Process a transaction created event and notify downstream systems.
Returns True if a new TransferUpdate was created, False otherwise.
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/policies/bank_transfer_processor.py
TransactionEventProcessingResult
dataclass
¶
TransactionEventProcessingResult(
bank_transfer,
transfer_update,
is_transfer_update_created,
is_payment_request_refunded,
payment_request,
account_reference,
reason_code=None,
)
refund_transactions ¶
RefundTransactionPolicy ¶
Reconcile Revolut refund transactions by polling the Revolut API.
Backstop in case we miss webhooks: polls Revolut for refunds in a given time window and re-injects each one through the bank_transfer_processor. Re-injection takes the same idempotent path as the live webhook.
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/policies/refund_transactions.py
create
classmethod
¶
Production factory: uses real Revolut client when ACTUALLY_PAY_WITH_REVOLUT is set.
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/policies/refund_transactions.py
create_null
classmethod
¶
Test/null factory: shares a single null Revolut client between both policies.
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/policies/refund_transactions.py
get_refund_transactions ¶
Fetch refund transactions from Revolut since the given date.
Returns refunds across all accounts in the workspace's Revolut business
account (the API filters by type=refund only, no per-account filter).
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/policies/refund_transactions.py
reconcile_refund_transaction ¶
Re-inject a refund through the bank_transfer_processor.
Returns True if the refund is reconciled (either freshly processed now or already known to our DB). Returns False when the refund lacks a related transaction, or when the processor could not process it.
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/policies/refund_transactions.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
stale_payments_policy ¶
StalePaymentsPolicy ¶
Reconcile stale PaymentRequests by polling the Revolut API.
Scoped to transfers that belong to a PaymentRequest (as opposed to bare transfers without a payment request, which are out of scope).
Implements the Nullable pattern (create / create_null factories).
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/policies/stale_payments_policy.py
create
classmethod
¶
Production factory: uses real Revolut client when ACTUALLY_PAY_WITH_REVOLUT is set.
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/policies/stale_payments_policy.py
create_null
classmethod
¶
Test/null factory: shares a single null Revolut client between both policies.
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/policies/stale_payments_policy.py
reconcile_stale_payment_request ¶
Poll Revolut for the current transaction state and reconcile if changed.
Returns True if a new TransferUpdate was created (state advanced), False if the state is unchanged or the transaction could not be fetched.
Pass transaction_info to skip the Revolut get_transaction call when
the caller already holds the transaction (e.g. orphan recovery).
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/policies/stale_payments_policy.py
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 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | |
topic_subscribers ¶
TransactionCreatedSubscriber ¶
Bases: Subscriber
Subscribes to Revolut TransactionCreated events.
Creates bank transfer records when new transactions are created. Only processes events matching its registered business account.
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/topic_subscribers.py
bank_transfer_processor_policy
instance-attribute
¶
receive ¶
Receive and process a TransactionCreated event.
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/topic_subscribers.py
TransactionStateChangedSubscriber ¶
Bases: Subscriber
Subscribes to Revolut TransactionStateChanged events.
Updates bank transfer status when transaction state changes.
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/topic_subscribers.py
bank_transfer_processor_policy
instance-attribute
¶
receive ¶
Receive and process a TransactionStateChanged event.