Imported from forter/forter-magento2 (
AGENTS.md). Install upstream withnpx skills add forter/forter-magento2. Copyright stays with the author.
forter-magento2
This file provides context for AI coding assistants working with this repository.
Repository Overview
This repository contains the Magento 2 Forter Fraud Detection Module. It integrates Forter's fraud prevention capabilities into Magento 2 e-commerce platforms.
Tech Stack: PHP, HTML, JavaScript
Build System
The project uses Magento 2's build system. Key commands include:
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy
php bin/magento cache:flush
Essential Workflows
Initial Setup
-
Install via composer (recommended):
composer require forter/magento2-module-forter -
Or install manually:
- Place contents under
{MAGENTO2-ROOT-DIR}/app/code/Forter/Forter
- Place contents under
-
Run setup commands:
php bin/magento maintenance:enable php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento setup:static-content:deploy php bin/magento maintenance:disable php bin/magento cache:flush
Making Code Changes
- Make changes in the appropriate directories (e.g.,
Block,Controller,Model) - Run compilation and deployment commands
- Test changes thoroughly
- Flush cache
Running Tests
No specific test commands are provided in the given context. Follow Magento 2 testing best practices.
Project Structure
📁 Block/ # View-related classes
📁 Adminhtml/ # Admin-specific blocks
📁 Widget/ # Custom widgets
📁 Controller/ # Request handling
📁 Callback/
📁 Index/
📁 Cron/ # Scheduled tasks
📁 Helper/ # Utility classes
📁 Logger/ # Custom logging
📁 Model/ # Business logic and data
📁 ActionsHandler/ # Handling approve/decline actions
📁 Config/
📁 Mappers/ # Payment gateway mappers
📁 Order/
📁 RequestBuilder/ # Building Forter API requests
📁 ResourceModel/ # Database interactions
📁 RmaFactory/
📁 ThirdParty/ # Integrations with 3rd party services
📁 Observer/ # Event observers
📁 Plugin/ # Magento plugins for various components
Critical Patterns
- Use of Mappers (
Model/Mappers/) for different payment gateways - Request builders (
Model/RequestBuilder/) for constructing API calls - Observers (
Observer/) for various Magento events - Custom logging implementation (
Logger/) - Cron jobs for queue processing and post-decision actions
Common Pitfalls to Avoid
- Ensure proper error handling in API interactions
- Be cautious with payment gateway integrations
- Handle cron jobs efficiently to avoid performance issues
- Properly sanitize and validate all inputs, especially in controllers
Security Guidelines (CRITICAL - Forter Standards)
Must Follow:
- ❌ NEVER hardcode secrets, API keys, or credentials
- ❌ NEVER log sensitive data (PII, tokens, passwords)
- ❌ NEVER commit .env files or secrets
- ✅ Use environment variables for all secrets
- ✅ Validate and sanitize all user inputs
- ✅ Follow the principle of least privilege
Additional Guidelines:
- Ensure all API calls use HTTPS
- Implement proper access controls for admin functionality
- Regularly update dependencies to patch security vulnerabilities
Before Committing
- Run Magento 2 code sniffer
- Ensure all new code has appropriate unit tests
- Verify that no sensitive information is being logged
- Run full Magento 2 test suite if available
- Perform manual testing on key workflows
Generated by Forter AI Platform