Integration Architecture and Data Flow
Mollie Payment Gateway Architecture
Mollie operates a RESTful API architecture with webhook-based notification systems. The payment flow initiates when customers select Mollie payment methods during Odoo checkout. Odoo creates a pending sales order and redirects customers to Mollie’s hosted payment page. This architecture maintains PCI compliance by keeping sensitive payment data outside your Odoo environment. Mollie processes the transaction through their secure infrastructure and returns customers to your Odoo site.
The critical integration point centers on Mollie webhooks that push payment status updates to your Odoo instance. These webhooks provide real-time notifications for payment completions, failures, refunds, and chargebacks. Your Odoo system must expose a secure endpoint to receive these webhook payloads. The webhook handler processes the JSON data and updates corresponding Odoo sales orders and accounting entries.
Data Synchronization Patterns
The integration employs bidirectional data synchronization with conflict resolution mechanisms. Odoo pushes order references and amounts to Mollie during payment initiation. Mollie pushes payment status changes back to Odoo through webhooks. This pattern ensures both systems maintain consistent payment state information. The implementation must handle scenarios where manual adjustments occur in either system.
Payment data flows through multiple Odoo modules including Sales, Accounting, and Invoicing. The integration creates payment transactions in Odoo’s accounting module that match Mollie’s settlement records. This alignment enables accurate bank reconciliation when Mollie transfers funds to your business account. The system maps Mollie payment methods to Odoo payment acquirers for reporting consistency.
Webhook Handling Infrastructure
Your Odoo instance requires a dedicated webhook controller that validates Mollie signatures and processes payloads. This controller extends Odoo’s HTTP controller class and implements proper authentication checks. Each webhook request must verify the Mollie-Signature header to prevent unauthorized data manipulation. The handler processes notifications asynchronously to maintain system performance during payment peaks.
The webhook infrastructure includes retry mechanisms for failed processing attempts. Mollie expects successful HTTP 200 responses within three seconds; otherwise, it retries the webhook delivery. Your implementation must handle duplicate webhooks through idempotent processing logic. The system logs all webhook activities for audit purposes and troubleshooting.
Step-by-Step Configuration
Mollie Developer Account Setup
Begin with Mollie merchant account configuration. Log into your Mollie dashboard and navigate to the Developers section. Generate new API keys for your Odoo integration - use test keys for development and live keys for production. Mollie provides separate keys for different environments to prevent accidental live transactions during testing. Enable all necessary webhooks in your Mollie profile for payment status updates.
Configure your website URLs in Mollie’s profile settings to ensure proper redirects. Set the webhook URL to your Odoo instance’s Mollie endpoint - typically https://yourdomain.com/mollie/webhook. Mollie sends all payment notifications to this endpoint. Verify your business details and activated payment methods in the Mollie dashboard. Different payment methods like iDEAL, credit cards, and PayPal require specific activation procedures.
Odoo Payment Acquirer Configuration
Install the base payment module in Odoo if not already active. Navigate to Apps and search for “payment” to verify installation. Access the Payments menu under Invoicing settings to configure a new payment acquirer. Select Custom Payment Acquirer as the provider type since Mollie lacks a native Odoo connector. This approach provides maximum flexibility for the Mollie API integration.
Configure the payment acquirer form with Mollie-specific parameters. Set the name to “Mollie” and the provider to “custom”. Enable the environment toggle for test mode during development. Input your Mollie API keys in the appropriate fields - these credentials authenticate all API calls from Odoo to Mollie. Set the payment icon to Mollie’s branding for consistent customer experience.
Python Integration Code Implementation
Create a new Odoo module for Mollie integration with proper module structure. The module requires Python code for payment processing logic and XML files for user interface elements. Implement the payment acquirer model that extends Odoo’s base payment class. This model handles payment form rendering, transaction creation, and status management.
class PaymentAcquirerMollie(models.Model):
_inherit = 'payment.acquirer'
provider = fields.Selection(selection_add=[('mollie', 'Mollie')])
mollie_api_key = fields.Char(string='Mollie API Key', required_if_provider='mollie')
def mollie_form_generate_values(self, values):
base_url = self.get_base_url()
mollie_tx_url = base_url + '/mollie/payment'
values.update({
'mollie_tx_url': mollie_tx_url,
'api_key': self.mollie_api_key
})
return values
def mollie_get_form_action_url(self):
return '/mollie/payment'
The code above extends Odoo’s payment acquirer model to include Mollie as a provider option. It stores the Mollie API key and generates payment form values. The form action URL directs customers to your custom payment processing endpoint.
Webhook Controller Development
Build the webhook controller that processes Mollie payment notifications. This controller handles both payment creation requests and status update webhooks. Implement signature verification to ensure webhook authenticity. The controller extracts payment IDs from webhook payloads and queries Mollie’s API for complete payment details.
class MollieController(http.Controller):
@http.route('/mollie/webhook', type='json', auth='public', csrf=False)
def mollie_webhook(self, **post):
data = request.get_json_data()
payment_id = data.get('id')
if not payment_id:
return jsonify({'status': 'error'}), 400
# Verify webhook signature
mollie_signature = request.headers.get('Mollie-Signature')
if not self.verify_signature(mollie_signature, data):
return jsonify({'status': 'unauthorized'}), 401
# Process payment status update
self.process_payment_status(payment_id)
return jsonify({'status': 'processed'})
The webhook controller implements proper security checks and processes payment updates asynchronously. It returns appropriate HTTP status codes to Mollie for successful processing or errors. The controller integrates with Odoo’s transaction system to update order payment status.
Payment Status Synchronization Logic
Implement payment status synchronization between Mollie and Odoo. Create methods that query Mollie’s API for payment status when webhooks might fail. This fallback mechanism ensures data consistency between both systems. The synchronization logic handles all possible Mollie payment statuses: open, canceled, pending, authorized, expired, failed, and paid.
Develop a cron job that periodically checks for pending payments in Odoo that might have completed in Mollie. This job runs every hour and queries Mollie for payments without recent status updates. The system updates Odoo transactions based on the Mollie API responses. This redundancy captures payments where webhook delivery failed.
Testing Configuration and Go-Live
Test the complete integration flow with Mollie’s test mode before production deployment. Use Mollie’s test payment methods to simulate successful payments, failures, and refunds. Verify that Odoo orders transition through proper status states during each test scenario. Confirm that accounting entries generate correctly for successful payments.
Execute the go-live checklist: switch API keys from test to live, update webhook URLs to production domain, and verify all payment methods in live mode. Monitor the initial live transactions for any issues. Configure proper logging and alerting for payment processing errors. Train your team on the new payment reconciliation procedures.
Data Mapping and Transformation
Payment Method Mapping
Mollie supports 25+ payment methods that must map to Odoo’s payment acquirer system. Each Mollie method corresponds to a specific payment type in Odoo’s accounting framework. Create a mapping table that associates Mollie method codes with Odoo payment journal entries. For example, map Mollie’s “ideal” to Odoo’s iDEAL journal and “creditcard” to the credit card journal.
The mapping system must handle dynamic payment method updates from Mollie. Implement a synchronization function that periodically fetches available payment methods from Mollie’s API. This function creates or updates payment method records in Odoo to maintain consistency. The system disables payment methods in Odoo that become unavailable in Mollie.
Transaction Data Structure
Mollie payment objects contain extensive data that transforms into Odoo transaction records. Map Mollie’s payment ID to Odoo’s transaction reference for cross-referencing. Extract the payment amount, currency, and description for accounting accuracy. Store Mollie’s created and updated timestamps for audit trail purposes.
Transform Mollie’s payment status to Odoo’s transaction state using a state mapping function. Mollie’s “paid” status becomes “done” in Odoo, while “failed” becomes “error”. Handle special statuses like “authorized” for credit card payments that require capture operations. The mapping preserves the payment lifecycle across both systems.
Customer and Order Reference Mapping
Mollie payments include customer information that links to Odoo partner records. Extract the customer name and email from Mollie payloads to find matching Odoo contacts. Create new partner records when customers don’t exist in Odoo, using Mollie’s customer data. Maintain consistent customer identifiers across both systems for reporting.
Order references flow from Odoo to Mollie during payment initiation. Odoo generates a unique order reference that includes the sales order number. Mollie stores this reference and includes it in all webhook notifications. The integration uses this reference to locate the correct Odoo order during payment status updates.
Amount and Currency Conversion
Mollie processes payments in multiple currencies that must align with Odoo’s multi-currency system. The integration handles currency conversion between Mollie’s settlement currency and Odoo’s company currency. Implement exchange rate calculations for payments in different currencies. Store both the original payment amount and the converted company currency amount.
Handle partial refunds and payment adjustments through proper amount mapping. When Mollie sends refund webhooks, the system calculates the refunded amount and updates Odoo’s accounting entries. The mapping preserves the original payment amount while tracking subsequent adjustments. This ensures accurate financial reporting.
Webhook Data Transformation
Mollie webhook payloads contain nested JSON structures that flatten into Odoo’s relational data model. Extract the primary payment data along with embedded resources like customer details and refund records. Transform the JSON timestamps into Odoo’s datetime format for consistent storage. The transformation process normalizes Mollie’s API response into Odoo’s database schema.
Handle webhook data validation and error reporting for malformed payloads. The system logs transformation errors for troubleshooting while responding successfully to Mollie to prevent webhook retries. Implement data cleansing for special characters and encoding issues that might occur in payment descriptions.
Error Handling and Resilience
Common Mollie API Integration Errors
Mollie API responses include specific error codes that require targeted handling. “401 Unauthorized” errors indicate invalid API keys - the system should alert administrators for credential issues. “429 Too Many Requests” errors signal rate limiting - implement exponential backoff in API clients. “500 Internal Server Errors” from Mollie require retry mechanisms with jitter.
Payment creation failures often stem from incorrect parameters or validation errors. Handle “422 Unprocessable Entity” responses by parsing Mollie’s error message for specific field violations. Common issues include invalid redirect URLs, unsupported currencies, or incorrect amount formatting. The system should log these errors with sufficient context for debugging.
Webhook Processing Failures
Webhook delivery failures occur when Odoo endpoints become unavailable or slow to respond. Mollie retries failed webhooks with exponential backoff over 24 hours. Implement idempotent webhook handlers that process duplicate notifications safely. Use Mollie’s webhook idempotency keys to detect and skip already-processed notifications.
Payload processing errors stem from malformed JSON or schema changes. Wrap webhook processing in comprehensive exception handling that captures all runtime errors. The system should log the complete payload for troubleshooting while returning success responses to Mollie. This prevents endless retry loops while preserving error data.
Payment Status Synchronization Issues
Discrepancies between Mollie and Odoo payment states require reconciliation procedures. Develop a dashboard that highlights payments with inconsistent status across both systems. Implement manual resolution workflows for finance teams to investigate and correct mismatches. The system should provide one-click synchronization for selected payments.
Network timeouts during Mollie API calls necessitate robust retry logic. Configure Odoo’s request timeout settings to accommodate Mollie’s API response times. Implement circuit breaker patterns that temporarily disable Mollie integration during extended outages. The system should queue synchronization attempts for later processing during connectivity issues.
Data Validation and Integrity Checks
Payment data validation prevents corrupted records from entering Odoo’s accounting system. Verify amount consistency between Odoo orders and Mollie payments before updating transaction status. Validate currency codes against Odoo’s active currency list. Check that payment references correspond to existing Odoo sales orders.
Implement database constraints that maintain referential integrity between payment transactions and related records. Use Odoo’s constraint system to prevent orphaned payment records. Regular integrity checks identify data inconsistencies before they impact financial reporting. Automated repair scripts fix common data issues without manual intervention.
Debugging and Logging Strategies
Comprehensive logging captures all Mollie API interactions and webhook processing activities. Store request and response payloads for troubleshooting without sensitive data exposure. Implement log correlation IDs that track a payment through the entire processing pipeline. Use Odoo’s logging framework with appropriate log levels for different error types.
Create diagnostic tools that test Mollie connectivity and configuration. These tools verify API key validity, webhook URL accessibility, and payment method availability. Develop a sandbox environment that replicates production configuration for safe testing. The diagnostics provide clear action steps for resolving identified issues.
Testing and Validation
Test Environment Configuration
Establish a dedicated testing environment that mirrors your production Odoo instance. Configure Mollie test mode API keys that simulate payment processing without actual financial transactions. Use test-specific webhook URLs that point to your testing environment. Create test customer accounts and products that represent real-world usage patterns.
Develop a test data factory that generates realistic orders with varying amounts, currencies, and payment methods. This factory should create orders through Odoo’s API to simulate actual customer checkout flows. Maintain separate test journals and accounting accounts to prevent contamination of financial data.
Payment Scenario Test Coverage
Test all Mollie payment status transitions with specific test cases. Verify successful payment flows from order creation through payment completion and accounting entry generation. Test failure scenarios including expired payments, canceled transactions, and failed payments. Validate refund processing for both partial and full refunds.
Execute edge case scenarios like payment method changes during checkout, currency conversion issues, and network timeouts. Test webhook handling for duplicate notifications, out-of-order delivery, and malformed payloads. Verify system behavior during Mollie API outages and recovery procedures.
Integration Validation Checklist
Create a comprehensive validation checklist that verifies each integration component. Confirm that Mollie payment methods display correctly in Odoo’s checkout process. Validate that order references pass correctly to Mollie and appear in the Mollie dashboard. Verify that webhook notifications update Odoo order status within acceptable timeframes.
Check accounting integration by validating that successful payments create proper journal entries. Confirm that payment reconciliation matches Mollie settlement amounts with Odoo accounting records. Test reporting accuracy by comparing Mollie settlement reports with Odoo financial statements.
Performance and Load Testing
Measure system performance under realistic transaction volumes. Test webhook handling capacity by simulating peak payment periods with multiple concurrent notifications. Measure API response times for payment creation and status queries. Establish performance baselines for key metrics like payment processing time and webhook handling latency.
Execute load tests that push the integration beyond expected transaction volumes. Identify performance bottlenecks in database queries, API calls, and background jobs. Verify that the system maintains data consistency under high load conditions. Test recovery procedures after simulated system failures.
User Acceptance Testing
Involve business users in testing the complete payment workflow from customer and administrative perspectives. Have customers execute test purchases using different payment methods and report any usability issues. Train accounting staff on the new reconciliation procedures and gather feedback on the interface.
Conduct operational readiness testing with the teams that support the production environment. Verify that monitoring alerts function correctly for payment processing errors. Confirm that log files contain sufficient information for troubleshooting common issues. Validate backup and recovery procedures for payment data.
Security Considerations
API Key Management and Protection
Mollie API keys grant full access to your payment account, requiring strict protection measures. Store API keys in Odoo’s configuration parameters rather than code files. Use different keys for development, testing, and production environments. Implement key rotation policies that periodically regenerate API keys.
Restrict API key permissions in Mollie’s dashboard to the minimum required functionality. Enable IP whitelisting for API key usage if your Odoo instance has static IP addresses. Monitor API key usage patterns for suspicious activities. Implement alerting for unexpected API key usage.
Webhook Security Implementation
Webhook endpoints require robust security measures to prevent unauthorized access. Validate Mollie-Signature headers on every webhook request using your API key as the verification secret. Implement request rate limiting to prevent denial-of-service attacks. Use HTTPS with proper certificate management for all webhook endpoints.
Verify webhook payload integrity by recalculating signatures before processing. Reject webhooks with missing or invalid signatures immediately. Log security rejection events for monitoring potential attacks. Keep webhook endpoint URLs confidential to reduce attack surface.
Data Protection and Privacy
Payment data protection requires careful handling of sensitive information. Never log complete payment payloads that might contain personal data. Implement data retention policies that automatically purge old payment processing logs. Anonymize customer data in test environments.
Encrypt sensitive data at rest in Odoo’s database using Odoo’s built-in encryption capabilities. Apply database field-level encryption to payment tokens and API keys. Ensure proper access controls limit payment data visibility to authorized personnel only.
Compliance and Audit Requirements
Maintain PCI DSS compliance by keeping sensitive payment data outside Odoo. The integration must never store credit card numbers or security codes. Implement audit trails that track all payment-related activities including modifications. Regular security assessments verify compliance with data protection regulations.
Document the integration architecture and security measures for compliance audits. Maintain records of security incidents and remediation actions. Conduct periodic access reviews for personnel with payment system privileges. Implement segregation of duties between development and production access.
Performance Optimization
API Call Optimization
Mollie API rate limits necessitate efficient API usage patterns. Implement request batching for operations that require multiple payment status checks. Use webhooks as the primary update mechanism instead of polling to reduce API calls. Cache payment method lists and configuration data to minimize configuration API calls.
Optimize API call timing by scheduling non-urgent operations during off-peak hours. Use background jobs for payment synchronization tasks that don’t require immediate processing. Implement intelligent retry logic that respects Mollie’s rate limit headers. Monitor API usage metrics to identify optimization opportunities.
Database Performance Tuning
Payment processing generates substantial database activity that requires optimization. Index transaction tables on Mollie payment references and order identifiers to speed up webhook processing. Partition large transaction tables by date to improve query performance. Regular database maintenance prevents index fragmentation.
Optimize Odoo’s ORM queries by selecting only necessary fields and using proper prefetch patterns. Avoid N+1 query problems in payment processing code by batching related record lookups. Implement database connection pooling to handle concurrent webhook requests efficiently.
Caching Strategies
Implement multi-layer caching to reduce Mollie API calls and database queries. Cache payment method configurations with appropriate expiration times. Store frequently accessed payment status information in memory to avoid database hits. Use Odoo’s built-in caching mechanisms for static configuration data.
Develop cache invalidation strategies that ensure data consistency when payments update. Clear relevant caches when processing webhook notifications to prevent stale data. Implement cache warming for payment methods during system startup. Monitor cache hit ratios to optimize cache sizing and expiration policies.
Background Processing Architecture
Move non-time-critical operations to background jobs to maintain responsive user interfaces. Process webhook payloads asynchronously using Odoo’s queue job system. Schedule payment synchronization tasks as low-priority background processes. Implement job prioritization that processes time-sensitive operations first.
Monitor background job queues for congestion and scale worker processes accordingly. Implement dead letter queues for failed jobs that require manual intervention. Set appropriate timeouts and retry policies for different job types. Use job monitoring dashboards to track processing backlog and performance.