lake-dynamics / sylius-monetico-plugin
Sylius plugin for Monetico payment gateway integration.
Installs: 275
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:sylius-plugin
pkg:composer/lake-dynamics/sylius-monetico-plugin
Requires
- php: ^8.2
- sylius/sylius: ^2.0
Requires (Dev)
- behat/behat: ^3.16
- dmore/behat-chrome-extension: ^1.4
- dmore/chrome-mink-driver: ^2.9
- friends-of-behat/mink: ^1.11
- friends-of-behat/mink-browserkit-driver: ^1.6
- friends-of-behat/mink-debug-extension: ^2.1
- friends-of-behat/mink-extension: ^2.7
- friends-of-behat/page-object-extension: ^0.3
- friends-of-behat/suite-settings-extension: ^1.1
- friends-of-behat/symfony-extension: ^2.6
- friends-of-behat/variadic-extension: ^1.6
- nyholm/psr7: ^1.8
- phpstan/phpstan: ^1.12
- phpstan/phpstan-doctrine: ^1.3
- phpstan/phpstan-webmozart-assert: ^1.2
- phpunit/phpunit: ^10.5
- robertfausk/behat-panther-extension: ^1.1
- sylius-labs/coding-standard: ^4.4
- sylius-labs/suite-tags-extension: ~0.2
- sylius/sylius-rector: ^2.0
- sylius/test-application: ^2.0.0@alpha
- symfony/browser-kit: ^6.4 || ^7.1
- symfony/debug-bundle: ^6.4 || ^7.1
- symfony/dotenv: ^6.4 || ^7.1
- symfony/http-client: ^6.4 || ^7.1
- symfony/intl: ^6.4 || ^7.1
- symfony/runtime: ^6.4 || ^7.1
- symfony/web-profiler-bundle: ^6.4 || ^7.1
- symfony/webpack-encore-bundle: ^2.2
README
A Sylius plugin for integrating Monetico payment gateway into your e-commerce store.
Features
- 💳 Complete Monetico payment gateway integration
- 🔒 Secure payment processing with MAC signature validation
- 🎨 Beautiful payment redirect page with loading animation
- 🌍 Support for both production and sandbox environments
- ✅ Full Sylius 2.0 Payment Request system compatibility
- 🔔 Automatic payment notification handling
- 📱 Responsive design
Requirements
- PHP 8.2 or higher
- Sylius 2.0 or higher
Installation
- Install the plugin using Composer:
composer require lake-dynamics/sylius-monetico-plugin
- Enable the plugin in your
config/bundles.php:
return [ // ... LakeDynamics\SyliusMoneticoPlugin\LakeDynamicsSyliusMoneticoPlugin::class => ['all' => true], ];
- Import the plugin configuration in
config/packages/_sylius.yaml:
imports: - { resource: "@LakeDynamicsSyliusMoneticoPlugin/config/config.yaml" }
- Import the plugin routes in
config/routes.yaml:
lake_dynamics_sylius_monetico: resource: "@LakeDynamicsSyliusMoneticoPlugin/config/routes/shop.yaml"
- Clear the cache:
bin/console cache:clear
Configuration
1. Create Payment Method
- Log in to the Sylius admin panel
- Go to Configuration > Payment methods
- Click Create
- Fill in the general information:
- Code:
monetico(or your preferred code) - Name:
Monetico - Enabled: Check this box
- Code:
- Select Monetico Payment Gateway as the gateway
- Configure the Monetico settings:
- TPE (Terminal Payment Electronic): Your Monetico TPE number
- Company ID (Société): Your Monetico company identifier
- Production Key: Your Monetico encryption key
- Use Production Environment: Check for production, uncheck for sandbox/test
2. Generate Encryption Key
To encrypt sensitive payment configuration data:
bin/console sylius:payment:generate-key
3. Monetico Credentials
You'll receive the following credentials from Monetico:
- TPE: Your terminal identifier (e.g.,
1234567) - Company ID: Your company code (e.g.,
mycompany) - Production Key: A 40-character hexadecimal key for MAC signature generation
How It Works
Payment Flow
- Customer Checkout: Customer selects Monetico as payment method
- Payment Initiation: System creates a PaymentRequest with ACTION_CAPTURE
- Field Preparation: Plugin prepares payment fields and generates MAC signature
- Redirect: Customer is redirected to Monetico payment page via auto-submit form
- Payment Processing: Customer completes payment on Monetico's secure portal
- Notification: Monetico sends payment result to your notification URL
- Validation: Plugin validates MAC signature and updates payment status
- Completion: Order is marked as paid or failed based on result
Security
- MAC Signature: All data exchanged with Monetico is signed using HMAC SHA1
- Encryption: Payment credentials are encrypted in database
- Validation: All incoming notifications are validated before processing
- HTTPS: Production environment requires HTTPS
Technical Details
Payment Fields Sent to Monetico:
- TPE: Terminal identifier
- societe: Company identifier
- montant: Amount in EUR format (e.g., "10.50EUR")
- reference: Unique payment reference
- date: Payment date in GMT
- MAC: HMAC SHA1 signature
- texte-libre: Base64-encoded payment metadata (order ID, payment ID, payment request hash)
- contexte_commande: Base64-encoded customer and billing data
- url_retour_ok: Success return URL
- url_retour_err: Error return URL
Valid Payment Status:
paiement: Successful payment (production)payetest: Successful payment (test/sandbox)
Development
Running Tests
# PHPUnit vendor/bin/phpunit # Behat (non-JS) vendor/bin/behat --strict --tags="~@javascript&&~@mink:chromedriver" # PHPStan vendor/bin/phpstan analyse -c phpstan.neon -l max src/ # Coding Standards vendor/bin/ecs check
Docker Development
# Initialize environment make init # Initialize database make database-init # Load fixtures make load-fixtures # Run tests make phpunit make behat make phpstan make ecs
Troubleshooting
Payment Fails with "Invalid MAC signature"
Problem: Notification validation fails
Solution:
- Verify your Production Key is correct (40 hex characters)
- Ensure your server time is synchronized (GMT)
- Check Monetico dashboard for the correct key
- Verify notification URL is accessible from external networks
Payment Page Doesn't Redirect
Problem: Auto-submit form doesn't work
Solution:
- Check browser console for JavaScript errors
- Verify payment fields are properly generated
- Ensure Monetico URL is accessible
- Check if Content Security Policy allows form submission
Notification URL Not Receiving Callbacks
Problem: Monetico can't reach your notification endpoint
Solution:
- Ensure your server is accessible from external networks
- Verify URL in admin matches:
https://yourdomain.com/payment/monetico/notify - Check firewall rules allow Monetico IPs
- Configure this URL in your Monetico backend for server-to-server notifications
Production vs Sandbox
Sandbox Testing:
- Use sandbox credentials from Monetico
- Uncheck "Use Production Environment" in payment method config
- Payment URL:
https://p.monetico-services.com/test/paiement.cgi
Production:
- Use production credentials from Monetico
- Check "Use Production Environment"
- Payment URL:
https://p.monetico-services.com/paiement.cgi - Requires HTTPS
Support
- Documentation: Monetico Documentation
- Sylius Docs: docs.sylius.com
- Issues: GitHub Issues
License
This plugin is licensed under the MIT License - see the LICENSE file for details.
Credits
Developed by LakeDynamics
Monetico is a trademark of Groupe BPCE.