For the complete documentation index, see llms.txt. This page is also available as Markdown.

Sponsor Bank connector

Design & Implementation

Part of writing a connector — for the end-to-end flow (implement the interface → extend the published Bridge Docker image → configure → deploy) see How to write your own connector.

Bank Disbursments - Flow

Module Information

  • Module Name: openg2p-g2p-bridge-bank-connectors

  • Location: /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

  1. HTTP-Based Communication: Uses httpx.Client() for HTTP requests

  2. Configuration-Driven URLs: Bank URLs from Settings configuration

  3. 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 name

  • funds_available_check_url_example_bank - URL for funds check endpoint

  • And 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 check

  • FundsBlockedWithBankEnum - Status for fund blocking operation

Actual enum values not visible in provided code.


HTTP Client Configuration

  • Library: httpx

  • Method: POST for requests

  • Error Handling: response.raise_for_status() - raises on 4xx/5xx

  • JSON Body: Requests sent as JSON


Payment Payload Variants

The implementation supports three payment methods via different fields:

  1. Bank Account Transfer

    • Uses: beneficiary_account, beneficiary_bank_code, beneficiary_branch_code

  2. Mobile Wallet

    • Uses: beneficiary_phone_no, beneficiary_mobile_wallet_provider

  3. 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

  1. Single Response for Batch: initiate_payment() receives List[DisbursementPaymentPayload] but returns single PaymentResponse (possible interface mismatch)

  2. HTTP Exceptions: HTTP errors result in exceptions being raised (not caught)

  3. Error Code Handling: All responses include error_code field (populated on error)

  4. Configuration-Driven: Bank endpoints loaded from configuration, allowing different banks to be configured without code changes

  5. No Transaction Tracking: Does not track transaction IDs in response (that's handled by retrieve methods)


Integration Pattern


Error Scenarios

  1. HTTP Connection Error: Raises httpx exception

  2. 4xx/5xx Response: Raises from response.raise_for_status()

  3. Missing Payment Method Fields: Raises ValueError in payment validation

  4. 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?