Skip to main content

Django reusable package for African mobile money payments

Project description

django-mobile-money

Documentation

PyPI version Tests Coverage Python License: MIT Downloads

Package Django reusable pour les paiements Mobile Money africains. Version stable 1.0.0 Integrez Wave, Orange Money, MTN MoMo et Moov Money en 3 lignes de code.

Backends supportes

Provider Pays Statut
Wave CI, SN Stable
Orange Money CI, SN, CM, BF, ML, GN Stable
MTN MoMo CI, GH, CM, BJ, SN, UG Stable
Moov Money CI, BJ, TG, BF, ML, NE Stable

Installation

pip install django-mobile-money

Quickstart

1. INSTALLED_APPS

INSTALLED_APPS = [
    "django_mobile_money",
]

2. settings.py

MOBILE_MONEY = {
    "DEFAULT_BACKEND": "wave",
    "WAVE": {
        "API_KEY": env("WAVE_API_KEY"),
        "SANDBOX": True,
    },
    "ORANGE_MONEY": {
        "CLIENT_ID":     env("ORANGE_CLIENT_ID"),
        "CLIENT_SECRET": env("ORANGE_CLIENT_SECRET"),
    },
    "MTN_MOMO": {
        "SUBSCRIPTION_KEY": env("MTN_SUBSCRIPTION_KEY"),
        "ENVIRONMENT":      "sandbox",
    },
    "MOOV_MONEY": {
        "USERNAME":   env("MOOV_USERNAME"),
        "PASSWORD":   env("MOOV_PASSWORD"),
        "PARTNER_ID": env("MOOV_PARTNER_ID"),
    },
}

3. urls.py

urlpatterns = [
    path("mobile-money/", include("django_mobile_money.urls")),
]

4. Lancer un paiement

from django_mobile_money import pay

result = pay(
    phone="+22507XXXXXXXX",
    amount=5000,
    backend="wave",
)

if result["status"] == "success":
    print("Paiement confirme :", result["transaction_id"])
elif result["status"] == "pending":
    print("En attente de confirmation")
else:
    print("Echec :", result["message"])

Reponse standardisee

{
    "status":             "pending" | "success" | "failed",
    "transaction_id":     str,
    "provider_reference": str,
    "message":            str,
    "raw_response":       dict,
}

Modeles Django

  • MobileTransaction - historique complet des paiements
  • WebhookLog - logs des webhooks entrants

Signals

from django.dispatch import receiver
from django_mobile_money.signals import payment_success

@receiver(payment_success)
def on_payment_success(sender, transaction, backend_id, **kwargs):
    print(f"Paiement reussi : {transaction.transaction_id}")

Template tags

{% load mobile_money_tags %}
{% payment_button phone="+22507XXXXXXXX" amount=5000 backend="wave" %}
{% transaction_status_badge transaction.status %}

Tests

uv run pytest -v
uv run coverage run -m pytest && uv run coverage report
# 34 tests - 92% coverage

Contribution

Voir CONTRIBUTING.md — les contributions sont les bienvenues !

Auteur

OURA KONAN ROMEO - Django Developer & IT Instructor Abidjan, Cote d Ivoire https://github.com/oura02

Licence

MIT 2026 OURA KONAN ROMEO

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_mobile_money-1.0.0.tar.gz (22.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_mobile_money-1.0.0-py3-none-any.whl (34.4 kB view details)

Uploaded Python 3

File details

Details for the file django_mobile_money-1.0.0.tar.gz.

File metadata

  • Download URL: django_mobile_money-1.0.0.tar.gz
  • Upload date:
  • Size: 22.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for django_mobile_money-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e433dee925143c42f63d517ee6b74ada9bdb985239a07b8e4491b5737d2de25d
MD5 be63c50e78deae3985ea3a43f8d477b7
BLAKE2b-256 97bd6dfe036617377c2f5fc9e816a581a88d2ff266b9e18d92ac768722efd600

See more details on using hashes here.

File details

Details for the file django_mobile_money-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_mobile_money-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e67360b5310d8c7266b7c80f7fb772f9270e62bbe80b9402b034d7847a31d28a
MD5 ac37022fe27fd96e006e0a5fc1195db0
BLAKE2b-256 436cfcf7701dc1be25b1f441204836f866e7b40f70e9efac8d200024f7279acf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page