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

Download files

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

Source Distribution

nexera_pay-0.1.0.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

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

nexera_pay-0.1.0-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file nexera_pay-0.1.0.tar.gz.

File metadata

  • Download URL: nexera_pay-0.1.0.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.1

File hashes

Hashes for nexera_pay-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f3ed7e7a0e3abe7d21a67b56c4b37c3891e370ded541d55b54b3367eae41ea4e
MD5 2f09683d720d9c3352ef95d7411ff6cc
BLAKE2b-256 5fd826dbe317af43e8a655e7013927ce4820e678aa54553c15867192e4331dfc

See more details on using hashes here.

File details

Details for the file nexera_pay-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: nexera_pay-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.1

File hashes

Hashes for nexera_pay-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d9140c8124d21e626003a95698b52e2f3689029a494d99984e5ad15e99b8184f
MD5 7a298650cf796af048b67a771a65c59d
BLAKE2b-256 d6b2c02f938c787be2ac7b43e292180c5ccfaaf59de0ba537a5b8d9942d2d55b

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