
Research
/Security News
Malicious npm Packages Target WhatsApp Developers with Remote Kill Switch
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.
This python module provides a simple way to integrate the Safaricom MPESA Daraja 2.0 API into your Python projects. It is designed to handle common operations like generating access tokens, formatting phone numbers, and sending STK Push requests.
This python module provides a simple way to integrate the Safaricom MPESA Daraja 2.0 API into your Python projects. It is designed to handle common operations like generating access tokens, formatting phone numbers, and sending STK Push requests.
Install the library directly from PyPI:
pip install daraja-client
Clone the repository:
git clone https://github.com/anomalous254/daraja_client.git
Navigate to the project directory:
cd daraja_client
Install dependencies:
pip install -r requirements.txt
Add the following variables to your .env
file in the root directory of your project:
DARAJA_API_CONSUMER_KEY='your_consumer_key'
DARAJA_API_CONSUMER_SECRET='your_consumer_secret'
DARAJA_API_PASS_KEY='your_pass_key'
DARAJA_API_SHORT_CODE='your_shortcode'
from daraja_client.core import DarajaClient
from decouple import config
# Configuration
auth_url = "https://sandbox.safaricom.co.ke/oauth/v1/generate?grant_type=client_credentials"
stk_push_url = 'https://sandbox.safaricom.co.ke/mpesa/stkpush/v1/processrequest'
call_back_url = 'https://your-callback-url.com' #
phone_number = '+254769507699' # person to receive the prompt
amount = '1'
# Initialize the client
cl = DarajaClient(
auth_url=auth_url,
consumer_key=config('DARAJA_API_CONSUMER_KEY'),
consumer_secret=config('DARAJA_API_CONSUMER_SECRET'),
pass_key=config('DARAJA_API_PASS_KEY'),
shortcode=config('DARAJA_API_SHORT_CODE'),
phone_number=phone_number,
call_back_url=call_back_url,
amount=amount
)
# Send STK Push
response = cl.send_stk_push(stk_push_url=stk_push_url)
print(response)
{
"message": "success",
"stkpushID": "ws_CO_blahblahblah",
"info": "You can use and store this stkpushID in your db model to be used for payment confirm during callback from Safaricom"
}
{
"message": "failed",
"error": "Wrong credentials"
}
This library was developed by Peter Nyando, a passionate software engineer dedicated to creating scalable and efficient solutions. Check out more of my work on my portfolio.
Ensure your .env
file is properly configured.
This project is licensed under the MIT License. See the LICENSE
file for details.
FAQs
This python module provides a simple way to integrate the Safaricom MPESA Daraja 2.0 API into your Python projects. It is designed to handle common operations like generating access tokens, formatting phone numbers, and sending STK Push requests.
We found that daraja-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.
Research
/Security News
Socket uncovered 11 malicious Go packages using obfuscated loaders to fetch and execute second-stage payloads via C2 domains.
Security News
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.