Skip to main content

Integration Architecture

Overview

BankLingo integrates with multiple external systems for payment processing, notifications, and regulatory reporting. This document describes the integration patterns, authentication mechanisms, data exchange formats, error handling strategies, and API contracts.

High-Level Integration Architecture

Integration Patterns

1. Payment Integration Pattern

NIBSS Instant Payment Integration

NIBSS Request/Response Models:

Transfer Request:

{
"sourceAccount": "1234567890",
"sourceBankCode": "033",
"destinationAccount": "0987654321",
"destinationBankCode": "044",
"amount": 50000.00,
"narration": "Payment for services",
"reference": "BLG-TXN-20260101-001",
"customerName": "John Doe",
"transactionDate": "2026-01-01T10:30:00Z"
}

Transfer Response (Success):

{
"status": "SUCCESS",
"transactionId": "NIBSS-202601-XYZ123",
"reference": "BLG-TXN-20260101-001",
"responseCode": "00",
"responseMessage": "Transaction successful",
"settlementDate": "2026-01-01T10:30:15Z"
}

Transfer Response (Error):

{
"status": "FAILED",
"transactionId": null,
"reference": "BLG-TXN-20260101-001",
"responseCode": "25",
"responseMessage": "Insufficient funds in source account",
"timestamp": "2026-01-01T10:30:10Z"
}

2. Notification Integration Pattern

Multi-Channel Notification Flow

Notification Service Configurations:

ServiceProviderAuthenticationRate LimitRetry Strategy
SMSTermii/TwilioAPI Key100 req/sec3 retries, exponential backoff
EmailSendGridAPI Key600 req/minNo retry (accepted = sent)
PushFirebase Cloud MessagingService Account10,000 req/min2 retries, linear backoff

SMS Request:

{
"to": "+2348012345678",
"from": "BankLingo",
"sms": "Your transaction of NGN 5,000.00 was successful. Ref: BLG-001. Balance: NGN 50,000.00",
"type": "plain",
"channel": "generic",
"api_key": "TL*********************"
}

Email Request:

{
"personalizations": [
{
"to": [{"email": "user@example.com", "name": "John Doe"}],
"dynamic_template_data": {
"transactionAmount": "5,000.00",
"transactionReference": "BLG-001",
"accountBalance": "50,000.00"
}
}
],
"from": {"email": "noreply@banklingo.com", "name": "BankLingo"},
"template_id": "d-1234567890abcdef",
"mail_settings": {
"sandbox_mode": {"enable": false}
}
}

Push Notification Request:

{
"to": "device_token_here",
"notification": {
"title": "Transaction Successful",
"body": "Your transaction of NGN 5,000.00 was successful"
},
"data": {
"transactionId": "txn-123",
"amount": "5000.00",
"type": "deposit",
"click_action": "OPEN_TRANSACTION_DETAILS"
},
"priority": "high"
}

3. Webhook Integration Pattern

Inbound Webhook Processing

Webhook Security:

  1. HMAC Signature Verification:
Code Removed

Implementation details removed for security.

Contact support for implementation guidance.

  1. Timestamp Validation:
Code Removed

Implementation details removed for security.

Contact support for implementation guidance.

Webhook Payload Examples:

NIBSS Payment Callback:

{
"eventType": "payment.completed",
"transactionId": "NIBSS-202601-XYZ123",
"reference": "BLG-TXN-20260101-001",
"status": "SUCCESS",
"amount": 50000.00,
"sourceAccount": "1234567890",
"destinationAccount": "0987654321",
"settlementDate": "2026-01-01T10:35:00Z",
"responseCode": "00",
"responseMessage": "Transaction successful"
}

4. Identity Verification Integration

BVN Verification Flow

BVN Verification Request:

{
"bvn": "12345678901",
"firstName": "John",
"lastName": "Doe",
"dateOfBirth": "1990-05-15",
"phoneNumber": "08012345678"
}

BVN Verification Response (Success):

{
"verified": true,
"bvn": "12345678901",
"firstName": "JOHN",
"lastName": "DOE",
"middleName": "MICHAEL",
"dateOfBirth": "1990-05-15",
"phoneNumber": "08012345678",
"gender": "Male",
"nationality": "Nigerian",
"stateOfOrigin": "Lagos",
"lgaOfOrigin": "Ikeja",
"imageBase64": "data:image/jpeg;base64,/9j/4AAQ...",
"registrationDate": "2015-03-10"
}

API Authentication & Authorization

Authentication Mechanisms

JWT Token Flow

JWT Token Structure:

Header:

{
"alg": "HS256",
"typ": "JWT"
}

Payload (Claims):

{
"sub": "user-123",
"name": "John Doe",
"email": "john.doe@example.com",
"roles": ["Teller", "Approver"],
"permissions": [
"transactions.create",
"transactions.approve",
"accounts.read"
],
"branchId": "branch-456",
"iat": 1735729800,
"exp": 1735733400,
"jti": "token-id-789"
}

Access Control Matrix:

RolePermissionsTransaction Limits
Tellertransactions.create, accounts.read, customers.readCreate: ₦500K, Approve: None
Approvertransactions.approve, transactions.readCreate: None, Approve: ₦5M
Branch Managertransactions., accounts., customers.*, reports.readCreate: ₦5M, Approve: ₦50M
Admin. (all permissions)No limits
Auditor*.read (read-only all)No transaction operations

Error Handling & Retry Strategies

Retry Policy Matrix

IntegrationError TypeRetry StrategyMax RetriesBackoff
NIBSS PaymentTimeoutExponential310s, 30s, 90s
NIBSS Payment5xx Server ErrorExponential310s, 30s, 90s
NIBSS Payment4xx Client ErrorNone0N/A
SMS GatewayTimeoutExponential35s, 15s, 45s
SMS Gateway5xx Server ErrorExponential35s, 15s, 45s
SMS GatewayRate Limit (429)Linear560s
Email Service5xx Server ErrorLinear230s, 60s
BVN VerificationTimeoutExponential220s, 60s
BVN Verification5xx Server ErrorExponential220s, 60s
Webhook CallbackProcessing ErrorExponential510s, 30s, 90s, 270s, 810s

Circuit Breaker Pattern

Circuit Breaker Configuration:

Code Removed

Implementation details removed for security.

Contact support for implementation guidance.


Data Exchange Formats

Standard Request/Response Format

Standard API Response:

{
"success": true,
"data": {
"transactionId": "txn-123",
"status": "SETTLED",
"amount": 5000.00
},
"message": "Transaction successful",
"timestamp": "2026-01-01T10:30:00Z",
"requestId": "req-456"
}

Standard Error Response:

{
"success": false,
"error": {
"code": "INSUFFICIENT_FUNDS",
"message": "Account has insufficient funds for this transaction",
"details": {
"accountBalance": 2000.00,
"requestedAmount": 5000.00,
"shortfall": 3000.00
}
},
"timestamp": "2026-01-01T10:30:00Z",
"requestId": "req-456"
}

Integration-Specific Formats

NIBSS ISO 8583 Format (For card transactions):

0200                          // Message Type
3838000000C00016 // Bitmap
16 1234567890123456 // PAN
03 000000 // Processing Code
12 000000005000 // Amount
07 0101103000 // Transmission Date/Time
11 123456 // STAN
37 123456789012 // Retrieval Reference Number
41 12345678 // Card Acceptor Terminal ID
42 123456789012345 // Card Acceptor ID

NEFT/RTGS XML Format:

<?xml version="1.0" encoding="UTF-8"?>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pacs.008.001.08">
<FIToFICstmrCdtTrf>
<GrpHdr>
<MsgId>BLG-20260101-001</MsgId>
<CreDtTm>2026-01-01T10:30:00</CreDtTm>
<NbOfTxs>1</NbOfTxs>
<TtlIntrBkSttlmAmt Ccy="NGN">50000.00</TtlIntrBkSttlmAmt>
</GrpHdr>
<CdtTrfTxInf>
<PmtId>
<InstrId>BLG-20260101-001</InstrId>
<EndToEndId>E2E-123456</EndToEndId>
</PmtId>
<IntrBkSttlmAmt Ccy="NGN">50000.00</IntrBkSttlmAmt>
<Dbtr>
<Nm>John Doe</Nm>
<Id>
<OrgId>
<Othr>
<Id>1234567890</Id>
</Othr>
</OrgId>
</Id>
</Dbtr>
<CdtrAcct>
<Id>
<Othr>
<Id>0987654321</Id>
</Othr>
</Id>
</CdtrAcct>
</CdtTrfTxInf>
</FIToFICstmrCdtTrf>
</Document>

Integration Monitoring & Observability

Key Metrics Tracked

MetricPurposeAlert Threshold
API Success RateIntegration health< 95%
API Response TimePerformanceP95 > 5s
Token Refresh RateAuth health> 100/min
Retry CountReliability> 50/hour
Circuit Breaker OpensService availability> 5/hour
Webhook Processing TimeAsync processingP95 > 10s
Failed NotificationsDelivery success> 10%
External API ErrorsThird-party health> 100/hour

Integration Dashboard

Application Insights Queries:

1. External API Success Rate:

dependencies
| where timestamp > ago(1h)
| where type == "HTTP"
| summarize
Total = count(),
Success = countif(success == true),
Failed = countif(success == false),
SuccessRate = 100.0 * countif(success == true) / count()
by target
| order by SuccessRate asc

2. Integration Response Times:

dependencies
| where timestamp > ago(1h)
| where type == "HTTP"
| summarize
P50 = percentile(duration, 50),
P95 = percentile(duration, 95),
P99 = percentile(duration, 99)
by target
| order by P95 desc

3. Retry Analysis:

traces
| where timestamp > ago(1h)
| where message contains "Retry attempt"
| parse message with * "Integration: " integration:string " | Attempt: " attempt:int " | " *
| summarize
TotalRetries = count(),
MaxAttempt = max(attempt)
by integration
| order by TotalRetries desc

Integration Security Best Practices

1. API Key Management

  • ✅ Store API keys in Azure Key Vault
  • ✅ Rotate keys quarterly
  • ✅ Use different keys per environment (dev/staging/prod)
  • ✅ Implement key versioning for zero-downtime rotation
  • ✅ Audit all key access in logs

2. TLS/SSL Configuration

  • ✅ Enforce TLS 1.2+ for all external connections
  • ✅ Validate SSL certificates (no self-signed in production)
  • ✅ Use certificate pinning for critical integrations (NIBSS, CBN)
  • ✅ Implement mutual TLS (mTLS) for high-security integrations

3. Request Signing

  • ✅ Sign all outbound requests with HMAC-SHA256
  • ✅ Include timestamp in signature to prevent replay attacks
  • ✅ Validate inbound webhook signatures
  • ✅ Use nonce/request ID for idempotency

4. Rate Limiting

  • ✅ Implement rate limiting on inbound webhooks (100 req/min per IP)
  • ✅ Respect rate limits of external APIs
  • ✅ Use exponential backoff when rate-limited (429 responses)
  • ✅ Cache responses to reduce API calls

5. Data Sanitization

  • ✅ Sanitize all input data before external API calls
  • ✅ Validate response data schema before processing
  • ✅ Mask sensitive data (PAN, BVN) in logs
  • ✅ Encrypt sensitive data in transit and at rest

Integration Testing Strategy

1. Mock External Services

Stub NIBSS Service (for testing):

Code Removed

Implementation details removed for security.

Contact support for implementation guidance.

2. Integration Test Scenarios

ScenarioTest CaseExpected Result
Happy PathSuccessful payment200 OK, transaction settled
Insufficient FundsPayment exceeds balance400 Bad Request, specific error
TimeoutExternal service delay > 30s504 Gateway Timeout, retry queued
Invalid TokenExpired/invalid auth token401 Unauthorized, token refresh
Rate Limit429 response from external APIRetry with backoff
Circuit Breaker5 consecutive failuresCircuit open, fail fast
IdempotencyDuplicate request IDReturn cached response
Webhook ValidationInvalid signature401 Unauthorized, log security event


Summary

The integration architecture provides:

  • ✅ Payment Integration - NIBSS, NEFT, RTGS with retry logic
  • ✅ Multi-Channel Notifications - SMS, Email, Push with template management
  • ✅ Webhook Processing - Secure inbound webhook handling with signature validation
  • ✅ Identity Verification - BVN verification with caching
  • ✅ Authentication - JWT-based auth with role-based access control
  • ✅ Error Handling - Comprehensive retry strategies and circuit breakers
  • ✅ Data Formats - JSON, XML, ISO 8583 support
  • ✅ Monitoring - Integration health metrics and alerting
  • ✅ Security - API key management, TLS, request signing
  • ✅ Testing - Mock services and comprehensive test scenarios

Integration Characteristics:

  • Reliability: 99.9% success rate with automatic retries
  • Performance: P95 < 3s for payment processing
  • Security: Multi-layered authentication and encryption
  • Scalability: 500+ TPS for external API calls
  • Observability: Real-time monitoring and alerting