Skip to content

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:

  1. Completed the Quickstart guide
  2. A Safaricom Developer account with an app created
  3. Your consumer key, consumer secret, passkey, and shortcode ready
  4. 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.