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:

    INSTALLED_APPS = [
        ...
        'mpesa',
    ]
  3. Add Mpesa Config variables to your project’s settings.py file

    MPESA_CONFIG = {

    … ‘CONSUMER_KEY’: ‘<Your consumer key from daraja>’, ‘CONSUMER_SECRET’: ‘<Your consumer secret from daraja>’, ‘HOST_NAME’: ‘<Your hostname e.g https://myhostname>’, ‘PASS_KEY’: ‘<Your pass key from daraja>’, ‘SAFARICOM_API’: ‘https://sandbox.safaricom.co.ke’, ‘SHORT_CODE’: ‘174379’

    }

    Check below for full setting variables description

  4. Include the polls URLconf in your project urls.py like this:

    from django.urls import path, include
    from mpesa.urls import mpesa_urls
    
    path('mpesa/', include(mpesa_urls)),
  5. Run python manage.py migrate to create the mpesa models.

  6. Start the development server and visit http://127.0.0.1:8000/admin/

  7. Visit http://127.0.0.1:8000/mpesa/ to checkout the library features.

API ENDPONTS

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/check-transaction/

    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.

Source Distribution

django-mpesa-2.0.14.tar.gz (9.0 kB view details)

Uploaded Source

Built Distributions

django_mpesa-2.0.14-py3.8.egg (11.6 kB view details)

Uploaded Source

django_mpesa-2.0.14-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

Details for the file django-mpesa-2.0.14.tar.gz.

File metadata

  • Download URL: django-mpesa-2.0.14.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/29.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.62.0 importlib-metadata/4.6.3 keyring/23.0.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.8.2

File hashes

Hashes for django-mpesa-2.0.14.tar.gz
Algorithm Hash digest
SHA256 aa9f98b113bd744cfdfeabdeef0028f883e14ee287f684d8cb0f3e00ef6fe105
MD5 9e42c025bb967d3495f3b4bebb9d4a3e
BLAKE2b-256 b05121acc07dceb7b74c5444e8a1c28c214970efe68e046d11c2af53025dc165

See more details on using hashes here.

File details

Details for the file django_mpesa-2.0.14-py3.8.egg.

File metadata

  • Download URL: django_mpesa-2.0.14-py3.8.egg
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/29.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.62.0 importlib-metadata/4.6.3 keyring/23.0.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.8.2

File hashes

Hashes for django_mpesa-2.0.14-py3.8.egg
Algorithm Hash digest
SHA256 79907f075ffd09453c9a6659791181b8a5b035497b8a77ca81839749524499d6
MD5 e328313f99d64eb62483ac8e74547f41
BLAKE2b-256 dd85a07e2af16c9f73f6893c0d961f317893ae87af8f4a9d810239ffd8d20ffb

See more details on using hashes here.

File details

Details for the file django_mpesa-2.0.14-py3-none-any.whl.

File metadata

  • Download URL: django_mpesa-2.0.14-py3-none-any.whl
  • Upload date:
  • Size: 13.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/29.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.62.0 importlib-metadata/4.6.3 keyring/23.0.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.8.2

File hashes

Hashes for django_mpesa-2.0.14-py3-none-any.whl
Algorithm Hash digest
SHA256 d1674f0ab9c37b37843f30543b2c22b6dd037fd510856c6f974c59c86aad7ba0
MD5 81de06493eeee42aa1ed870b60e3ead2
BLAKE2b-256 d68ef3973d61dec9eca020c68bdb1e19d49a4fcb426c173c096cc171838446a0

See more details on using hashes here.

Supported by

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