nexera / pay
Nexera Pay — API paiement RDC (Mobile Money + Carte). SDK PHP officiel.
v0.1.0
2026-08-08 19:56 UTC
Requires
- php: >=7.4
- ext-curl: *
- ext-json: *
README
SDK PHP officiel pour Nexera Pay — API paiement Payment Facilitator RDC (Mobile Money + Carte, wrapper Moko/PayDRC/Cybersource).
Compatible PHP 7.4+, Laravel (any version), WordPress (plugins e-commerce).
Installation
composer require nexera/pay
Quickstart
<?php require 'vendor/autoload.php'; $nexera = new \Nexera\Pay\NexeraPay( getenv('NEXERA_PAY_API_KEY'), getenv('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', ]); echo $payment['id'] . ' — ' . $payment['status']; // pay_xxx — processing
Paiement carte (hosted checkout)
$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 vers le checkout hosted MokoAfrika header('Location: ' . $payment['checkout_url']);
Vérifier un webhook (dans Laravel)
use Nexera\Pay\Webhooks; Route::post('/webhooks/nexera', function (Request $request) { $sig = $request->header('X-Nexera-Signature', ''); $body = $request->getContent(); if (!Webhooks::verifySignature(env('NEXERA_WEBHOOK_SECRET'), $sig, $body)) { return response('invalid signature', 401); } $event = json_decode($body, true); if ($event['type'] === 'payment.succeeded') { $tx = $event['data']['object']; // Marquer la facture tx['reference'] comme payée dans ta DB } return response('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(); echo $bal['available']['USD']; // en cents
Gestion d'erreurs
use Nexera\Pay\NexeraPay; use Nexera\Pay\Errors\{ValidationError, RateLimitError, SignatureError}; try { $p = $nexera->payments->create([...]); } catch (RateLimitError $e) { echo "Rate limited, retry dans {$e->retryAfter}s"; } catch (ValidationError $e) { echo "Validation failed: {$e->detail}"; } catch (SignatureError $e) { // Clé/secret incorrect ou horloge système décalée }
Sandbox
Clé nex_test_... → tout mocké. Patterns MSISDN de test :
| MSISDN | Résultat |
|---|---|
...001 |
Succès en 3s |
...002 |
Failed |
...003 |
Timeout |
...004 |
Failed (wrong PIN) |
Docs
https://docs.nexera.africa/pay
License
MIT