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,
)
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_request_from_revolut_transaction_event ¶
Get payment request from a Revolut transaction event payload.
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/helpers.py
get_payment_status_from_revolut_bank_transfer_update ¶
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
)
Source code in components/payment_gateway/subcomponents/transfers/adapters/revolut/helpers.py
update_payment_request_from_revolut_transaction_event ¶
Update the payment request matching the bank transfer if it exists
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
TransactionEventProcessingResult
dataclass
¶
TransactionEventProcessingResult(
bank_transfer,
transfer_update,
is_transfer_update_created,
is_payment_request_refunded,
payment_request,
account_reference,
reason_code=None,
)
topic_subscribers ¶
TransactionCreatedSubscriber ¶
Bases: Subscriber
Subscribes to Revolut TransactionCreated events.
Creates bank transfer records when new transactions are created.
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.