Skip to content

Adapters

components.payment_gateway.internal.adapters.adyen

register

register_adyen_topic_subscribers

register_adyen_topic_subscribers()

Register all the Adyen topic subscribers that the Payment Gateway handles directly.

Source code in components/payment_gateway/internal/adapters/adyen/register.py
def register_adyen_topic_subscribers() -> None:
    """Register all the Adyen topic subscribers that the Payment Gateway handles directly."""
    from components.payment_gateway.internal.adapters.adyen.topic_subscribers import (
        RawWebhookTopicSubscriber,
    )
    from components.payment_gateway.public.connectors.adyen_connectors import (
        adyen_card_order_topic,
        adyen_payment_instrument_topic,
        adyen_raw_webhook_topic,
    )
    from components.payment_gateway.subcomponents.cards.adapters.adyen.topic_subscribers import (
        CardOrderTopicSubscriber,
        PaymentInstrumentTopicSubscriber,
    )
    from components.payment_gateway.subcomponents.cards.business_logic.policies.card_order_tracking import (
        CardOrderTrackingPolicy,
    )
    from components.payment_gateway.subcomponents.cards.business_logic.policies.card_status_handling import (
        CardStatusHandlingPolicy,
    )

    payment_instrument_topic_subscriber = PaymentInstrumentTopicSubscriber(
        CardStatusHandlingPolicy()
    )
    adyen_payment_instrument_topic.subscribe(payment_instrument_topic_subscriber)

    card_order_topic_subscriber = CardOrderTopicSubscriber(CardOrderTrackingPolicy())
    adyen_card_order_topic.subscribe(card_order_topic_subscriber)

    adyen_raw_webhook_topic.subscribe(RawWebhookTopicSubscriber())

register_authorization_resolvers

register_authorization_resolvers(
    expense_category_resolver, line_of_credit_resolver
)

Connect the application-specific resolvers to the Adyen authorisation relay and transfer topic.

Source code in components/payment_gateway/internal/adapters/adyen/register.py
def register_authorization_resolvers(
    expense_category_resolver: ExpenseCategoryResolver,
    line_of_credit_resolver: LineOfCreditResolver,
) -> None:
    """Connect the application-specific resolvers to the Adyen authorisation relay and transfer topic."""
    from components.payment_gateway.public.connectors.adyen_connectors import (
        adyen_authorisation_relay,
        adyen_transfer_topic,
    )
    from components.payment_gateway.subcomponents.authorizations.business_logic.policies.authorization_request_processing import (
        AuthorizationRequestProcessingPolicy,
    )

    adyen_authorisation_relay.register_policy(
        authorization_request_processing_policy=AuthorizationRequestProcessingPolicy(
            expense_category_resolver=expense_category_resolver,
            line_of_credit_resolver=line_of_credit_resolver,
        )
    )
    adyen_transfer_topic.subscribe(adyen_authorisation_relay)

register_transfer_routers

register_transfer_routers(
    card_transfer_router,
    bank_transfer_router,
    account_transfer_router,
)

Connect the application-specific transfer routers to the Adyen transfer topic.

Source code in components/payment_gateway/internal/adapters/adyen/register.py
def register_transfer_routers(
    card_transfer_router: CardTransferRouter,
    bank_transfer_router: BankTransferRouter,
    account_transfer_router: AccountTransferRouter,
) -> None:
    """Connect the application-specific transfer routers to the Adyen transfer topic."""
    from components.payment_gateway.public.connectors.adyen_connectors import (
        adyen_transfer_topic,
    )
    from components.payment_gateway.subcomponents.transfers.adapters.adyen.topic_subscribers import (
        TransferTopicSubscriber,
    )
    from components.payment_gateway.subcomponents.transfers.business_logic.policies.account_transfer_processor import (
        AccountTransferProcessorPolicy,
    )
    from components.payment_gateway.subcomponents.transfers.business_logic.policies.bank_transfer_processor import (
        BankTransferProcessorPolicy,
    )
    from components.payment_gateway.subcomponents.transfers.business_logic.policies.card_transfer_processor import (
        CardTransferProcessorPolicy,
    )

    transfer_topic_subscriber = TransferTopicSubscriber(
        card_transfer_processor_policy=CardTransferProcessorPolicy(
            card_transfer_router=card_transfer_router
        ),
        bank_transfer_processor_policy=BankTransferProcessorPolicy(
            bank_transfer_router=bank_transfer_router
        ),
        account_transfer_processor_policy=AccountTransferProcessorPolicy(
            account_transfer_router=account_transfer_router
        ),
    )
    adyen_transfer_topic.subscribe(transfer_topic_subscriber)

topic_subscribers

RawWebhookTopicSubscriber

RawWebhookTopicSubscriber()

Bases: Subscriber

This class subscribes to the Adyen raw webhook topic messages and logs them in database.

Source code in components/payment_gateway/internal/adapters/adyen/topic_subscribers.py
def __init__(self) -> None:
    pass
receive
receive(message)
Source code in components/payment_gateway/internal/adapters/adyen/topic_subscribers.py
@override
@obs.event_subscriber()
def receive(self, message: AdyenRawWebhook) -> None:
    from shared.helpers.db import current_session

    try:
        current_session.add(
            WebhookLog(
                source=message.source,
                status=message.status,
                payload=message.payload,
            )
        )
        current_session.commit()
    except Exception as e:
        # It's probably OK to not do anything here besides logging as it
        # might be a transient error with the DB
        current_logger.exception(
            "Unknown exception",
            exception=e,
        )

components.payment_gateway.internal.adapters.jpmorgan

register

register_jpmorgan_topic_subscribers

register_jpmorgan_topic_subscribers()
Source code in components/payment_gateway/internal/adapters/jpmorgan/register.py
def register_jpmorgan_topic_subscribers() -> None:
    jpmorgan_transfer_topic.subscribe(
        subscriber=JPMorganBankTransferTopicSubscriber(
            bank_transfer_processor_policy=JPMorganBankTransferProcessorPolicy(),
        )
    )