Availability |
Odoo Online
Odoo.sh
On Premise
|
Odoo Apps Dependencies |
•
Contacts (contacts)
• Invoicing (account) • Discuss (mail) |
Lines of code | 213 |
Technical Name |
payment_c2b_common_ke |
License | LGPL-3 |
Website | https://odoo.co.ke |
Versions | 16.0 |
Availability |
Odoo Online
Odoo.sh
On Premise
|
Odoo Apps Dependencies |
•
Contacts (contacts)
• Invoicing (account) • Discuss (mail) |
Lines of code | 213 |
Technical Name |
payment_c2b_common_ke |
License | LGPL-3 |
Website | https://odoo.co.ke |
Versions | 16.0 |
Utilities • Foundation
KE C2B Common
Streamline Kenyan mobile payment integrations with standardized MSISDN normalization and SHA-256 hashing utilities

☁️ Compatibility
📸 Screenshots
Visual guide to KE C2B Common functionality
Partner Phone Hash Fields
Partner form showing Kenya C2B Data section with ke_phone_hashes and legacy mpesa_phone_hashes fields.

✨ Key Features
Comprehensive utilities for Kenyan mobile payment integrations
📞 MSISDN Normalization
- Automatic Phone Number Standardization: Converts various Kenyan phone number formats to the standard international format (254XXXXXXXXX)
- Multiple Format Support: Handles local formats (07XXXXXXXX, 7XXXXXXXX) and international format (254XXXXXXXXX)
- Validation: Ensures only valid Kenyan mobile numbers are processed
🔐 Phone Number Hashing
- SHA-256 Encryption: Generates secure hashes of normalized phone numbers for privacy and security
- Duplicate Prevention: Prevents creation of duplicate contacts with the same phone number
- Legacy Compatibility: Maintains backward compatibility with existing M-Pesa phone hash fields
👥 Enhanced Partner Management
- Alternate Contact Field: Additional contact field for partners
- Automatic Hash Updates: Phone hashes are automatically updated when contact information changes
- Duplicate Detection: Real-time validation prevents duplicate phone numbers across contacts
- Migration Support: Seamless migration from legacy M-Pesa hash fields to neutral phone hash fields
🛒 Point of Sale Integration
- POS Phone Validation: JavaScript validation for phone numbers in Point of Sale interface
- Real-time Feedback: Immediate validation feedback during data entry
Latest Release 18.0.1.0.0
2024-12-27- Initial release with MSISDN normalization and SHA-256 hashing.
- Partner fields with duplicate prevention and POS validation.
📅 Changelog
Date | Version | Notes |
---|---|---|
2025-08-22 | 16.0.1.0.0 | 🚀 Initial release – full automation |
📜 Licensing
License Type
LGPL-3Redistribution
No redistributionFull Policy
View PolicySupport & Contact
support@odoo.co.ke
https://odoo.co.ke/helpdesk
+254739444447
1 business day SLA
KE C2B Common (M-Pesa/Kopo Kopo)

Version: 16.0.1.0.0
Author: Metro ICT Limited
License: LGPL-3
Website: https://odoo.co.ke
Support: support@odoo.co.ke
Overview
The KE C2B Common module provides shared utilities for Kenyan mobile money integrations, specifically designed for M-Pesa and Kopo Kopo Customer-to-Business (C2B) payment processing. This module serves as a foundation for other Kenyan payment modules by providing standardized MSISDN (Mobile Station International Subscriber Directory Number) normalization, hashing, and partner management utilities.
Key Features
MSISDN Normalization
- Automatic Phone Number Standardization: Converts various Kenyan phone number formats to the standard international format (254XXXXXXXXX)
- Multiple Format Support: Handles local formats (07XXXXXXXX, 7XXXXXXXX) and international format (254XXXXXXXXX)
- Validation: Ensures only valid Kenyan mobile numbers are processed
Phone Number Hashing
- SHA-256 Encryption: Generates secure hashes of normalized phone numbers for privacy and security
- Duplicate Prevention: Prevents creation of duplicate contacts with the same phone number
- Legacy Compatibility: Maintains backward compatibility with existing M-Pesa phone hash fields
Enhanced Partner Management
- Alternate Contact Field: Additional contact field for partners
- Automatic Hash Updates: Phone hashes are automatically updated when contact information changes
- Duplicate Detection: Real-time validation prevents duplicate phone numbers across contacts
- Migration Support: Seamless migration from legacy M-Pesa hash fields to neutral phone hash fields
Point of Sale Integration
- POS Phone Validation: JavaScript validation for phone numbers in Point of Sale interface
- Real-time Feedback: Immediate validation feedback during data entry
How It Works
Phone Number Processing Flow
- Input Processing: When a phone number is entered in any of the contact fields (phone, mobile, alternate_contact)
- Normalization: The number is processed through the normalization function:
- Removes all non-digit characters
- Converts local format (07XXXXXXXX) to international (254XXXXXXXXX)
- Converts short format (7XXXXXXXX) to international (254XXXXXXXXX)
- Validates the final format is exactly 12 digits starting with 254
- Hashing: Normalized numbers are hashed using SHA-256 for security
- Storage: Hashes are stored in the ke_phone_hashes field as comma-separated values
- Validation: System checks for duplicates before saving
Data Flow Example
Input: "0712345678" ↓ Normalization Output: "254712345678" ↓ Hashing (SHA-256) Output: "a1b2c3d4e5f6..." (64-character hash) ↓ Storage Field: ke_phone_hashes = "a1b2c3d4e5f6..."
Duplicate Prevention
The module implements robust duplicate prevention:
- Create Operations: Checks for existing hashes before creating new partners
- Update Operations: Validates against existing partners (excluding current record)
- Real-time Validation: Immediate feedback during data entry
- Error Messages: Clear error messages indicating which contact has the duplicate number
User Guide
Installation
- Copy Module: Place the payment_c2b_common_ke folder in your Odoo custom addons directory
- Update Apps List: Go to Apps → Update Apps List
- Install Module: Search for "KE C2B Common" and click Install
Configuration
No additional configuration is required. The module works automatically once installed.
Usage
Adding Contact Information
- Navigate to Contacts: Go to Contacts → Contacts
- Create/Edit Contact: Create a new contact or edit an existing one
- Enter Phone Numbers: Add phone numbers in any of these fields:
- Phone: Primary phone number
- Mobile: Mobile phone number
- Alternate Contact: Additional contact number
- Automatic Processing: The system automatically:
- Normalizes the phone numbers
- Generates secure hashes
- Validates for duplicates
- Updates the hash fields
Supported Phone Number Formats
The module accepts various Kenyan phone number formats:
- Local Format: 0712345678, 0722345678, 0732345678, etc.
- Short Format: 712345678, 722345678, 732345678, etc.
- International Format: 254712345678, 254722345678, etc.
- With Separators: 0712-345-678, +254 712 345 678, etc.
All formats are automatically converted to the standard international format (254XXXXXXXXX).
Point of Sale Usage
When using the Point of Sale interface:
- Customer Selection: Phone number validation occurs in real-time
- Format Assistance: The system provides immediate feedback on phone number format
- Auto-correction: Invalid formats are highlighted with suggestions
Duplicate Handling
If you attempt to enter a phone number that already exists:
- Error Message: A clear error message will appear
- Existing Contact: The system will show which contact already has this number
- Resolution: Either use the existing contact or verify the phone number is correct
Technical Details
Dependencies
- base: Core Odoo functionality
- contacts: Contact management
- account: Accounting module
Database Fields
res.partner Model Extensions:
- alternate_contact (Char): Additional contact field
- ke_phone_hashes (Char): Comma-separated SHA-256 hashes of normalized phone numbers
- mpesa_phone_hashes (Char): Legacy alias field for backward compatibility
SQL Constraints:
- phone_or_mobile_required: Ensures at least one phone number is provided
API Reference
Utility Functions:
# Normalize a Kenyan phone number from odoo.addons.payment_c2b_common_ke.utils import normalize_kenyan_number normalized = normalize_kenyan_number("0712345678") # Returns "254712345678" # Hash a normalized number from odoo.addons.payment_c2b_common_ke.utils import hash_kenyan_number hashed = hash_kenyan_number("254712345678") # Returns SHA-256 hash
Partner Methods:
# Update phone hashes for a partner partner._update_phone_hashes(msisdn="254712345678", alternate="254722345678")
Migration and Compatibility
Legacy Support
The module maintains full backward compatibility with existing M-Pesa integrations:
- Field Mapping: mpesa_phone_hashes field automatically syncs with ke_phone_hashes
- Data Migration: Post-installation hook migrates existing M-Pesa hash data
- API Compatibility: Existing code using M-Pesa fields continues to work
Migration Process
During installation, the module automatically:
- Identifies Legacy Data: Finds partners with mpesa_phone_hashes but no ke_phone_hashes
- Copies Data: Transfers hash data to the new neutral field
- Maintains Sync: Keeps both fields synchronized for compatibility
Troubleshooting
Common Issues
- Phone Number Not Accepted
- Ensure the number is a valid Kenyan mobile number
- Check that the number has 9-10 digits (excluding country code)
- Verify the number starts with 7 (after removing country code)
- Duplicate Error Messages
- Check if the phone number already exists in another contact
- Use the search function to find the existing contact
- Consider if this is the same person with multiple records
- Hash Field Not Updating
- Ensure you're saving the record after making changes
- Check that the phone number format is valid
- Verify the module is properly installed and activated
- Point of Sale Validation Issues
- Clear browser cache and reload the POS interface
- Ensure the module assets are properly loaded
- Check browser console for JavaScript errors
Performance Considerations
- Hash Generation: SHA-256 hashing is computationally efficient
- Duplicate Checking: Database queries are optimized with proper indexing
- Batch Operations: Large data imports should be done in batches
Support and Development
Technical Support: support@odoo.co.ke
Website: https://odoo.co.ke
Developer: Metro ICT Limited
For technical issues, feature requests, or custom development needs, please contact our support team.
Contributing
This module is part of the Kenyan payment ecosystem. When contributing:
- Follow Standards: Adhere to Odoo development guidelines
- Test Thoroughly: Ensure all phone number formats work correctly
- Maintain Compatibility: Preserve backward compatibility with existing integrations
- Document Changes: Update this README for any new features
License
This module is licensed under LGPL-3. See the LICENSE file for full details.
Changelog
- Version 16.0.1.0.0
- Initial release for Odoo 16.0
- MSISDN normalization and hashing utilities
- Enhanced partner management with duplicate prevention
- Point of Sale integration
- Legacy M-Pesa compatibility
- Migration support for existing data
Please log in to comment on this module