mpesa
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
Install the package with pip like this:
pip install django-mpesa
Add “mpesa” to your INSTALLED_APPS setting like this:
INSTALLED_APPS = [ ... 'mpesa', ]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
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)),Run python manage.py migrate to create the mpesa models.
Start the development server and visit http://127.0.0.1:8000/admin/
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
- mpesa/submit/
This endpoint allows you to submit a post request to initiate an STK push
- mpesa/confirm/
This endpoint is used as the callback endpoint on which MPESA will return a transaction response/status
- 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
Metadata
Release files for django-mpesa 2.0.14
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-mpesa-2.0.14.tar.gz | 9.0 kB | Without provenance | Details for django-mpesa-2.0.14.tar.gz |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_mpesa-2.0.14-py3.8.egg | Legacy Egg format | - | - | Details for django_mpesa-2.0.14-py3.8.egg |
| django_mpesa-2.0.14-py3-none-any.whl | Python 3 | none | any | Details for django_mpesa-2.0.14-py3-none-any.whl |
Total release size: 33.7 kB
Release files / django-mpesa-2.0.14.tar.gz
| Download URL | django-mpesa-2.0.14.tar.gz |
|---|---|
| Size | 9.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aa9f98b113bd744cfdfeabdeef0028f883e14ee287f684d8cb0f3e00ef6fe105
|
|
BLAKE2b-256 checksum How to use checksums |
b05121acc07dceb7b74c5444e8a1c28c214970efe68e046d11c2af53025dc165
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / django_mpesa-2.0.14-py3.8.egg
| Download URL | django_mpesa-2.0.14-py3.8.egg |
|---|---|
| Size | 11.6 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
79907f075ffd09453c9a6659791181b8a5b035497b8a77ca81839749524499d6
|
|
BLAKE2b-256 checksum How to use checksums |
dd85a07e2af16c9f73f6893c0d961f317893ae87af8f4a9d810239ffd8d20ffb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / django_mpesa-2.0.14-py3-none-any.whl
| Download URL | django_mpesa-2.0.14-py3-none-any.whl |
|---|---|
| Size | 13.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d1674f0ab9c37b37843f30543b2c22b6dd037fd510856c6f974c59c86aad7ba0
|
|
BLAKE2b-256 checksum How to use checksums |
d68ef3973d61dec9eca020c68bdb1e19d49a4fcb426c173c096cc171838446a0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Security for django-mpesa 2.0.14
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.