Tutorial¶
Welcome to the safcom tutorial. You'll learn how to use every feature of the M-Pesa API through practical, copy-pasteable examples.
Choose a topic to get started:
- STK Push — Initiate Lipa Na M-Pesa Online payments and handle callbacks. Read →
- Payment Status — Query whether a payment went through. Read →
- Send Money (B2C) — Send money from your business to a customer. Read →
- Account Balance — Check your M-Pesa account balance programmatically. Read →
- Going Live — Move from sandbox to production safely. Read →
Prerequisites¶
Before starting the tutorial, you should have:
- Completed the Quickstart guide
- A Safaricom Developer account with an app created
- Your consumer key, consumer secret, passkey, and shortcode ready
- Python 3.10+ installed on your machine
Conventions¶
Throughout this tutorial:
- Code blocks are copy-paste ready — just replace placeholder values with your own
- Callout boxes highlight common pitfalls
- Tips show best practices
Ready? Start with STK Push.