Adapters
components.payment_gateway.subcomponents.authorizations.adapters.adyen ¶
authorisation_relay ¶
AdyenAuthorisationRelay ¶
Bases: Subscriber
This class implements the main Adyen Authorisation Relay connector between their webhooks and our business logic.
It provides both an entry point to respond to authorisation webhooks, and a TransferNotificationRequest topic subscriber to process card transfer events on previously handled authorisation requests.
authorization_request_processing_policy
instance-attribute
¶
on_authorisation_request ¶
Process an incoming Adyen authorisation request event.
This method is called when an authorization request webhook is received from Adyen. It converts the webhook payload to a PendingTransaction before calling the core policy.
Source code in components/payment_gateway/subcomponents/authorizations/adapters/adyen/authorisation_relay.py
receive ¶
Receive card transfer events and forward them to the core policy for lifecycle management.
Source code in components/payment_gateway/subcomponents/authorizations/adapters/adyen/authorisation_relay.py
register_policy ¶
Register the policy to be used for processing authorisation requests.
Any authorisation request will be denied until this method is called.
Source code in components/payment_gateway/subcomponents/authorizations/adapters/adyen/authorisation_relay.py
helpers ¶
authorization_request_external_id_from_transfer_data ¶
Source code in components/payment_gateway/subcomponents/authorizations/adapters/adyen/helpers.py
to_pending_transaction ¶
Convert an Adyen authorisation request to a pending transaction.
Source code in components/payment_gateway/subcomponents/authorizations/adapters/adyen/helpers.py
components.payment_gateway.subcomponents.authorizations.adapters.swan ¶
helpers ¶
Map a Swan Payment Control request to the engine's generic PendingTransaction.
Single boundary file — Swan vocabulary stops here. Everything downstream sees only the engine's generic types.
to_pending_transaction ¶
Translate a Swan Payment Control payload to the engine's generic PendingTransaction.
Asserts the identity / credit-essential fields Swan marks optional but we strictly
need (payment id, card id, amount, currency). The caller catches and returns
AuthorizationResult.declined (fail-CLOSED).
Source code in components/payment_gateway/subcomponents/authorizations/adapters/swan/helpers.py
payment_control ¶
Orchestrator for Swan Payment Control — wraps the auth-relay engine with fail-CLOSED webhook semantics.
See https://docs.swan.io/developers/using-api/payment-control/ ⧉
The synchronous decision must reach Swan within 1.5 s in Live. Any exception is
caught and translated into AuthorizationResult.declined (fail-CLOSED), so Swan
always receives a concrete answer within the budget.
SwanPaymentControl ¶
Swan Payment Control connector — synchronous accept/decline on every card authorization.
Source code in components/payment_gateway/subcomponents/authorizations/adapters/swan/payment_control.py
on_payment_control_request ¶
Synchronously approve or decline an incoming Swan Payment Control request.
On unexpected error: logs + alerts, then re-raises. The caller (the webhook
controller) is responsible for catching, rolling back the session, and
returning AuthorizationResult.declined to Swan. Same fail-CLOSED outcome,
cleaner separation: this method does the work and signals failure with an
exception; transaction/response lifecycle is the controller's concern.
Source code in components/payment_gateway/subcomponents/authorizations/adapters/swan/payment_control.py
register_policy ¶
Register the policy that will process payment control requests.
Called once at boot from the application-specific
register_payment_gateway_connectors(). Until this is called, the connector
replies declined to every request (fail-CLOSED).
Source code in components/payment_gateway/subcomponents/authorizations/adapters/swan/payment_control.py
release_pending_transaction ¶
Release a previously-reserved authorization once Swan confirms the transfer.
Called from alan_pay/internal/business_logic/actions/card_payment.py when a
card transaction transitions into a terminal Swan state (captured / released /
rejected). No-op when no prior auth request exists (handled inside the policy).