13 KiB
GPN Payment Flow
Overview
The DBIS Global Payments Network (GPN) processes payments through a three-layer architecture: Sovereign Access Layer, Global Switching Layer, and Finality Layer. This flow documents the complete payment routing and settlement process.
Prerequisites
- Source and destination accounts exist and are active
- Sufficient balance in source account
- Valid SDIP (Sovereign Digital Identity Passport) for authentication
- GPN service is operational
- ISO 20022 message format compliance
Visual Flow Diagram
sequenceDiagram
participant PI as Payment Initiator
participant L1 as Layer 1: Sovereign Access
participant L2 as Layer 2: Global Switching
participant L3 as Layer 3: Finality
participant SCB as SCB Ledger
participant DBIS as DBIS Ledger
PI->>L1: Payment Request (PACS.008)
Note over L1: SDIP Authentication<br/>Zero-trust verify<br/>Traffic segmentation
L1->>L1: Validate SDIP
L1->>L1: Zero-trust check
L1->>L2: Authenticated Request
Note over L2: FX cost optimization<br/>Liquidity check<br/>SRI risk weighting<br/>Route calculation
L2->>L2: Calculate optimal route
L2->>L2: Check liquidity
L2->>L2: Apply SRI weighting
L2->>L3: Route Selected
Note over L3: Hash-lock creation<br/>Dual-ledger posting<br/>Hash-lock verification
L3->>L3: Create hash-lock
L3->>SCB: Post to SCB Ledger
L3->>DBIS: Post to DBIS Ledger
SCB-->>L3: Confirmation
DBIS-->>L3: Confirmation
L3->>L3: Verify hash-lock
L3->>PI: Finality Confirmed
ASCII Diagram (Legacy):
┌─────────────┐
│ Payment │
│ Initiator │
└──────┬──────┘
│
│ 1. Payment Request
│ (PACS.008)
▼
┌─────────────────────────┐
│ Layer 1: Sovereign │
│ Access Layer │
│ - SDIP Authentication │
│ - Zero-trust verify │
│ - Traffic segmentation │
└──────┬──────────────────┘
│
│ 2. Authenticated
▼
┌─────────────────────────┐
│ Layer 2: Global │
│ Switching Layer │
│ - FX cost optimization │
│ - Liquidity check │
│ - SRI risk weighting │
│ - Route calculation │
└──────┬──────────────────┘
│
│ 3. Route Selected
▼
┌─────────────────────────┐
│ Layer 3: Finality │
│ Layer │
│ - Hash-lock creation │
│ - SCB ledger post │
│ - DBIS ledger post │
│ - Hash-lock verify │
└──────┬──────────────────┘
│
│ 4. Finality Confirmed
▼
┌─────────────┐
│ Payment │
│ Settled │
└─────────────┘
Step-by-Step Process
Step 1: Payment Initiation
- Payment initiator submits payment request via API or ISO 20022 message (PACS.008)
- GPN message handler receives and validates message format
- Extract payment details:
- Source account (debtorAccount)
- Destination account (creditorAccount)
- Amount and currency
- Payment priority
- Reference information
Code Reference: src/core/payments/payment.service.ts:18-73
Step 2: Layer 1 - Sovereign Access Authentication
- Extract SDIP from request headers or message
- Verify SDIP signature using sovereign identity service
- Validate sovereign bank ID matches SDIP
- Check zero-trust authentication:
- Verify request signature
- Validate timestamp (prevent replay attacks)
- Check access permissions
- Segment traffic by sovereign identity
Code Reference: src/integration/api-gateway/middleware/auth.middleware.ts
Step 3: Account Validation
- Lookup source account (debtorAccount) by account number
- Lookup destination account (creditorAccount) by account number
- Verify both accounts exist and are active
- Check source account balance:
- Calculate available balance
- Verify sufficient funds for payment amount
- Consider any pending holds or reserves
- If insufficient balance, return error and terminate flow
Code Reference: src/core/accounts/account.service.ts
Step 4: Layer 2 - Global Switching & Routing
- Calculate optimal route using:
- FX cost optimization
- Liquidity availability check
- SRI-based risk weighting
- Settlement mode (RTGS vs DNS)
- Determine settlement mode based on priority:
- RTGS for urgent/high-priority payments
- DNS for normal/deferred payments
- Select routing path:
- Direct SCB-to-SCB if same currency
- Via GSS if cross-currency
- Via SSU if optimal for cross-border
- Create payment routing record
Code Reference: src/core/settlement/sire/sire-routing.service.ts
Step 5: Layer 3 - Finality & Settlement
- Create hash-lock for atomic settlement:
- Generate commitment hash
- Store hash-lock record
- Post to SCB sovereign ledger:
- Create debit entry on source account
- Create credit entry on destination account
- Generate sovereign ledger hash
- Post to DBIS master ledger:
- Create corresponding entries
- Generate DBIS ledger hash
- Verify hash-lock match:
- Compare sovereign and DBIS hashes
- Verify dual-ledger commit
- Mark payment as settled
Code Reference:
src/core/settlement/gss/gss-master-ledger.service.ts:35-96src/core/ledger/ledger-lifecycle.service.ts:44-139
Step 6: Confirmation & Notification
- Generate payment status report (PACS.002)
- Send confirmation to payment initiator
- Notify destination bank (if different sovereign)
- Update payment status in database
- Log settlement event
Error Handling
Error: Account Not Found
- Detection: Account lookup returns null
- Action: Return error code
NOT_FOUND - Recovery: Terminate flow, notify initiator
Error: Insufficient Balance
- Detection: Available balance < payment amount
- Action: Return error code
VALIDATION_ERROR - Recovery: Terminate flow, suggest alternative payment methods
Error: Authentication Failure
- Detection: SDIP verification fails
- Action: Return error code
UNAUTHORIZED - Recovery: Terminate flow, log security event
Error: Routing Failure
- Detection: No valid route found
- Action: Return error code
ROUTING_ERROR - Recovery: Retry with alternative routing, escalate if persistent
Error: Dual-Ledger Commit Failure
- Detection: Hash-lock verification fails
- Action: Rollback both ledger entries
- Recovery:
- Mark payment as failed
- Create reconciliation record
- Notify operations team
Integration Points
Related Services
- Payment Service:
src/core/payments/payment.service.ts - Account Service:
src/core/accounts/account.service.ts - Ledger Service:
src/core/ledger/ledger.service.ts - GSS Master Ledger:
src/core/settlement/gss/gss-master-ledger.service.ts - SIRE Routing:
src/core/settlement/sire/sire-routing.service.ts - Identity Service:
src/core/cbdc/interoperability/cim-identity.service.ts
API Endpoints
POST /api/v1/gpn/authenticate- Layer 1 authenticationPOST /api/v1/gpn/route- Layer 2 routingPOST /api/v1/gpn/finality- Layer 3 finality verificationPOST /api/v1/gpn/message/pacs008- ISO 20022 message handling
Database Models
GpnPayment- Payment routing recordsGpnRoute- Routing paths with cost/risk metricsGpnSettlementLock- Hash-lock records for finality
Performance Metrics
- Layer 1 (Authentication): < 50ms target
- Layer 2 (Routing): < 100ms target
- Layer 3 (Finality): < 200ms target
- Total End-to-End: < 350ms target
- Throughput: 10,000+ payments/second per node
- Availability: 99.99% uptime target
Security Considerations
Authentication Checkpoints
- SDIP signature verification (Layer 1)
- Request signature validation
- Timestamp verification (replay attack prevention)
- Access permission checks
Authorization
- Sovereign bank must have active status
- Account must have transfer permissions
- Payment amount within policy limits
Data Protection
- All messages encrypted in transit (TLS 1.3)
- Sensitive data encrypted at rest
- Audit logging for all operations
Testing Scenarios
Happy Path
- Valid payment request with sufficient balance
- Successful authentication
- Successful routing
- Successful dual-ledger commit
- Payment settled within SLA
Error Scenarios
- Invalid SDIP signature
- Account not found
- Insufficient balance
- Routing failure
- Dual-ledger commit failure
- Network timeout
Edge Cases
- Concurrent payments to same account
- Maximum payment amount
- Minimum payment amount
- Cross-currency payments
- Offline destination bank
Recommendations
Error Handling Strategies
Priority: High
-
Retry Mechanisms
- Description: Implement intelligent retry logic for transient failures
- Implementation: Use exponential backoff, maximum retry limits, circuit breaker pattern
- Impact: Improves system resilience and reduces manual intervention
- Dependencies: Retry middleware, circuit breaker library
-
Idempotency Keys
- Description: Ensure payment requests are idempotent
- Implementation: Generate unique idempotency keys, check for duplicate requests, return same response for duplicates
- Impact: Prevents duplicate payments and enables safe retries
- Dependencies: Idempotency key storage, request deduplication service
-
Compensation Transactions
- Description: Implement compensation for failed payments
- Implementation: Track payment state, implement rollback procedures, notify parties of failures
- Impact: Ensures financial consistency and proper error recovery
- Dependencies: State tracking system, compensation service
Performance Optimization
Priority: High
-
Payment Batching
- Description: Batch multiple payments for efficiency
- Implementation: Collect payments in time windows, batch process, optimize database writes
- Impact: Reduces database load and improves throughput
- Dependencies: Batching service, batch processing framework
-
Caching Strategy
- Description: Cache frequently accessed data
- Implementation: Cache account balances, FX rates, routing tables, use TTL-based invalidation
- Impact: Reduces database queries and improves response times
- Dependencies: Caching infrastructure (Redis), cache invalidation service
-
Async Processing
- Description: Process non-critical operations asynchronously
- Implementation: Use message queues for notifications, reporting, audit logging
- Impact: Improves API response times and system scalability
- Dependencies: Message queue infrastructure (Kafka, RabbitMQ)
Security Hardening
Priority: Critical
-
Request Signature Verification
- Description: Verify all payment requests are properly signed
- Implementation: Use HSM-backed signatures, verify signatures on all requests, reject unsigned requests
- Impact: Prevents unauthorized payment requests
- Dependencies: HSM infrastructure, signature verification service
-
Rate Limiting
- Description: Implement per-sovereign rate limiting
- Implementation: Track request rates, enforce limits, alert on violations
- Impact: Prevents abuse and ensures fair resource allocation
- Dependencies: Rate limiting middleware, monitoring system
-
Audit Logging
- Description: Comprehensive audit trail for all payments
- Implementation: Log all payment operations, store in tamper-proof storage, enable audit queries
- Impact: Enables compliance and forensic analysis
- Dependencies: Audit logging service, secure storage
Monitoring Points
Priority: High
-
Payment Latency Monitoring
- Monitor time at each layer (L1, L2, L3)
- Alert on SLA violations
- Track p50, p95, p99 latencies
-
Error Rate Monitoring
- Track error rates by error type
- Monitor authentication failures
- Alert on error rate spikes
-
Throughput Monitoring
- Track payments per second
- Monitor queue depths
- Alert on capacity issues
Testing Approaches
Priority: Medium
-
Load Testing
- Test system under expected load
- Identify bottlenecks
- Validate SLA compliance
-
Chaos Engineering
- Test failure scenarios
- Validate failover mechanisms
- Ensure system resilience
-
Security Testing
- Penetration testing
- Fuzz testing
- Vulnerability scanning
Related Flows: