Nexera Pay — SDK PHP officiel. composer: nexera/pay
# Nexera Pay — SDK PHP
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
```bash
composer require nexera/pay
```
## Quickstart
```php
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)
```php
$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 vers le checkout hosted MokoAfrika
header('Location: ' . $payment['checkout_url']);
```
## Vérifier un webhook (dans Laravel)
```php
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
```php
$payout = $nexera->payouts->create([
'amount' => 100,
'currency' => 'CDF',
'operator' => 'mpesa',
'phone' => '243828584688',
'reference' => 'REMB-001',
'description' => 'Remboursement client',
]);
```
## Refund
```php
// Refund total
$nexera->refunds->create('pay_xxx');
// Refund partiel
$nexera->refund …