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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file malipo-1.0.0.tar.gz.
File metadata
- Download URL: malipo-1.0.0.tar.gz
- Upload date:
- Size: 7.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6078942cf3522bd552f8dbdc0fb47a6f6e3c8bf7f790c4eaa9a3537d4d49683
|
|
| MD5 |
95e248de9ae6001dce5590ecc939a8ac
|
|
| BLAKE2b-256 |
271c2840036abadd3f63e749f31d33f4d452a12c027e154dfbc4bfaf91a41044
|
File details
Details for the file malipo-1.0.0-py3-none-any.whl.
File metadata
- Download URL: malipo-1.0.0-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc9244825d950de7c9b526f8734425e645787a4082304b18fb30b6231239101f
|
|
| MD5 |
44e224c1bd5183a3426874ccb2617ac2
|
|
| BLAKE2b-256 |
864804b870a637d543729dec05eaee25f74afe8bf338225d2a8ddb760e5a1482
|