🚀 Smart Pay Direct (SPD) – Real-Time Payment & Settlement Flow

Step 1: QR Scan & API Trigger
Triggered via SPD mobile app to Azure App Service and authenticated.
⏱ SLA: 0.5s | 🔁 Retries: 0 | ✅ Status: Completed | 🕒 09:00:01
Step 2: Bank Rail Detection
Azure Function DeterminePaymentRail selects RTP or FedNow using routing info from Cosmos DB.
[FunctionName("DeterminePaymentRail")] public static string Run(string routingNumber) => BankRoutingMap[routingNumber];
⏱ SLA: 0.3s | 🔁 Retries: 0 | ✅ Status: FedNow | 🕒 09:00:01
Step 3: Durable Orchestrator Initialized
Function InstantSettlementOrchestrator starts with PaymentInfo object.
await context.CallActivityAsync("ConfirmDebit", info); await context.CallActivityAsync("InitiateRTPTransfer", info); await context.CallActivityAsync("ConfirmCredit", info);
⏱ SLA: 0.2s | 🔁 Retries: 0 | ✅ Status: Running | 🕒 09:00:01
Step 4: RTP Payment via Modern Treasury
Durable Activity InitiateRTPTransfer posts to Modern Treasury RTP API.
POST https://api.moderntreasury.com/api/payment_orders Authorization: Bearer API_KEY Content-Type: application/json
{ "amount": 10000, "currency": "USD", "direction": "debit", "originating_account_id": "acct_123", "receiving_account": { "account_number": "987654321", "routing_number": "111000025", "account_type": "checking", "name": "Merchant LLC" }, "payment_type": "real_time_payments", "purpose": "qr_settlement" }
⏱ SLA: 1.0s | 🔁 Retries: 0 | ✅ Status: Sent | 🕒 09:00:02
Step 5: Webhook Listener Activated
Azure Function ModernTreasuryWebhookHandler is ready to receive payment_order.* events.
if (WebhookValidator.IsValid(rawBody, sig, secret)) { var evt = JsonConvert.DeserializeObject(rawBody); switch (evt.EventType) { case "payment_order.completed": await context.CallActivityAsync("UpdateLedger", evt.Data); break; } }
⏱ SLA: 0.2s | 🔁 Retries: 0 | ✅ Status: Ready | 🕒 09:00:02
Step 6: Webhook Receipt & Event Routing
Webhook event payment_order.completed is validated and routed to UpdateLedger.
{ "event_type": "payment_order.completed", "data": { "id": "po_abc123", "status": "completed", "amount": 10000, "currency": "USD", "direction": "debit" }, "record_type": "event", "created_at": "2025-07-13T09:00:03Z" }
⏱ SLA: 1.0s | 🔁 Retries: 0 | ✅ Status: Routed | 🕒 09:00:03
Step 7: SPD Ledger Update
Activity UpdateLedger updates SPD system transaction ledger.
await LedgerService.WriteAsync(info.QrInvoiceId, "Settled");
⏱ SLA: 1.5s | 🔁 Retries: 1 | ✅ Status: Completed | 🕒 09:00:04
Step 8: Audit Trail Logged
Activity LogAudit writes metadata to Cosmos DB for reconciliation & history.
await AuditLogger.WriteAsync(new AuditEntry { Status = "Completed" });
⏱ SLA: 1.5s | 🔁 Retries: 0 | ✅ Status: Logged | 🕒 09:00:04
Step 9: Final SPD Settlement Confirmed
Orchestrator terminates. All parties reconciled across banks, merchant, and ledger.
⏱ SLA: 0.5s | 🔁 Retries: 0 | ✅ Status: Success | 🕒 09:00:05