Giter Site home page Giter Site logo

ekirapapaul / django-mpesa Goto Github PK

View Code? Open in Web Editor NEW
36.0 4.0 28.0 65 KB

This repo is meant to simplify Safaricom's mpesa API integration in simple steps.

License: BSD 2-Clause "Simplified" License

Python 100.00%
safaricom-mpesa-apis safaricom-mpesa daraja-mpesa

django-mpesa's Introduction

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

  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

django-mpesa's People

Contributors

dependabot[bot] avatar ekirapapaul avatar muneneevans avatar paul-weqe avatar ronnie-leon76 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

django-mpesa's Issues

CamelCase?

@muneneevans voting we should move all parameters, args etc to camel case. Example in the submit API move from phone_number to phoneNumber.

Get rid of absolute referencing

Absolute referencing may bring issues when integrating with other tools such as celery.

Proposed solution

Bump Django version and do away with absolute referencing.

Error

Hello, Template doesn't exist for mpesa urls? Why?
How do I use the Mpesa Urls in my e-commerce website ?

Data validation

@Ekirapapaul i noticed that if the input Json are wrong, the API throws an error instead of retuning a valid message. We might need to look at the serializers to handle input validation

Documentation

kindly explain to me how to use the wallet module in django administrator

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.