Skip to Content
Menu

KE C2B Common (M-Pesa/Kopo Kopo)

by
Odoo
v 16.0 Third Party 4
Download for v 16.0 Deploy on Odoo.sh
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
LicenseLGPL-3
Websitehttps://odoo.co.ke
Versions 16.0
You bought this module and need support? Click here!
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
LicenseLGPL-3
Websitehttps://odoo.co.ke
Versions 16.0
Supports:
Community
Enterprise
Availability:
On Premise
Odoo.sh
Odoo Online

Utilities • Foundation

KE C2B Common

Streamline Kenyan mobile payment integrations with standardized MSISDN normalization and SHA-256 hashing utilities

Hero
☁️ Compatibility
Community
Enterprise
Odoo.sh
Not supported on Odoo Online

📸 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.

Partner form KE hashes

✨ 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

No. Python backend not allowed.

Latest Release 18.0.1.0.0

2024-12-27
Add
  • 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-3
Redistribution
No redistribution
Full Policy
View Policy
Important: This module is licensed under LGPL-3 with no redistribution rights. Please review our full license policy for complete terms and conditions.

Support & Contact

Website
https://odoo.co.ke/helpdesk
Phone
+254739444447
Response Time
1 business day SLA
🎁 90-day complimentary support included with your purchase

KE C2B Common (M-Pesa/Kopo Kopo)

KE C2B Common Banner

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

  1. Input Processing: When a phone number is entered in any of the contact fields (phone, mobile, alternate_contact)
  2. 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
  3. Hashing: Normalized numbers are hashed using SHA-256 for security
  4. Storage: Hashes are stored in the ke_phone_hashes field as comma-separated values
  5. 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

  1. Copy Module: Place the payment_c2b_common_ke folder in your Odoo custom addons directory
  2. Update Apps List: Go to Apps → Update Apps List
  3. 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

  1. Navigate to Contacts: Go to Contacts → Contacts
  2. Create/Edit Contact: Create a new contact or edit an existing one
  3. Enter Phone Numbers: Add phone numbers in any of these fields:
    • Phone: Primary phone number
    • Mobile: Mobile phone number
    • Alternate Contact: Additional contact number
  4. 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:

  1. Customer Selection: Phone number validation occurs in real-time
  2. Format Assistance: The system provides immediate feedback on phone number format
  3. Auto-correction: Invalid formats are highlighted with suggestions

Duplicate Handling

If you attempt to enter a phone number that already exists:

  1. Error Message: A clear error message will appear
  2. Existing Contact: The system will show which contact already has this number
  3. 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:

  1. Identifies Legacy Data: Finds partners with mpesa_phone_hashes but no ke_phone_hashes
  2. Copies Data: Transfers hash data to the new neutral field
  3. 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:

  1. Follow Standards: Adhere to Odoo development guidelines
  2. Test Thoroughly: Ensure all phone number formats work correctly
  3. Maintain Compatibility: Preserve backward compatibility with existing integrations
  4. 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

  • The author can leave a single reply to each comment.
  • This section is meant to ask simple questions or leave a rating. Every report of a problem experienced while using the module should be addressed to the author directly (refer to the following point).
  • If you want to start a discussion with the author, please use the developer contact information. They can usually be found in the description.
Please choose a rating from 1 to 5 for this module.