# ignertic/paynow architecture

> Architecture diagram of the GitHub repository ignertic/paynow, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-02-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ignertic/paynow
- Repository: https://github.com/ignertic/paynow

## Overview

##### Project Type Analysis
This is a Flutter SDK package that provides payment integration capabilities with the Paynow payment gateway, supporting both web and mobile-based transactions.

##### Main Components

A. Core SDK Components:
- Payment Processing Layer
- Transaction Management
- Status Monitoring System
- Authentication/Security Layer

B. Integration Points:
- Paynow API Gateway
- Mobile Money Services (Ecocash, OneMoney)
- Web Payment Interface

**┌─ Flutter Application ─────────────────────────────────────┐**

- ┌─ Paynow SDK ────────────────────────────────────┐    │

- ┌─ Core Services ─────┐  ┌─ Payment Models ──┐ │    │
- Payment Creation  │  │ - Payment         │ │    │
- Cart Management   │  │ - Cart Items      │ │    │
- Hash Generation   │  │ - Init Response   │ │    │
- Status Polling    │  │ - Status Response │ │    │
- ┘  └────────────────────┘    │

- ┌─ Payment Channels ───────────────────────┐    │    │
- Web Checkout                           │    │    │
- Mobile Money (Ecocash/OneMoney)        │    │    │
- ┘    │    │
- ┘    │

- ┘

- ↓                         ↓

**┌─ Paynow Gateway API ─┐    ┌─ Payment Providers ─┐**
- Authentication     │    │ - Ecocash           │
- Transaction Init   │←→│ - OneMoney          │
- Status Updates     │    │ - Web Payment       │
- ┘    └──────────────────────┘

##### Important Elements to Highlight

a. Data Flow:
- Payment initialization flow
- Status polling mechanism
- Webhook/callback paths

b. Key Components:
- Payment Processing System
- Transaction Status Stream Manager
- Mobile Payment Methods
- Web Checkout Flow

##### Implementation Details

Technical notes showing:
- Integration with Flutter apps
- Authentication flow
- Error handling paths
- Status monitoring system

##### Security and authentication mechanisms

Remember to include notes about the upcoming null-safety implementation in version 2.x.x as this will affect the architecture.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Flutter_App
        subgraph Paynow_SDK
            subgraph Core_Services
                PaymentProcessing["Payment Processing"]:::core
                CartManagement["Cart Management"]:::core
                HashGen["Hash Generation"]:::core
                StatusPolling["Status Polling"]:::core
            end

            subgraph Payment_Models
                PaymentModel["Payment Model"]:::model
                CartItems["Cart Items"]:::model
                InitResponse["Init Response"]:::model
                StatusResponse["Status Response"]:::model
                Currency["Currency Handler"]:::model
            end

            subgraph Payment_Channels
                WebCheckout["Web Checkout"]:::channel
                MobileMoney["Mobile Money\n(Ecocash/OneMoney)"]:::channel
            end

            subgraph Error_Handling
                ErrorManager["Error Manager"]:::error
            end

            subgraph Status_Monitor
                StatusStream["Status Stream Manager"]:::monitor
            end
        end

        subgraph Integration_Example
            CheckoutBloc["Checkout Bloc"]:::example
            CheckoutPage["Checkout Page"]:::example
            ReturnPage["Return Page"]:::example
        end
    end

    subgraph External_Services
        PaynowAPI["Paynow Gateway API"]:::external
        subgraph Payment_Providers
            Ecocash["Ecocash"]:::provider
            OneMoney["OneMoney"]:::provider
            WebPayment["Web Payment"]:::provider
        end
    end

    %% Relationships
    PaymentProcessing --> PaynowAPI
    PaymentProcessing --> StatusStream
    CartManagement --> PaymentProcessing
    HashGen --> PaymentProcessing
    StatusPolling --> StatusStream
    
    WebCheckout --> PaynowAPI
    MobileMoney --> PaynowAPI
    
    PaynowAPI --> Payment_Providers
    
    StatusStream --> StatusResponse
    PaymentProcessing --> PaymentModel
    CartManagement --> CartItems
    PaymentProcessing --> InitResponse
    
    CheckoutBloc --> PaymentProcessing
    CheckoutPage --> CheckoutBloc
    StatusStream --> ReturnPage

    %% Click Events
    click PaymentProcessing "https://github.com/ignertic/paynow/blob/master/lib/src/paynow.dart"
    click StatusStream "https://github.com/ignertic/paynow/blob/master/lib/payment_status_stream_manager/payment_status_stream_manager.dart"
    click HashGen "https://github.com/ignertic/paynow/blob/master/lib/src/hash.dart"
    click PaymentModel "https://github.com/ignertic/paynow/blob/master/lib/models/payment.dart"
    click InitResponse "https://github.com/ignertic/paynow/blob/master/lib/models/init_response.dart"
    click StatusResponse "https://github.com/ignertic/paynow/blob/master/lib/models/status_response.dart"
    click MobileMoney "https://github.com/ignertic/paynow/blob/master/lib/models/mobile_payment_methods.dart"
    click CartItems "https://github.com/ignertic/paynow/blob/master/lib/models/_paynow_cart_item.dart"
    click ErrorManager "https://github.com/ignertic/paynow/blob/master/lib/errors/errors.dart"
    click Currency "https://github.com/ignertic/paynow/blob/master/lib/models/currency.dart"
    click CheckoutBloc "https://github.com/ignertic/paynow/blob/master/example/lib/paynow/bloc/paynow_checkout_bloc.dart"
    click CheckoutPage "https://github.com/ignertic/paynow/blob/master/example/lib/paynow/ui/pages/paynow_checkout_page.dart"
    click ReturnPage "https://github.com/ignertic/paynow/blob/master/example/lib/paynow/ui/pages/paynow_return_page.dart"

    %% Styles
    classDef core fill:#2196F3,stroke:#1976D2,color:white
    classDef model fill:#4CAF50,stroke:#388E3C,color:white
    classDef channel fill:#FF9800,stroke:#F57C00,color:white
    classDef error fill:#f44336,stroke:#d32f2f,color:white
    classDef monitor fill:#9C27B0,stroke:#7B1FA2,color:white
    classDef external fill:#607D8B,stroke:#455A64,color:white
    classDef provider fill:#795548,stroke:#5D4037,color:white
    classDef example fill:#00BCD4,stroke:#0097A7,color:white
```
