Skip to main content

nexera-pay

SDK Python officiel pour Nexera Pay — API paiement Payment Facilitator RDC (Mobile Money + Carte, wrapper Moko/PayDRC/Cybersource).

Installation

pip install nexera-pay

Quickstart

from nexera_pay import NexeraPay
import os

nexera = NexeraPay(
    api_key=os.environ["NEXERA_PAY_API_KEY"],
    secret=os.environ["NEXERA_PAY_SECRET"],
)

# Créer un paiement Mobile Money (STK)
payment = nexera.payments.create(
    amount=10000,          # 100.00 USD en cents
    currency="USD",
    method="mobile_money",
    operator="mpesa",
    phone="243812345001",
    reference="INV-2026-0001",
    description="Facture #INV-2026-0001",
)

print(payment["id"], payment["status"])   # pay_xxxx  processing

Client async

from nexera_pay import NexeraPayAsync
import asyncio

async def main():
    nexera = NexeraPayAsync(api_key="...", secret="...")
    p = await nexera.payments.create(
        amount=100, currency="CDF", method="mobile_money",
        operator="mpesa", phone="243828584688", reference="TEST-1",
    )
    print(p)

asyncio.run(main())

Créer un paiement carte

payment = nexera.payments.create(
    amount=50000, currency="USD", method="card",
    reference="INV-002",
    customer_email="client@example.com",
    customer_name="Jean Kabala",
    return_url="https://monsite.cd/facture/002",
)
# Rediriger le client :
# checkout_url = payment["checkout_url"]

Vérifier un webhook (Django/Flask/FastAPI)

from nexera_pay import verify_webhook_signature
from flask import Flask, request

app = Flask(__name__)
WEBHOOK_SECRET = "whsec_..."

@app.route("/webhooks/nexera", methods=["POST"])
def webhook():
    sig = request.headers.get("X-Nexera-Signature", "")
    if not verify_webhook_signature(WEBHOOK_SECRET, sig, request.get_data(as_text=True)):
        return "invalid signature", 401
    event = request.json
    if event["type"] == "payment.succeeded":
        tx = event["data"]["object"]
        # Marquer la facture tx["reference"] comme payée
    return "ok", 200

Payout B2C

payout = nexera.payouts.create(
    amount=100, currency="CDF",
    operator="mpesa", phone="243828584688",
    reference="REMB-001", description="Remboursement client",
)

Refund

# Refund total
nexera.refunds.create("pay_xxx")

# Refund partiel
nexera.refunds.create("pay_xxx", amount=5000, reason="Article manquant")

Balance

bal = nexera.balance.get()
print(bal["available"]["USD"], bal["available"]["CDF"])   # en cents

Gestion d'erreurs

from nexera_pay import NexeraPay, ValidationError, RateLimitError, SignatureError

try:
    p = nexera.payments.create(amount=10000, ...)
except RateLimitError as e:
    print(f"Rate limited, retry dans {e.retry_after}s")
except ValidationError as e:
    print(f"Validation failed: {e.detail}")
except SignatureError:
    # Clé/secret incorrect ou horloge système décalée
    pass

Sandbox

Clé nex_test_... → tout mocké, aucun vrai argent. Patterns MSISDN de test :

MSISDN Résultat
...001 Succès en 3s
...002 Failed
...003 Timeout puis failed
...004 Failed (wrong PIN)

Docs

https://docs.nexera.africa/pay

License

MIT

Metadata

Release files for nexera-pay 0.1.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 nexera-pay 0.1.0
File Size Uploaded
nexera_pay-0.1.0.tar.gz 8.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nexera-pay 0.1.0
File Interpreter ABI Platform
nexera_pay-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 17.3 kB

Release files / nexera_pay-0.1.0.tar.gz

Download URL nexera_pay-0.1.0.tar.gz
Size 8.7 kB
Tags Source
SHA-256 checksum
How to use checksums
f3ed7e7a0e3abe7d21a67b56c4b37c3891e370ded541d55b54b3367eae41ea4e
BLAKE2b-256 checksum
How to use checksums
5fd826dbe317af43e8a655e7013927ce4820e678aa54553c15867192e4331dfc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.1

Release files / nexera_pay-0.1.0-py3-none-any.whl

Download URL nexera_pay-0.1.0-py3-none-any.whl
Size 8.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d9140c8124d21e626003a95698b52e2f3689029a494d99984e5ad15e99b8184f
BLAKE2b-256 checksum
How to use checksums
d6b2c02f938c787be2ac7b43e292180c5ccfaaf59de0ba537a5b8d9942d2d55b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.1

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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