Metadata-Version: 2.4
Name: nelsius-pay
Version: 2.0.0
Summary: Official Python SDK for Nelsius Pay API V2
Home-page: https://github.com/nelson-siebi/nelsius-pay-python
Author: Nelson Siebi
Author-email: Nelson Siebi <nelsonsiebi237@gmail.com>
License: MIT
Project-URL: Homepage, https://nelsiuspay.com
Project-URL: Documentation, https://nelsiuspay.com/api-doc
Project-URL: Source, https://github.com/nelson-siebi/nelsius-pay-python
Project-URL: Bug Tracker, https://github.com/nelson-siebi/nelsius-pay-python/issues
Keywords: nelsius,nelsiuspay,payments,checkout,mobile-money,orange-money,mtn-momo,sdk,python,africa,fintech
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Office/Business :: Financial :: Point-Of-Sale
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: requests>=2.25.0
Dynamic: author
Dynamic: home-page

# NelsiusPay Python SDK (V2)

SDK officiel Python pour intégrer la passerelle de paiement **NelsiusPay** dans vos applications Django, Flask, FastAPI ou scripts automatisés.

## Installation

```bash
pip install nelsius-pay
```

## Initialisation

```python
from nelsius_pay import NelsiusClient

client = NelsiusClient(
    api_key="np_live_xxxxxxxxxxxxxxxx",
    secret_key="whsec_xxxxxxxxxxxxxxx"
)
```

## 1. Créer une session de paiement hébergée (Hosted Checkout)

```python
session = client.checkout.create_session(
    amount=5000,
    currency="XAF",
    reference="CMD-94812",
    customer_email="client@example.com",
    customer_phone="+237690000000",
    customer_name="Jean Dupont",
    default_country="CM",  # Cameroun par défaut (ou CI, SN, BJ...)
    return_url="https://monsite.com/commande/succes",
    cancel_url="https://monsite.com/commande/annulee",
    description="Abonnement mensuel Pro"
)

# Redirigez votre client vers l'URL sécurisée :
print(session["data"]["checkout_url"])
```

## 2. Débit direct Mobile Money (Server-to-Server USSD)

```python
charge = client.charges.direct_pay(
    amount=2500,
    currency="XAF",
    operator="orange",  # ou mtn
    phone="699000000",
    customer_name="Alice Ngo",
    reference="REF-8849"
)

print(charge["message"])  # Prompt USSD envoyé sur le téléphone du client
```

## 3. Vérifier un webhook sécurisé HMAC-SHA256

```python
@app.route("/webhooks/nelsius", methods=["POST"])
def nelsius_webhook():
    payload = request.get_data()
    signature = request.headers.get("X-Nelsius-Signature")
    
    try:
        event = client.webhooks.construct_event(payload, signature)
        if event["event"] == "payment.success":
            tx = event["data"]
            print(f"Paiement validé : {tx['amount']} {tx['currency']}")
        return {"status": "ok"}, 200
    except Exception as e:
        return {"error": str(e)}, 400
```

