# improntus/module-powerpay architecture

> Architecture diagram of the GitHub repository improntus/module-powerpay, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/improntus/module-powerpay
- Repository: https://github.com/improntus/module-powerpay

## Overview

PowerPay is a Magento payment module that lets shoppers initiate installment financing, sends transaction requests to PowerPay, and handles subsequent status updates and order invoicing or cancellation. Its runtime also stores transaction state, expires pending orders, and can show financing widgets on product, header, and banner areas. The graph follows relationships visible in the excerpts and source index; Magento configuration and layout wiring is not sampled, so those connections are not asserted.

Main entry points: [`Model/PowerPay.php`](https://github.com/improntus/module-powerpay/blob/main/Model/PowerPay.php) (Payment orchestration), [`Helper/Data.php`](https://github.com/improntus/module-powerpay/blob/main/Helper/Data.php) (Payment settings helper), [`Model/TransactionRepository.php`](https://github.com/improntus/module-powerpay/blob/main/Model/TransactionRepository.php) (Transaction repository), [`Cron/CancelOrder.php`](https://github.com/improntus/module-powerpay/blob/main/Cron/CancelOrder.php) (Pending order expiry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_checkout["Checkout and payment"]
  node_payment_ui["Payment UI<br/>[method.js]"]
  node_create_order["Create order flow<br/>[Create.php]"]
  node_response_order["Order response flow<br/>[Response.php]"]
  node_payment_core["Payment orchestration<br/>[PowerPay.php]"]
  node_currency_check["Currency validation"]
  node_order_views["Checkout result views"]
end

subgraph group_transactions["Transaction lifecycle"]
  node_callback_endpoint["Status callback endpoint<br/>[Callback.php]"]
  node_transaction_repo["Transaction repository"]
  node_transaction_store[("Transaction database resource<br/>[Transaction.php]")]
  node_expiry_job["Pending order expiry<br/>[CancelOrder.php]"]
end

subgraph group_configuration["Settings and widgets"]
  node_settings["Payment settings helper<br/>[Data.php]"]
  node_admin_settings["Admin payment settings<br/>[system.xml]"]
  node_widget_viewmodel["Financing widgets<br/>[Widgets.php]"]
  node_widget_template["Product widget template"]
  node_widget_provider["Checkout payment config<br/>[ConfigProvider.php]"]
end

subgraph group_integration["PowerPay integration"]
  node_web_service["REST client<br/>[WebService.php]"]
end

node_shopper(("Shopper"))
node_powerpay_service{{"PowerPay service"}}
node_external_widgets{{"External widget library"}}

node_shopper -.->|"selects payment"| node_payment_ui
node_payment_ui -.->|"starts checkout"| node_create_order
node_create_order -->|"creates transaction"| node_payment_core
node_response_order -->|"handles response"| node_payment_core
node_payment_core -->|"sends request"| node_web_service
node_web_service -->|"gets API settings"| node_settings
node_web_service -->|"calls REST API"| node_powerpay_service
node_payment_core -->|"saves transaction"| node_transaction_repo
node_transaction_repo -->|"loads and saves"| node_transaction_store
node_callback_endpoint -->|"processes status"| node_payment_core
node_callback_endpoint -->|"checks signature"| node_settings
node_expiry_job -->|"finds pending"| node_transaction_repo
node_expiry_job -->|"cancels order"| node_payment_core
node_expiry_job -->|"updates expiry status"| node_transaction_repo
node_widget_viewmodel -->|"reads widget settings"| node_settings
node_widget_template -.->|"renders widget"| node_widget_viewmodel
node_widget_viewmodel -->|"loads widget library"| node_external_widgets
node_widget_provider -->|"reads payment settings"| node_settings
node_payment_core -->|"reads credentials"| node_settings
node_payment_core -->|"validates currency"| node_currency_check
node_payment_core -.->|"provides order result"| node_order_views
node_admin_settings -.->|"configures payment"| node_settings

click node_payment_ui "https://github.com/improntus/module-powerpay/blob/main/view/frontend/web/js/view/payment/method.js"
click node_create_order "https://github.com/improntus/module-powerpay/blob/main/Controller/Order/Create.php"
click node_response_order "https://github.com/improntus/module-powerpay/blob/main/Controller/Order/Response.php"
click node_payment_core "https://github.com/improntus/module-powerpay/blob/main/Model/PowerPay.php"
click node_currency_check "https://github.com/improntus/module-powerpay/blob/main/Gateway/Validator/CurrencyValidator.php"
click node_order_views "https://github.com/improntus/module-powerpay/tree/main/Block/Onepage"
click node_callback_endpoint "https://github.com/improntus/module-powerpay/blob/main/Model/Api/Callback.php"
click node_transaction_repo "https://github.com/improntus/module-powerpay/blob/main/Model/TransactionRepository.php"
click node_transaction_store "https://github.com/improntus/module-powerpay/blob/main/Model/ResourceModel/Transaction.php"
click node_expiry_job "https://github.com/improntus/module-powerpay/blob/main/Cron/CancelOrder.php"
click node_settings "https://github.com/improntus/module-powerpay/blob/main/Helper/Data.php"
click node_admin_settings "https://github.com/improntus/module-powerpay/blob/main/etc/adminhtml/system.xml"
click node_widget_viewmodel "https://github.com/improntus/module-powerpay/blob/main/ViewModel/Widgets.php"
click node_widget_template "https://github.com/improntus/module-powerpay/blob/main/view/frontend/templates/productWidget.phtml"
click node_widget_provider "https://github.com/improntus/module-powerpay/blob/main/Model/ConfigProvider.php"
click node_web_service "https://github.com/improntus/module-powerpay/blob/main/Model/Rest/WebService.php"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_payment_ui,node_create_order,node_response_order,node_payment_core,node_currency_check,node_order_views toneBlue
class node_callback_endpoint,node_transaction_repo,node_transaction_store,node_expiry_job toneAmber
class node_settings,node_admin_settings,node_widget_viewmodel,node_widget_template,node_widget_provider toneMint
class node_web_service toneRose
class node_shopper,node_powerpay_service,node_external_widgets toneIndigo
```

## Components

### Checkout and payment

- [Payment UI](https://github.com/improntus/module-powerpay/blob/main/view/frontend/web/js/view/payment/method.js): `view/frontend/web/js/view/payment/method.js`
- [Create order flow](https://github.com/improntus/module-powerpay/blob/main/Controller/Order/Create.php): `Controller/Order/Create.php`
- [Order response flow](https://github.com/improntus/module-powerpay/blob/main/Controller/Order/Response.php): `Controller/Order/Response.php`
- [Payment orchestration](https://github.com/improntus/module-powerpay/blob/main/Model/PowerPay.php): `Model/PowerPay.php`
- [Currency validation](https://github.com/improntus/module-powerpay/blob/main/Gateway/Validator/CurrencyValidator.php): `Gateway/Validator/CurrencyValidator.php`
- [Checkout result views](https://github.com/improntus/module-powerpay/tree/main/Block/Onepage): `Block/Onepage`

### Transaction lifecycle

- [Status callback endpoint](https://github.com/improntus/module-powerpay/blob/main/Model/Api/Callback.php): `Model/Api/Callback.php`
- [Transaction repository](https://github.com/improntus/module-powerpay/blob/main/Model/TransactionRepository.php): `Model/TransactionRepository.php`
- [Transaction database resource](https://github.com/improntus/module-powerpay/blob/main/Model/ResourceModel/Transaction.php): `Model/ResourceModel/Transaction.php`
- [Pending order expiry](https://github.com/improntus/module-powerpay/blob/main/Cron/CancelOrder.php): `Cron/CancelOrder.php`

### Settings and widgets

- [Payment settings helper](https://github.com/improntus/module-powerpay/blob/main/Helper/Data.php): `Helper/Data.php`
- [Admin payment settings](https://github.com/improntus/module-powerpay/blob/main/etc/adminhtml/system.xml): `etc/adminhtml/system.xml`
- [Financing widgets](https://github.com/improntus/module-powerpay/blob/main/ViewModel/Widgets.php): `ViewModel/Widgets.php`
- [Product widget template](https://github.com/improntus/module-powerpay/blob/main/view/frontend/templates/productWidget.phtml): `view/frontend/templates/productWidget.phtml`
- [Checkout payment config](https://github.com/improntus/module-powerpay/blob/main/Model/ConfigProvider.php): `Model/ConfigProvider.php`

### PowerPay integration

- [REST client](https://github.com/improntus/module-powerpay/blob/main/Model/Rest/WebService.php): `Model/Rest/WebService.php`

### Other components

- **Shopper**
- **PowerPay service**
- **External widget library**

## Connections

- Shopper → Payment UI: selects payment
- Payment UI → Create order flow: starts checkout
- Create order flow → Payment orchestration: creates transaction (evidence: `Controller/Order/Create.php`)
- Order response flow → Payment orchestration: handles response (evidence: `Controller/Order/Response.php`)
- Payment orchestration → REST client: sends request (evidence: `Model/PowerPay.php`)
- REST client → Payment settings helper: gets API settings (evidence: `Model/Rest/WebService.php`)
- REST client → PowerPay service: calls REST API (evidence: `Model/Rest/WebService.php`)
- Payment orchestration → Transaction repository: saves transaction (evidence: `Model/PowerPay.php`)
- Transaction repository → Transaction database resource: loads and saves (evidence: `Model/TransactionRepository.php`)
- Status callback endpoint → Payment orchestration: processes status (evidence: `Model/Api/Callback.php`)
- Status callback endpoint → Payment settings helper: checks signature (evidence: `Model/Api/Callback.php`)
- Pending order expiry → Transaction repository: finds pending (evidence: `Cron/CancelOrder.php`)
- Pending order expiry → Payment orchestration: cancels order (evidence: `Cron/CancelOrder.php`)
- Pending order expiry → Transaction repository: updates expiry status (evidence: `Cron/CancelOrder.php`)
- Financing widgets → Payment settings helper: reads widget settings (evidence: `ViewModel/Widgets.php`)
- Product widget template → Financing widgets: renders widget
- Financing widgets → External widget library: loads widget library (evidence: `README.md`)
- Checkout payment config → Payment settings helper: reads payment settings (evidence: `Model/ConfigProvider.php`)
- Payment orchestration → Payment settings helper: reads credentials (evidence: `Model/PowerPay.php`)
- Payment orchestration → Currency validation: validates currency (evidence: `Gateway/Validator/CurrencyValidator.php`)
- Payment orchestration → Checkout result views: provides order result (evidence: `Block/Onepage/Success.php`)
- Admin payment settings → Payment settings helper: configures payment
