Mpesa B2C, C2B, STKPush Django framework based on the new Api's
developer.safaricom.co.ke
## Status
As of now the following services are done
* B2C
* C2B
* STK PUSH
The pending services are
* Reversal
* Transaction Status
* Account Balance
* B2B
If you have a free pair of hands let me know.
## Installation
`pip install mpesa-api` or
`pip install -e git+
github.com`
## Requirements
- Python 3.8+
- Django 2.1.7+
- Celery 4.1.0+
- djangorestframework 3.7.3+
- requests 2.18.4+
- python-decouple 3.3+
## Setup
Add the following in the `urls.py`
```python
urlpatterns = [
...
path('mpesa/', include('mpesa_api.core.urls', 'mpesa')),
...
]
```
Add the following to installed apps
```python
INSTALLED_APPS =
...
'mpesa_api.core',
'mpesa_api.util',
...
```
Copy the `.env-example` to `.env`. Note the `DB` and `DJANGO` configs are needed when using docker.
Add the following in your settings file get the values from [
developer.safaricom.co.ke
```python
...
# Safaricom Configs
# B2C (Bulk Payment) Configs
# see
developer.safaricom.co.ke
#
developer.safaricom.co.ke
#Consumer Key
MPESA_B2C_ACCESS_KEY = config('MPESA_B2C_ACCESS_KEY')
#Consumer Secret
MPESA_B2C_CONSUMER_SECRET = config('MPESA_B2C_CONSUMER_SECRET')
# This is the encryption of the scurity Credentials I used the Developer site to encrypt it.
B2C_SECURITY_TOKEN = config('B2C_SECURITY_TOKEN')
#InitiatorName
B2C_INITIATOR_NAME = config('B2C_INITIATOR_NAME')
# CommandID
B2C_COMMAND_ID = config('B2C_COMMAND_ID')
#PartyA
B2C_SHORTCODE = config('B2C_SHORTCODE')
# this is the url where Mpesa will post in case of a time out. Replace
mpesa.ngrok.io with your url ow here this app is running
B2C_QUEUE_TIMEOUT_URL = config('B2C_QUEUE_TIMEOUT_URL')
# this is the url where Mpesa will post the result. Replace
mpesa.ngrok.io with your url ow here this app is running
B2C_RESULT_URL = config('B2C_RESULT_URL')
# this is the url where we post the B2C request to Mpesa. Replace this with th …