Skip to main content

Payment Orchestration Service - Product Requirements Document

Version: 1.0
Date: December 2024
Status: Draft
Author: Development Team


Table of Contents​

  1. Executive Summary
  2. Problem Statement
  3. Target Users & Personas
  4. Features & Requirements
  5. Success Metrics
  6. Constraints & Assumptions
  7. Risk Assessment

1. Executive Summary​

1.1 What We're Building​

Payment Orchestration Service is a unified API platform that enables businesses to accept payments through multiple payment providers (Paystack, Stripe, Flutterwave, etc.) with a single integration. The platform provides intelligent routing, automatic fallback, comprehensive reconciliation, and actionable insights.

1.2 Why We're Building It​

Market Problem:

  • Nigerian/African businesses lose 8-10% of potential revenue due to payment failures
  • Integrating multiple payment providers takes 3+ months and $15k-30k in developer time
  • Manual reconciliation across multiple providers consumes 4+ hours daily
  • Businesses are locked into single providers with no negotiating power

Our Solution:

  • 3 Months → 2 Hours: One integration instead of multiple
  • 8% → 99%+ Success Rate: Automatic fallback across providers
  • 4 Hours → 15 Minutes: Automated reconciliation
  • Provider Independence: Switch providers without code changes

1.3 Target Market​

Primary: Nigerian & African e-commerce businesses and SaaS companies
Secondary: Global businesses needing African payment methods
Tertiary: Fintech companies requiring payment orchestration

1.4 Success Criteria​

Technical:

  • 99.9% uptime
  • < 500ms API response time (p95)
  • 98%+ payment success rate (when providers are healthy)
  • Support for 3+ providers in MVP

Business:

  • 10+ active customers in first 3 months
  • Process ₦100M+ in payment volume
  • 90%+ customer satisfaction score

2. Problem Statement​

2.1 Current Pain Points​

For E-commerce Businesses:

  1. Payment Failures = Lost Revenue

    • Single provider (e.g., Paystack) has 92% success rate
    • 8% failure = ₦40M lost on ₦500M monthly revenue
    • No automatic retry mechanism
  2. Complex Multi-Provider Integration

    • Each provider has different API formats
    • Different webhook structures
    • Different error codes
    • 3+ months to integrate 3 providers
  3. Manual Reconciliation Nightmare

    • Download CSV from each provider daily
    • Manually match transactions in Excel
    • 4+ hours daily for finance team
    • High error rate in manual matching
  4. Vendor Lock-in

    • Dependent on single provider
    • No negotiating power on fees
    • Risk if provider has downtime or changes terms

For Developers:

  1. Integration Complexity

    • Different SDKs for each provider
    • Different authentication methods
    • Different webhook verification
    • Constant maintenance as APIs change
  2. Fallback Logic Complexity

    • Must build retry logic from scratch
    • Handle race conditions
    • Manage state across providers
    • Debug multi-provider issues

2.2 Market Opportunity​

Nigerian E-commerce Market:

  • $12B+ annual e-commerce volume (growing 25% YoY)
  • 50M+ online shoppers
  • 8-10% payment failure rate = $960M-$1.2B lost annually

Target Addressable Market:

  • 10,000+ Nigerian e-commerce businesses
  • 5,000+ SaaS companies accepting payments
  • Average transaction volume: ₦50M-500M/month per business

Competitive Landscape:

  • Stripe Connect: Global but weak African coverage, expensive
  • Adyen: Enterprise-focused, complex, expensive
  • Direct Integration: Time-consuming, maintenance-heavy
  • Our Advantage: African-first, multi-provider, simple, affordable

3. Target Users & Personas​

3.1 Primary Persona: Fast-Growing E-commerce Founder​

Name: Chidi
Role: Founder/CTO of Nigerian e-commerce startup
Company Size: 10-50 employees
Transaction Volume: 1,000-5,000 orders/month
Pain Points:

  • Losing ₦500k-5M/month to failed payments
  • Can't afford 3 months to integrate multiple providers
  • Finance team overwhelmed with reconciliation

Goals:

  • Increase payment success rate
  • Reduce integration time
  • Automate reconciliation

Willingness to Pay: High ($50-200/month)

3.2 Secondary Persona: Established E-commerce Finance Manager​

Name: Ada
Role: Finance Manager at established e-commerce
Company Size: 50-200 employees
Transaction Volume: 10,000+ orders/month
Pain Points:

  • Already using 2-3 providers manually
  • Spending 4+ hours daily on reconciliation
  • Can't get unified view of all payments

Goals:

  • Automate reconciliation
  • Get unified analytics
  • Reduce manual work

Willingness to Pay: Very High ($200-1000/month)

3.3 Tertiary Persona: SaaS Developer​

Name: Tunde
Role: Backend Developer at SaaS company
Company Size: 5-20 employees
Transaction Volume: Variable (subscriptions)
Pain Points:

  • Need reliable payments for subscription renewals
  • International customers need different providers
  • Can't handle provider downtime

Goals:

  • Reliable payment processing
  • Global reach
  • Easy integration

Willingness to Pay: Medium-High ($100-500/month)


4. Features & Requirements​

4.1 MVP Features (Weeks 1-8) - NOW​

4.1.1 Core Payment Features​

Payment Initiation API

  • POST /v1/payments: Create payment

    • Accept amount, currency, customer email
    • Support multiple currencies (NGN, USD, EUR, GBP, GHS, ZAR, KES)
    • Amount validation (min/max by currency)
    • Customer metadata support
  • GET /v1/payments/:id: Get payment status

    • Real-time status updates
    • Payment history/timeline
  • POST /v1/payments/:id/refund: Process refunds

    • Full and partial refunds
    • Refund status tracking

Payment Methods Supported:

  • ✅ Card payments (all providers)
  • ✅ Bank transfers (Paystack, Flutterwave)
  • ⏭️ USSD (V2)
  • ⏭️ Mobile Money (V2)
  • ⏭️ QR Codes (V2)

4.1.2 Provider Integration​

Supported Providers (V1):

  • Paystack (Nigeria, Ghana, South Africa)
  • Stripe (Global)
  • Flutterwave (Pan-African, 34+ countries)

Provider Features:

  • Unified adapter interface
  • Provider-specific error mapping
  • Test and live mode support
  • Automatic provider selection (priority-based)
  • Fallback on provider failure (opt-in)

4.1.3 Webhook Infrastructure​

Incoming Webhooks (from providers):

  • Webhook receiver endpoint per provider
  • Signature verification (HMAC)
  • Idempotent processing (Redis-based)
  • Automatic retry for failed processing
  • Webhook event storage for debugging

Outgoing Webhooks (to customers):

  • Customer webhook endpoint registration
  • Event subscription (payment.completed, payment.failed, etc.)
  • HMAC signature generation
  • Retry mechanism (7 attempts over 31 hours)
  • Webhook delivery logs

4.1.4 Transaction State Management​

State Machine:

  • States: pending → processing → completed/failed/cancelled
  • Atomic state transitions (PostgreSQL transactions)
  • Immutable audit log (payment_events table)
  • Status polling endpoint

4.1.5 Multi-Tenancy & Authentication​

API Key Management:

  • Generate publishable/secret keys per tenant
  • Test mode vs Live mode keys (different prefixes)
  • Key hashing in database (never store plaintext)
  • Key rotation capability

Tenant Isolation:

  • Row-level security (all queries scoped to tenant)
  • Separate test/live mode data per tenant
  • Tenant middleware for request context

4.1.6 Basic Dashboard​

Features:

  • Authentication (email/password)
  • Email verification
  • Password reset
  • Test/Live mode toggle
  • API keys management (view, create, revoke)
  • Recent payments list (last 100)
  • Payment detail view
  • Provider configuration (add API keys per provider)
  • Webhook endpoint configuration
  • Webhook delivery logs
  • Basic statistics (today/week/month volume)
  • KYC form submission
  • KYC status view (pending/approved/rejected)
  • 2FA support
  • Team management (Owner, Admin, Developer, Viewer roles)

4.1.7 Security Basics​

  • Rate limiting (by IP and by API key)
  • Request validation (class-validator DTOs)
  • CORS configuration
  • Helmet.js for security headers
  • Input sanitization
  • Audit logs (all sensitive actions)

4.1.8 Developer Experience​

API Documentation:

  • OpenAPI/Swagger spec
  • Interactive API explorer
  • Request/response examples
  • Error code documentation

Test Environment:

  • Mock provider for instant testing
  • Test mode API keys
  • Test cards/accounts
  • Sandbox environment

4.2 Phase 2 Features (Weeks 9-16) - NEXT​

4.2.1 Advanced Payment Features​

  • Payment Intents (pre-authorization)
  • Recurring payments (subscriptions)
  • Payment Links
  • Invoicing

4.2.2 Reliability & Resilience​

  • Circuit breaker pattern (per provider)
  • Advanced retry logic (exponential backoff with jitter)
  • Distributed locking (Redis-based)
  • Health checks for providers
  • Automatic failover

4.2.3 Ledger & Reconciliation​

  • Double-entry ledger system
  • Daily reconciliation jobs
  • Discrepancy detection and alerting
  • Reconciliation reports (CSV/PDF export)

4.2.4 Additional Providers​

  • Monnify (Nigeria)
  • PayPal (Global)
  • Quickteller (Interswitch - Nigeria)

4.2.5 Smart Routing​

  • Route by geography
  • Route by amount
  • Route by success rate
  • Cost optimization routing

4.2.6 Observability​

  • Structured logging (Winston/Pino)
  • Prometheus metrics
  • Distributed tracing (OpenTelemetry)
  • Alerting (PagerDuty/Opsgenie integration)
  • Grafana dashboards

4.3 Future Features (Weeks 17+) - LATER​

  • Recurring payments & subscriptions
  • Payouts (send money to users)
  • Installment payments
  • Advanced analytics dashboard
  • Machine learning routing
  • White-label option
  • SDK/Client libraries (JS, Python, PHP, Ruby, Go)
  • Mobile SDKs

5. Success Metrics​

5.1 Technical Metrics​

API Performance:

  • Uptime: 99.9% (target)
  • Response Time: p50 < 200ms, p95 < 500ms, p99 < 1s
  • Payment Success Rate: 98%+ (when providers are healthy)
  • Webhook Processing: < 5 seconds from receipt

System Health:

  • Database connection pool: < 80% utilization
  • Redis memory: < 80% utilization
  • Queue backlog: < 1000 jobs
  • Error rate: < 0.1%

5.2 Business Metrics​

Adoption:

  • Number of active tenants: 10+ in first 3 months
  • Number of transactions: 10,000+ in first month
  • Total Payment Volume (TPV): ₦100M+ in first 3 months

Customer Health:

  • Time to first payment: < 1 hour from signup
  • Days to go live: < 7 days (from KYC approval)
  • API errors per customer: < 1% of requests
  • Churn rate: < 5% monthly

Revenue (Future):

  • Monthly Recurring Revenue (MRR): Track when monetization starts
  • Customer Lifetime Value (LTV)
  • Customer Acquisition Cost (CAC)

5.3 Product Metrics​

Feature Usage:

  • % of customers using multiple providers: 60%+
  • % of payments with fallback: 10-15%
  • Average providers per customer: 2+
  • Webhook delivery success rate: 99%+

Provider Distribution:

  • Paystack: 60-70% of transactions
  • Flutterwave: 20-30% of transactions
  • Stripe: 10-20% of transactions

6. Constraints & Assumptions​

6.1 Technical Constraints​

  • Architecture: Modular Monolith (not microservices initially)
  • Database: PostgreSQL (ACID compliance required)
  • Caching: Redis (for idempotency, locks, cache)
  • Queue: BullMQ or RabbitMQ (for async jobs)
  • Deployment: AWS (ECS Fargate or EKS)
  • Language: TypeScript/Node.js (NestJS framework)

6.2 Business Constraints​

  • Regulatory: Aggregator model (not Payment Facilitator) - no CBN license needed
  • Monetization: Free initially, SaaS pricing later
  • Team: Solo developer (20 hours/week)
  • Timeline: 8 weeks for MVP

6.3 Assumptions​

Market Assumptions:

  • Nigerian/African market has demand for payment orchestration
  • Businesses are willing to pay for higher success rates
  • Customers already have provider accounts (aggregator model)

Technical Assumptions:

  • Provider APIs are stable and well-documented
  • Webhooks are reliable (with retries)
  • AWS infrastructure is available and affordable

Business Assumptions:

  • No regulatory issues with aggregator model
  • Customers trust us with their API keys (encrypted)
  • Market is ready for this solution

6.4 Out of Scope (MVP)​

  • Payment Facilitator model (we don't handle money)
  • Settlement tracking (customers handle in provider dashboards)
  • Chargeback management (V2)
  • Advanced fraud detection (V2)
  • Mobile apps (web dashboard only for MVP)
  • White-label option (V2+)

7. Risk Assessment​

7.1 Technical Risks​

Risk: Provider API Changes

  • Impact: High - Could break integrations
  • Probability: Medium
  • Mitigation: Version pinning, adapter pattern isolates changes, monitoring

Risk: Webhook Reliability

  • Impact: High - Payments might not update
  • Probability: Medium
  • Mitigation: Polling backup, retry mechanism, reconciliation jobs

Risk: Database Performance

  • Impact: Medium - Slow queries affect UX
  • Probability: Low
  • Mitigation: Proper indexing, connection pooling, read replicas

7.2 Business Risks​

Risk: Regulatory Changes

  • Impact: High - Could require licensing
  • Probability: Low
  • Mitigation: Consult Nigerian fintech lawyer, stay as aggregator

Risk: Low Adoption

  • Impact: High - No customers
  • Probability: Medium
  • Mitigation: Strong value proposition, free tier, good documentation

Risk: Provider Relationships

  • Impact: Medium - Providers might restrict API access
  • Probability: Low
  • Mitigation: Use official APIs, follow best practices, maintain good relationships

7.3 Operational Risks​

Risk: Single Point of Failure

  • Impact: High - Service downtime
  • Probability: Low
  • Mitigation: Multi-AZ deployment, health checks, monitoring

Risk: Security Breach

  • Impact: Critical - API keys compromised
  • Probability: Low
  • Mitigation: Encryption at rest, KMS, audit logs, security best practices

Appendix​

A. Glossary​

  • TPV: Total Payment Volume
  • PSP: Payment Service Provider
  • CBN: Central Bank of Nigeria
  • KYC: Know Your Customer
  • PCI-DSS: Payment Card Industry Data Security Standard
  • SLA: Service Level Agreement

B. References​

  • Paystack API Documentation
  • Stripe API Documentation
  • Flutterwave API Documentation
  • Nigerian Fintech Regulations

Document Status: Draft - Awaiting Review
Next Review Date: TBD
Version History:

  • v1.0 (Dec 2024): Initial draft