Nexera Pay — SDK Python officiel. pypi: nexera-pay
# nexera-pay
SDK Python officiel pour **Nexera Pay** — API paiement Payment Facilitator RDC (Mobile Money + Carte, wrapper Moko/PayDRC/Cybersource).
## Installation
```bash
pip install nexera-pay
```
## Quickstart
```python
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
```python
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
```python
payment = nexera.payments.create(
amount=50000, currency="USD", method="card",
reference="INV-002",
customer_email="client@example.com",
customer_name="Jean Kabala",
return_url="
monsite.cd",
)
# Rediriger le client :
# checkout_url = payment["checkout_url"]
```
## Vérifier un webhook (Django/Flask/FastAPI)
```python
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
```python
payout = nexer …