выпускать: 2026/09/20 05:00 читать: 0
Оригинальный автор:DevNook
Первоисточник:https://www.youtube.com/embed/G8mbH5rPq5I
Learn how to integrate M-Pesa payments into Django using Safaricom’s Daraja API and STK Push. In this step-by-step tutorial, we build a simple Django payment application called PayFlow and connect it to the M-Pesa Daraja sandbox. You’ll learn how to: * Set up a Django payment application * Connect Django to the Daraja API * Authenticate with Daraja using OAuth * Send an M-Pesa STK Push * Receive M-Pesa callbacks * Use `CheckoutRequestID` to track payments * Handle successful and failed payments * Store the M-Pesa receipt in the database * Use ngrok for local callback testing M-Pesa Payment Flow User enters phone number and amount - Django creates a pending payment - Daraja authenticates the request - Django sends an STK Push - Customer enters their M-Pesa PIN - M-Pesa processes the payment - Daraja sends a callback - Django updates the payment - Payment becomes successful or failed What We Build A simple Django + M-Pesa payment dashboard where you can make payments and track their status. Technologies * Python * Django * M-Pesa Daraja API * STK Push * SQLite * Requests * python-dotenv * ngrok Chapters 00:00 - Introduction & Finished Application 00:00 - M-Pesa Payment Flow 00:00 - Django Project Setup 00:00 - Payment Model & Form 00:00 - Payment Dashboard 00:00 - Safaricom Daraja Setup 00:00 - OAuth Access Token 00:00 - Phone Number Formatting 00:00 - STK Push 00:00 - M-Pesa Callback 00:00 - ngrok Setup 00:00 - Handling Successful & Failed Payments 00:00 - Storing M-Pesa Receipt 00:00 - Testing the Payment Flow 00:00 - Common Errors 00:00 - Final Walkthrough Important An STK Push being accepted does not mean the payment was successful. Daraja first accepts the STK Push request and gives us a `CheckoutRequestID`. The final payment result is sent later through the M-Pesa callback. This tutorial shows how Django uses that callback to update the payment as successful or failed. Resources Safaricom Daraja: https://developer.safaricom.co.ke/ GitHub repository: https://github.com/ceciliawambui/payflow Notes: https://getdevnook.com/topics/python-django-framework-integrating-m-pesa-pyments-in-django-apps If you're learning JS, React, Python, Django, APIs, and real-world software development, subscribe for more practical tutorials. #Django #MPesa #DarajaAPI #Python #STKPush #MPesaAPI #DjangoTutorial #PythonDjango #Safaricom #KenyaDevelopers
TechAnalysis
2026-09-21 05:36
DADS DEFI SPACE
2026-09-21 05:36
Cybersecurity News
2026-09-21 05:36
Dr Niki
2026-09-21 05:36
Marinko
2026-09-21 05:23
Tearrs
2026-09-21 05:21
by rekta
2026-09-21 05:19
Kaiden
2026-09-21 05:19
CoinBaron
2026-09-21 04:57
Выберите валюту
US Dollar
USD
Chinese Yuan
CNY
Japanese Yen
JPY
South Korean Won
KRW
New Taiwan Dollar
TWD
Canadian Dollar
CAD
Euro
EUR
Pound Sterling
GBP
Danish Krone
DKK
Hong Kong Dollar
HKD
Australian Dollar
AUD
Brazilian Real
BRL
Swiss Franc
CHF
Chilean Peso
CLP
Czech Koruna KČ
CZK
Singapore Dollar
SGD
Indian Rupee
INR
Saudi Riyal
SAR
Vietnamese Dong
VND
Thai Baht
THB
Выберите валюту
US Dollar
USD-$
Chinese Yuan
CNY-¥
Japanese Yen
JPY-¥
South Korean Won
KRW -₩
New Taiwan Dollar
TWD-NT$
Canadian Dollar
CAD-$
Euro
EUR - €
Pound Sterling
GBP-£
Danish Krone
DKK-KR
Hong Kong Dollar
HKD- $
Australian Dollar
AUD-$
Brazilian Real
BRL -R$
Swiss Franc
CHF -FR
Chilean Peso
CLP-$
Czech Koruna KČ
CZK -KČ
Singapore Dollar
SGD-S$
Indian Rupee
INR -₹
Saudi Riyal
SAR -SAR
Vietnamese Dong
VND-₫
Thai Baht
THB -฿