Skip to main content

Python wrapper for Mpesa Daraja API

Project description

pydaraja

Description

This is a python wrapper that handles payment requests through the Daraja Mpesa API.

Daraja API services offered by pydaraja are:

  • Lipa na M-PESA online API also known as M-PESA express (STK Push/NI push)
  • STK push query API -> Used to check the status of Lipa na Mpesa online payment

More services will come soon.

Installation

pip install -U pydaraja

Usage

from pydaraja import payment

payment.CONSUMER_KEY = "YOUR_CONSUMER_KEY"
payment.CONSUMER_SECRET = "YOUR_CONSUMER_SECRET"
payment.BUSINESS_SHORTCODE = "YOUR_BUSINESS_SHORTCODE"
payment.PASSKEY = "YOUR_PASSKEY"
payment.CALLBACK_URL = "YOUR_CALLBACK_URL"

payment.ACCOUNT_REFERENCE = "YOUR_ACCOUNT_REFERENCE"
payment.TRANSACTION_DESC = "YOUR_TRANSACTION_DESCRIPTION"

response = payment.trigger_stk_push(phone_number="+254700000000", amount=1)
print(response.json())

# use checkout_request_id from the above stk push as parameter for the function below
stk_query = payment.query_stk_push(your_checkout_request_id)
print(stk_query.json())

Contribute

Read the CONTRIBUTING.md file.

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

pydaraja-0.1.2.tar.gz (3.9 kB view hashes)

Uploaded Source

Built Distribution

pydaraja-0.1.2-py3-none-any.whl (4.8 kB view hashes)

Uploaded Python 3

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