Mpesa library that can be used to make api calls to mpesa daraja API
Project description
M-pesa SDK
The M-Pesa SDK is a Python library that provides an easy-to-use interface for integrating M-Pesa APIs into your Python applications. It simplifies the process of initiating transactions, querying transaction status, and performing other M-Pesa operations. MPESA API.
Features
- Initiate B2B (Business to Business) transactions
- Initiate B2C (Business to Customer) transactions
- Register validation and confirmation URLs for C2B (Customer to Business) transactions
- Simulate C2B transactions
- Check transaction status
- Inquire account balance
- Perform transaction reversal
- Initiate Lipa Na M-Pesa Online payments using STK Push
Installation
You can install the M-Pesa SDK via pip:
pip install py_mpesa_daraja_api
Usage
from py_mpesa_daraja_api.mpesa import Mpesa
# Initialize Mpesa instance
mpesa = Mpesa(consumer_key='YOUR_CONSUMER_KEY', consumer_secret='YOUR_CONSUMER_SECRET', env='sandbox')
# Example: Initiate B2C Payment Request
data = {
'InitiatorName': 'test',
'SecurityCredential': 'security_credential',
'CommandID': 'SalaryPayment',
'Amount': 1000,
'PartyA': 'shortcode',
'PartyB': 'customer_phone',
'Remarks': 'Salary payment',
'QueueTimeOutURL': 'timeout_url',
'ResultURL': 'result_url',
'Occasion': 'Salary Payment'
}
response, status_code = mpesa.b2c_payment_request(data)
print(response, status_code)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py_mpesa_daraja_api-0.0.1.tar.gz.
File metadata
- Download URL: py_mpesa_daraja_api-0.0.1.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
951e687c3509114bc4e5e23b7f669d5c867d9cbee226f4b0017c97e004f222ba
|
|
| MD5 |
88d6ffcf19a57b47f76d0ef7e24185c1
|
|
| BLAKE2b-256 |
e3bc1606e12cc233c8f8313b54f902938e860f1b66ffd74ba106d1304c7c0aee
|
File details
Details for the file py_mpesa_daraja_api-0.0.1-py3-none-any.whl.
File metadata
- Download URL: py_mpesa_daraja_api-0.0.1-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20e1ec957ac66bc3a3eeaf0437a144011c5f8595e676c5d2e5878f75d8f09a68
|
|
| MD5 |
286fa623ef9ae44048eacc05cd1a5570
|
|
| BLAKE2b-256 |
79d5f3c8f98e03b7ea4a0a15d1afec0039e4ae7d937b12d2d47f59b0107176bd
|