Skip to main content

mpesa-tz

A lightweight, developer-friendly Python package for accepting and sending M-Pesa Tanzania payments through the Vodacom M-Pesa OpenAPI.

Works with Django, Flask, FastAPI or plain Python.

Features

  • STK push: ask a customer to pay; they confirm with their M-Pesa PIN on their phone
  • Pay customers (B2C) and pay other businesses (B2B)
  • Check a transaction's status and reverse (refund) a payment
  • Handles M-Pesa authentication and session keys for you
  • Checks phone numbers, amounts and references before anything is sent
  • Clear error messages for every M-Pesa response code
  • Sandbox (testing) and production modes
  • Ready-made Django app: payment records, admin page and callback endpoint
  • Command-line tool for quick checks

Installation

pip install mpesa-tz

Requires Python 3.10+.

Getting started

QUICKSTART.md walks you through everything step by step: getting sandbox credentials, configuring the package, sending your first payment request, adding it to a Django, Flask or FastAPI app, and going live. It also has the full technical reference: return values, errors, options, callbacks and CLI commands.

Documentation

Guide What's in it
QUICKSTART.md Setup, first payment, framework integration, reference
TESTING.md Running the tests and validating the package
CHANGELOG.md What changed in each version
examples/ Ready-to-run Python, Flask and FastAPI examples

License

MIT

Metadata

Release files for mpesa-tz 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mpesa-tz 0.2.0
File Size Uploaded Provenance Actions
mpesa_tz-0.2.0.tar.gz 22.8 kB With provenance Details for mpesa_tz-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mpesa-tz 0.2.0
File Interpreter ABI Platform Actions
mpesa_tz-0.2.0-py3-none-any.whl Python 3 none any Details for mpesa_tz-0.2.0-py3-none-any.whl

Total release size: 44.1 kB

Release files / mpesa_tz-0.2.0.tar.gz

Download URL mpesa_tz-0.2.0.tar.gz
Size 22.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7b4140ff51b9b42397079c37667a2acfbafb33a37105659179e6f144c8d91bf8
BLAKE2b-256 checksum
How to use checksums
2d3e3e06daf2b86ac51a7a87f03391ea145dc82457c3d01a33cc562a7572585e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

Release files / mpesa_tz-0.2.0-py3-none-any.whl

Download URL mpesa_tz-0.2.0-py3-none-any.whl
Size 21.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8ff988d175e013c0205d39c773437ff629824cb7c9e1b25881a5b5cb413b4d4b
BLAKE2b-256 checksum
How to use checksums
d8c4bec3036c2bd78e1eef7582d223ef206a51b7da30732f8f3873b2bc1afce1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

Security for mpesa-tz 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mpesa_tz-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page