Skip to main content

The official Python library for the Malipo Payment Gateway

Project description

Malipo Python SDK

The official Python library for the Malipo Payment Gateway. Securely accept Mobile Money payments (Vodacom MPesa, Orange Money, Airtel Money) in the DRC.

Installation

pip install malipo

Quick Start

from malipo import Malipo

malipo = Malipo(api_key='sk_test_your_api_key')

# Create a charge
try:
    charge = malipo.charges.create({
        "amount": 10,
        "currency": "USD",
        "phone": "243810000000",
        "network": "VODACOM_MPESA",
        "description": "Order #123"
    }, idempotency_key='unique_order_id_123')

    print(f"Charge initiated: {charge['id']}")
    print(f"Status: {charge['status']}") # 'pending'
except Exception as e:
    print(f"Charge failed: {e}")

Features

🔐 Idempotency

Protect against duplicate charges by providing an idempotency_key in the options.

🔄 Environment Detection

The SDK automatically switches between sandbox and live environments based on your API key prefix (sk_test_ vs sk_live_).

📊 Balance Check

Check your available and pending balances for your current environment.

balance = malipo.balance.retrieve()
print(f"Available USD: {balance['available'][0]['amount']}")

Webhooks

from flask import Flask, request
from malipo import Malipo

app = Flask(__name__)
malipo = Malipo(api_key='...')

@app.route('/webhooks/malipo', methods=['POST'])
def handle_webhook():
    signature = request.headers.get('X-Webhook-Signature')
    payload = request.get_data(as_text=True)
    
    try:
        event = malipo.webhooks.construct_event(
            payload=payload,
            signature=signature,
            secret='whsec_your_secret'
        )
        
        if event['type'] == 'charge.succeeded':
            charge = event['data']['object']
            print(f"Payment successful: {charge['id']}")
            
        return "OK", 200
    except Exception as e:
        return str(e), 400

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

malipo-1.0.1.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

malipo-1.0.1-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file malipo-1.0.1.tar.gz.

File metadata

  • Download URL: malipo-1.0.1.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for malipo-1.0.1.tar.gz
Algorithm Hash digest
SHA256 886cac495c482aa5a3c0ab9f77275a60fadebe46da56fbd51b7edf17212fb21b
MD5 cf5ea0d41ae6405750f018da7bb3290f
BLAKE2b-256 3db285ae8a841121a3f4ff4606ccb9a949883254d6b216ca021d2567d1df4c8a

See more details on using hashes here.

File details

Details for the file malipo-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: malipo-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for malipo-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2e1237119dd219cb6b0f6d207225608d2748d1780d9f0f5d6e070b004f596d34
MD5 61d24e6e5f69d4f754ea192a1990d5d3
BLAKE2b-256 35a181f970904ec8001687c45374e9c2db83e95799150c57c8e45b0f6b2392e1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page