# dravasp/ccavenuepaymentgatewaymagentoseamless architecture

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

- Interactive diagram: https://gitdiagram.com/dravasp/ccavenuepaymentgatewaymagentoseamless
- Repository: https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless

## Overview

##### Project type and purpose
- This is a Magento 2 payment‐gateway integration module (dravasp/ccavenuepaymentgatewaymagentoseamless).
- It implements a new payment method “CCAvenue MCPG” in both the storefront checkout and admin configuration, handling all communication to/from the CCAvenue Internet Payment Gateway.

A. Magento Application
- Frontend (storefront)
– Controllers: Place.php, Redirect.php, ReturnUrl.php, SilentPost.php
– Blocks & Templates: view/frontend templates + view/frontend/web/js/… (KnockoutJS, RequireJS)
– UI ConfigProvider for checkout payment method
- Adminhtml (backend)
– System Configuration UI: etc/adminhtml/system.xml, CcavenuepayRules.php block
– Order view info: FraudDetails, other info blocks under Block/Adminhtml
– Admin controllers for module upload/update
- Business Logic & Service Layer
– Model/Method/Adapter for payment method configuration and behavior
– Model/TransactionService for order capture, void, refund
– Model/Session, Config, IframeConfigProvider
- Gateway Layer
– Gateway/Http/Client (real & mock), TransferFactory
– Gateway/Request (AuthorizationRequest, CaptureRequest, VoidRequest, MockDataRequest)
– Gateway/Response (TxnIdHandler, FraudHandler)
– Gateway/Validator/ResponseCodeValidator
– Factories to assemble/decode CCAvenue payloads
- Event/Observer Layer
– observers wired in etc/events.xml (e.g., DataAssignObserver, SaveOrderAfterSubmitObserver)
– listens for checkout and order events, enriches requests/responses
- Data persistence
– Magento database (orders, payment transactions, module config stored in core_config_data)
B. CCAvenue External Payment Gateway
– Endpoints:
- test.ccavenue.com/transaction.do?command=initiateTransaction
- secure.ccavenue.com/transaction.do?command=initiateTransaction
– Payload encryption/decryption (AES-256-CBC)
– Webhooks/Callbacks: ReturnUrl, SilentPost

##### Architectural patterns & design principles
- MVC (Controllers, Blocks as view‐models, PHTML templates)
- Gateway Pattern encapsulating HTTP transport, transfer objects
- Factory Pattern for Request/Response object creation
- Observer Pattern for reacting to Magento events
- Dependency Injection per di.xml

##### Key technologies, frameworks, libraries
- PHP 7.x, Magento 2.4.x (Composer-based)
- KnockoutJS & RequireJS for payment form UI (`view/frontend/web/js`)
- AES-256-CBC encryption in Helpers for payload security
- Magento’s Gateway/Http client or client mock for unit testing
- PHPUnit tests under Test/Unit

## Diagram (Mermaid)

```mermaid
graph TD
    %% Presentation Layer - Frontend
    subgraph "Presentation Layer: Frontend" 
        direction TB
        FC("Frontend Controllers"):::frontend
        FB("Blocks & Templates & JS"):::frontend
        CP("Checkout UI ConfigProvider"):::frontend
    end

    %% Presentation Layer - Adminhtml
    subgraph "Presentation Layer: Adminhtml"
        direction TB
        SC("System Configuration UI"):::frontend
        OV("Order View Info Blocks"):::frontend
        AC("Admin Upload/Update Controllers"):::frontend
    end

    %% Application Logic Layer
    subgraph "Application Logic Layer" 
        direction TB
        PM("Payment Method & Adapter"):::business
        TS("Transaction Service"):::business
        PC("Session & Config Providers"):::business
        OBS("Event Observers"):::business
    end

    %% Gateway Layer
    subgraph "Gateway Layer" 
        direction TB
        GC("HTTP Client & TransferFactory"):::gateway
        GR("Request Objects"):::gateway
        GH("Response Handlers & Validator"):::gateway
    end

    %% External and Infrastructure
    subgraph "Infrastructure & External"
        direction TB
        DB[(Magento Database)]:::database
        CC["CCAvenue API Endpoints"]:::external
    end

    %% Flows
    Shopper -->|Initiate Payment| FC
    FC -->|Build Auth Request| PM
    PM -->|create AuthorizationRequest| GR
    GR -->|create Transfer| GC
    GC -->|HTTPS Encrypt| CC
    CC -->|Session & Redirect URL| FC
    FC -->|Redirect Browser| Shopper

    CC -->|Return/Callback| FC
    FC -->|Handle Response| GH
    GH -->|TxnId/Fraud Data| TS
    TS -->|Update Order| DB
    TS -->|Trigger Observer| OBS
    OBS -->|Email & Status| Shopper

    SC -->|Config Save| DB
    DB -->|Read Config| PC
    PC -->|Provide Values| FC
    PC -->|Provide Values| PM

    %% Click Events - Frontend Controllers
    click FC "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/blob/main/Controller/Ccavenuepay/Place.php"
    click FC "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/blob/main/Controller/Ccavenuepay/Redirect.php"
    click FC "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/blob/main/Controller/Ccavenuepay/ReturnUrl.php"
    click FC "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/blob/main/Controller/Ccavenuepay/SilentPost.php"

    %% Click Events - Blocks & Templates & JS
    click FB "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/blob/main/Block/Ccavenuepay/Form.php"
    click FB "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/blob/main/Block/Ccavenuepay/Iframe.php"
    click FB "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/blob/main/view/frontend/templates/Ccavenuepay/form.phtml"
    click FB "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/blob/main/view/frontend/templates/Ccavenuepay/info.phtml"
    click FB "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/blob/main/view/frontend/templates/Ccavenuepay/redirect.phtml"
    click FB "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/tree/main/view/frontend/web/js"

    %% Click Event - ConfigProvider
    click CP "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/blob/main/Model/Ui/ConfigProvider.php"

    %% Click Events - Adminhtml
    click SC "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/blob/main/etc/adminhtml/system.xml"
    click SC "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/blob/main/Block/Adminhtml/System/Config/CcavenuepayRules.php"
    click OV "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/blob/main/Block/Adminhtml/Order/View/Info/FraudDetails.php"
    click AC "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/blob/main/Controller/Ccavenuepay/Checkmoduleupload.php"
    click AC "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/blob/main/Controller/Ccavenuepay/Newmoduleupdatenow.php"

    %% Click Events - Business Logic
    click PM "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/blob/main/Model/Method/Ccavenuepay.php"
    click PM "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/blob/main/Model/Method/Adapter.php"
    click TS "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/blob/main/Model/TransactionService.php"
    click PC "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/blob/main/Model/Ccavenuepay/Session.php"
    click PC "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/blob/main/Model/Config.php"
    click PC "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/blob/main/Model/IframeConfigProvider.php"
    click OBS "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/blob/main/Observer/DataAssignObserver.php"
    click OBS "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/blob/main/Observer/SaveOrderAfterSubmitObserver.php"
    click OBS "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/blob/main/Observer/AddFieldsToResponseObserver.php"
    click OBS "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/blob/main/Observer/CheckPaymentAvailabilityObserver.php"
    click OBS "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/blob/main/Observer/RestrictAdminUsageObserver.php"
    click OBS "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/blob/main/Observer/UpdateAllEditIncrementsObserver.php"

    %% Click Events - Gateway
    click GC "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/blob/main/Gateway/Http/Client/ClientMock.php"
    click GC "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/blob/main/Gateway/Http/TransferFactory.php"
    click GR "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/blob/main/Gateway/Request/AuthorizationRequest.php"
    click GR "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/blob/main/Gateway/Request/CaptureRequest.php"
    click GR "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/blob/main/Gateway/Request/VoidRequest.php"
    click GR "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/blob/main/Gateway/Request/MockDataRequest.php"
    click GH "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/blob/main/Gateway/Response/TxnIdHandler.php"
    click GH "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/blob/main/Gateway/Response/FraudHandler.php"
    click GH "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/blob/main/Gateway/Validator/ResponseCodeValidator.php"

    %% Click Events - Module Bootstrap
    click DB "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/blob/main/registration.php"
    click DB "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/blob/main/etc/module.xml"
    click DB "https://github.com/dravasp/ccavenuepaymentgatewaymagentoseamless/blob/main/composer.json"

    %% Styles
    classDef frontend fill:#E0F7FA,stroke:#006064,color:#006064
    classDef business fill:#E8F5E9,stroke:#2E7D32,color:#2E7D32
    classDef gateway fill:#FFF3E0,stroke:#E65100,color:#E65100
    classDef database fill:#ECEFF1,stroke:#455A64,color:#455A64
    classDef external fill:#F3E5F5,stroke:#6A1B9A,color:#6A1B9A
```
