How adyen/adyen-magento2 works
1. This repository is a single Magento 2 module, Adyen_Payment, that plugs Adyen payments into Adobe Commerce. The architecture is shaped by Magento extension points: DI configuration, observers, plugins, blocks/templates, controllers, cron jobs, webhooks, GraphQL resolvers, REST APIs, and UI component providers.
2. The core business boundary is the payment integration layer under Gateway/. It builds Adyen API requests from Magento order/quote/payment data, sends them through HTTP clients, validates responses, and maps those responses back into Magento order state, status history, captures, refunds, cancels, donation flows, payment links, and POS cloud sync.
3. Frontend checkout integration lives primarily in view/frontend/, Model/Ui/, Block/Checkout, Block/Form, and view/frontend/web/js. Magento checkout renders Adyen-specific payment methods and components, while JavaScript models coordinate checkout state, payment component state, shipping/payment information, and success-page behavior.
4. Adminhtml functionality is a separate subsystem centered on Controller/Adminhtml, Block/Adminhtml, Model/Config/Adminhtml, and view/adminhtml/. It provides configuration wizard screens, merchant account setup, webhook testing, notifications, support forms, and custom system configuration fields for payment method settings and activation.
5. Webhook processing is a major backend flow. Incoming webhook requests hit Controller/Webhook/Index, are stored as Notification records, and are later processed by Cron/WebhookProcessor and the webhook helper/acceptor classes. This separates receipt of notifications from the actual order updates so processing can happen after Magento has created and persisted the order.
6. Persistence is handled through Magento resource models and repositories in Model/ResourceModel, Model/Repository, and Model/Sales. The module stores its own operational state such as notifications, payment responses, analytics events, checkout state data, and related creditmemo/invoice/order-payment records, rather than relying only on Magento sales tables.
7. The module has a distinct headless/API surface in Api/, Model/Api/, and Model/Resolver/. These interfaces and implementations expose Adyen functions such as payment methods retrieval, payment details, payment status, gift cards, donations, POS Cloud initiation, and state-data save/remove for GraphQL and REST consumers.
8. A second integration boundary is the asynchronous and scheduled processing layer. Cron jobs clean up analytics and state data, cancel expired orders, process queued notifications/webhooks, and refresh Adyen server IPs for validation. There is also a queue-based notification publisher/consumer path under Model/Queue/Notification for decoupled processing.
9. Observers and plugins form the Magento adaptation layer. Observers attach Adyen data to quotes/orders/invoices/credit memos and adjust order state after payment. Plugins intercept checkout, REST, GraphQL, multishipping, vault, and instant purchase flows to keep Adyen behavior consistent across Magento entry points.
10. Supporting subsystems include analytics/event submission, logging, and support tooling. Model/AnalyticsEvent, Cron/SubmitAnalyticsEvents, and logger handlers track operational events; dedicated admin support forms and email templates provide merchant-facing troubleshooting and configuration assistance.
11. The module supports multiple payment modes and domains: standard online cards, alternative payment methods, gift cards, Pay by Link, POS Cloud/in-store, partial payments, recurring/vault, and instant purchase. These variants are reflected in separate request builders, UI config providers, info blocks, and payment method renderers rather than being handled by one generic path.
12. The repository is heavily tested, with unit tests covering most service classes, plus API functional suites for GraphQL and WebAPI, and MFTF coverage for Magento UI flows. The .github directory also shows CI/CD pipelines for unit, REST, GraphQL, E2E, and Magento functional testing, which indicates the module’s architecture is validated across storefront, admin, and headless execution paths.
Main entry points: Client HTTP clients · Request Request builders · Model Repositories · Resolver GraphQL resolvers
Components 21
Gateway
Builds, sends, and interprets Adyen payment requests and responses.
- Request builders · Builds Adyen API payloads from Magento order, quote, and shopper data.
Gateway/Request - HTTP clients · Sends payment, capture, refund, cancel, donate, payment-link, and POS sync calls.
Gateway/Http/Client - Response handlers · Maps Adyen responses back into order state, histories, and payment outcomes.
Gateway/Response - Validators · Validates checkout, modification, payment-link, donate, and POS responses.
Gateway/Validator - Webhook handlers · Dispatches webhook event types to domain-specific order and contract handlers.
Helper/Webhook
Storefront
Checkout and customer-facing payment rendering and state handling.
- Checkout UI · Renders payment methods, forms, and success-page behavior for Adyen checkout.
view/frontend/web/js/view/payment - Checkout models · Coordinates checkout state, shipping/payment information, and component state.
view/frontend/web/js/model - Payment templates · Provides Knockout templates for card, PM, vault, giftcard, and POS views.
view/frontend/web/template/payment - Payment blocks · Supplies checkout, form, info, and customer-renderer blocks for storefront output.
Block
Admin
Configuration, support, and merchant operations in Magento admin.
- Config wizard · Wizard, system fields, and backend config models for activation and setup.
Model/Config/Adminhtml - Support tools · Admin support forms, notices, and email templates for troubleshooting and onboarding.
Controller/Adminhtml/Support - Notifications UI · Lists webhook notifications and supports reprocessing and related admin actions.
Controller/Adminhtml/Notifications
Headless API
GraphQL and REST-facing module services and resolvers.
- GraphQL resolvers · Exposes payment methods, payment details, status, donations, giftcards, and POS actions.
Model/Resolver - REST services · Implements REST and guest service contracts for payment methods, state data, and giftcards.
Model/Api
Async Jobs
Cron, queue, and command-driven background processing.
- Cron jobs · Cleans analytics/state data, cancels orders, processes webhooks, and refreshes server IPs.
Cron - Notification queue · Publishes and consumes webhook notifications for decoupled processing.
Model/Queue/Notification
Persistence
Module-owned repositories, resource models, and stored operational state.
- Repositories · Stores notifications, analytics events, payment responses, and sales-related Adyen records.
Model - Resource models · Implements persistence and collections for module-owned entities and sales extensions.
Model/ResourceModel
Magento Hooks
Observers and plugins that adapt Magento flows to Adyen behavior.
- Observers · Attaches Adyen data to quotes, invoices, credit memos, orders, and analytics flows.
Observer - Plugins · Intercepts checkout, REST, GraphQL, multishipping, vault, and instant purchase flows.
Plugin - DI and events · Wires extension points through DI, events, webhooks, queue topology, and Magento config.
etc
Connections 21
- DI and events → Request builders: wires · Dependency injection and configuration connect builders to services.
- DI and events → HTTP clients: wires · Configures transport clients and adapters.
- Request builders → HTTP clients: feeds · Request builders prepare payloads for HTTP transport.
- HTTP clients → Validators: returns · Raw Adyen responses are validated before processing.
- HTTP clients → Response handlers: drives · Transport results are mapped into Magento domain updates.
- Webhook handlers → Repositories: stores · Webhook processing persists notification and payment state.
- Notification queue → Webhook handlers: delivers · Queued notifications are passed to webhook acceptors and handlers.
- Cron jobs → Notification queue: consumes · Cron processes queued webhook notifications and cleanup jobs.
- Cron jobs → Repositories: updates · Scheduled tasks clean state data and analytics records.
- GraphQL resolvers → Request builders: calls · GraphQL mutations and queries trigger Adyen request preparation.
- GraphQL resolvers → REST services: shares · GraphQL and REST services share payment and state-data domain logic.
- REST services → Repositories: persists · Service contracts save and retrieve operational state.
- Checkout UI → Checkout models: uses · UI components rely on shared checkout models and state.
- Checkout models → Request builders: prepares · Checkout state is transformed into payment request data.
- Payment blocks → Payment templates: renders · Blocks render storefront payment and info templates.
- Observers → Repositories: writes · Observers store or update module-owned sales data.
- Plugins → Checkout models: adapts · Plugins adjust checkout and payment flows at Magento entry points.
- Plugins → GraphQL resolvers: adapts · Plugins alter GraphQL purchase and cart behaviors where needed.
- Config wizard → DI and events: configures · Admin setup drives module configuration and system wiring.
- Notifications UI → Cron jobs: reprocesses · Admin actions can trigger webhook reprocessing paths.
- Support tools → Payment blocks: surfaces · Support UI uses shared blocks and templates for admin-facing output.