# uddoktapay/laravelsdk architecture

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

- Interactive diagram: https://gitdiagram.com/uddoktapay/laravelsdk
- Repository: https://github.com/uddoktapay/laravelsdk

## Overview

##### Main Components

a. Client Application Layer:
- Routes integration points (checkout, verify, cancel, ipn, refund)

b. SDK Core Layer (Middle):
- Central UddoktaPay class component
- Request handlers (CheckoutRequest, RefundRequest)
- Response handlers (CheckoutResponse, RefundResponse, VerifyResponse)
- HTTP Client component

c. External Service Layer:
- UddoktaPay API Gateway
- Payment Processing Systems

##### Component Relationships

**Client App → SDK Core → UddoktaPay API**
- ↓
- Response Handling
- ↓
**Client App ← SDK Core ← UddoktaPay API**

##### Detailed Component Breakdown

a. SDK Core (UddoktaPay.php):
- Configuration management
- API key handling
- Main interface methods (checkout, verify, refund)

b. Request/Response Flow:
- Request formation (Concerns/Normalize.php)
- HTTP client handling (Http/Client.php)
- Response parsing
- Exception handling (UddoktaPayException)

c. Integration Points:
- Webhook handling (IPN)
- Verification endpoints
- Refund processing
- Checkout flow

##### Technical Details to Note

Small notes about:
- API URL configuration
- Authentication mechanism
- Response status handling
- Error propagation

##### Refund Processing Flow

Remember to include:
- Entry points from the client application
- SDK core processing
- External API communication
- Response handling back to the client
- Error handling paths

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Application Layer"]
        Routes["Integration Routes"]
        Checkout["Checkout Endpoint"]
        Verify["Verify Endpoint"]
        Cancel["Cancel Endpoint"]
        IPN["IPN Handler"]
        Refund["Refund Endpoint"]
    end

    subgraph Core["SDK Core Layer"]
        UddoktaPay["UddoktaPay Core"]:::core
        click UddoktaPay "https://github.com/UddoktaPay/LaravelSDK/blob/2.x/src/UddoktaPay.php"
        
        subgraph Requests["Request Handlers"]
            CheckoutReq["Checkout Request"]:::request
            RefundReq["Refund Request"]:::request
            click CheckoutReq "https://github.com/UddoktaPay/LaravelSDK/blob/2.x/src/Requests/CheckoutRequest.php"
            click RefundReq "https://github.com/UddoktaPay/LaravelSDK/blob/2.x/src/Requests/RefundRequest.php"
        end

        subgraph Responses["Response Handlers"]
            CheckoutRes["Checkout Response"]:::response
            RefundRes["Refund Response"]:::response
            VerifyRes["Verify Response"]:::response
            click CheckoutRes "https://github.com/UddoktaPay/LaravelSDK/blob/2.x/src/Responses/CheckoutResponse.php"
            click RefundRes "https://github.com/UddoktaPay/LaravelSDK/blob/2.x/src/Responses/RefundResponse.php"
            click VerifyRes "https://github.com/UddoktaPay/LaravelSDK/blob/2.x/src/Responses/VerifyResponse.php"
        end

        HTTPClient["HTTP Client"]:::http
        click HTTPClient "https://github.com/UddoktaPay/LaravelSDK/blob/2.x/src/Http/Client.php"
        
        Normalize["Request Normalizer"]:::util
        click Normalize "https://github.com/UddoktaPay/LaravelSDK/blob/2.x/src/Concerns/Normalize.php"
        
        Exception["UddoktaPay Exception"]:::error
        click Exception "https://github.com/UddoktaPay/LaravelSDK/blob/2.x/src/Exceptions/UddoktaPayException.php"
    end

    subgraph External["External Service Layer"]
        Gateway["UddoktaPay API Gateway"]
        Payment["Payment Processing Systems"]
    end

    %% Connections
    Routes --> UddoktaPay
    Checkout --> CheckoutReq
    Verify --> UddoktaPay
    Cancel --> UddoktaPay
    IPN --> UddoktaPay
    Refund --> RefundReq

    CheckoutReq --> Normalize
    RefundReq --> Normalize
    Normalize --> HTTPClient
    HTTPClient --> Gateway
    Gateway --> Payment

    Gateway --> CheckoutRes
    Gateway --> RefundRes
    Gateway --> VerifyRes
    
    CheckoutRes --> UddoktaPay
    RefundRes --> UddoktaPay
    VerifyRes --> UddoktaPay

    HTTPClient -.- Exception
    UddoktaPay -.- Exception

    %% Styles
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef request fill:#9b59b6,stroke:#8e44ad,color:white
    classDef response fill:#9b59b6,stroke:#8e44ad,color:white
    classDef http fill:#e67e22,stroke:#d35400,color:white
    classDef util fill:#1abc9c,stroke:#16a085,color:white
    classDef error fill:#e74c3c,stroke:#c0392b,color:white

    %% Legend
    subgraph Legend
        L1["Core Component"]:::core
        L2["Request/Response Handler"]:::request
        L3["HTTP Client"]:::http
        L4["Utility Component"]:::util
        L5["Error Handler"]:::error
    end
```
