Skip to main content

A python library that interfaces safaricoms mpesa apis

Project description

Django-Mpesa is a generic python library that interfaces the safaricom MPESA APIs to enable easy payments to your python application.

Detailed documentation is in the “docs” directory.

View the module from the official pypi site

Quick start

  1. Install the package with pip like this:

    pip install django-mpesa
  2. Add “mpesa” to your INSTALLED_APPS setting like this:

  3. Include the polls URLconf in your project like this:

    from django.urls import path, include
    from mpesa.urls import mpesa_urls
    path('mpesa/', include(mpesa_urls)),
  4. Run python makemigrations and python migrate to create the mpesa models.

  5. Start the development server and visit

  6. Visit to checkout the library features.


This module exposes some API endpoints that enable you work with MPESA API

  1. mpesa/submit/
    This endpoint allows you to submit a post request to initiate an STK push
  2. mpesa/confirm/
    This endpoint is used as the callback endpoint on which MPESA will return a transaction response/status
  3. mpesa/checktransaction/
    This endpoint allows you to manually check for the status of an mpesa transaction

Check out the test module for more elaborate examples

Project details

Download files

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

Files for django-mpesa, version 1.3.4
Filename, size File type Python version Upload date Hashes
Filename, size django_mpesa-1.3.4-py3-none-any.whl (12.8 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size django-mpesa-1.3.4.tar.gz (8.4 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page