Sponsor Bank connector
Design & Implementation
Bank Disbursments - Flow

Module Information
Module Name:
openg2p-g2p-bridge-bank-connectorsLocation:
/openg2p-g2p-bridge-bank-connectors/Primary Implementation:
ExampleBankConnector
Interface Definition
File: bank_interface/bank_connector_interface.py
Data Models
Interface Methods
Reference Implementation: ExampleBankConnector
File: bank_connectors/example_bank_connector.py
Key Features
HTTP-Based Communication: Uses
httpx.Client()for HTTP requestsConfiguration-Driven URLs: Bank URLs from Settings configuration
Logging: Uses logger from config:
_config.logging_default_logger_name
Implementation Details
check_funds()
block_funds()
(Implementation details not fully visible in provided code excerpt)
initiate_payment()
retrieve_reconciliation_id(), retrieve_beneficiary_name(), retrieve_reversal_reason()
(Implementations not provided in code excerpt)
Factory Pattern
File: bank_connectors/bank_connector_factory.py
Configuration
File: config.py
Configuration parameters include:
logging_default_logger_name- Logger namefunds_available_check_url_example_bank- URL for funds check endpointAnd likely other bank-specific URLs (block_funds, payment, etc.)
Enums from openg2p_g2p_bridge_models
The interface depends on enums defined in the models package:
FundsAvailableWithBankEnum- Status for fund availability checkFundsBlockedWithBankEnum- Status for fund blocking operation
Actual enum values not visible in provided code.
HTTP Client Configuration
Library:
httpxMethod:
POSTfor requestsError Handling:
response.raise_for_status()- raises on 4xx/5xxJSON Body: Requests sent as JSON
Payment Payload Variants
The implementation supports three payment methods via different fields:
Bank Account Transfer
Uses: beneficiary_account, beneficiary_bank_code, beneficiary_branch_code
Mobile Wallet
Uses: beneficiary_phone_no, beneficiary_mobile_wallet_provider
Email Wallet
Uses: beneficiary_email, beneficiary_email_wallet_provider
Implementation logic determines which method based on which fields are populated.
Response Format
CheckFundsResponse
BlockFundsResponse
PaymentResponse
Key Implementation Notes
Single Response for Batch:
initiate_payment()receivesList[DisbursementPaymentPayload]but returns singlePaymentResponse(possible interface mismatch)HTTP Exceptions: HTTP errors result in exceptions being raised (not caught)
Error Code Handling: All responses include error_code field (populated on error)
Configuration-Driven: Bank endpoints loaded from configuration, allowing different banks to be configured without code changes
No Transaction Tracking: Does not track transaction IDs in response (that's handled by retrieve methods)
Integration Pattern
Error Scenarios
HTTP Connection Error: Raises httpx exception
4xx/5xx Response: Raises from
response.raise_for_status()Missing Payment Method Fields: Raises ValueError in payment validation
Bank Response Parsing Error: May raise JSON parsing error if response malformed
Testing Notes
The "ExampleBankConnector" is meant for:
Development/testing
As a template for real bank implementations
Mock responses without actual bank integration
Last updated
Was this helpful?