PHPackages                             dexchangepay/dexpay-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. dexchangepay/dexpay-php

ActiveLibrary[Payment Processing](/categories/payments)

dexchangepay/dexpay-php
=======================

SDK officiel PHP pour l'API DEXPAY - Paiements Mobile Money pour l'Afrique de l'Ouest

00PHP

Since Jun 10Pushed todayCompare

[ Source](https://github.com/DEXCHANGE-GROUP/dexpay-php)[ Packagist](https://packagist.org/packages/dexchangepay/dexpay-php)[ RSS](/packages/dexchangepay-dexpay-php/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

dexpay-php
==========

[](#dexpay-php)

SDK officiel PHP pour l'API DEXPAY - Paiements Mobile Money pour l'Afrique de l'Ouest.

Compatible **Laravel**, **Symfony**, **WordPress** et tout projet PHP 8.1+.
Aucune dépendance externe — utilise `cURL` natif.

[![Packagist](https://camo.githubusercontent.com/2b92cf40c9105e740f41ab28a2296b28bcb7585be635e5ac3adfafbc1e4638a5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6465786368616e67657061792f6465787061792d7068702e737667)](https://packagist.org/packages/dexchangepay/dexpay-php)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)[![PHP](https://camo.githubusercontent.com/6b84e9311750c972da98b6d521269a76c32b8928b672000d4a8c5dd7ac866d09/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253345253344382e312d626c75652e737667)](https://php.net)

Installation
------------

[](#installation)

```
composer require dexchangepay/dexpay-php
```

Démarrage rapide
----------------

[](#démarrage-rapide)

```
use DexchangePay\DexPay;

$dexpay = new DexPay(
    apiKey:    'pk_test_xxx',   // Votre clé publique
    apiSecret: 'sk_test_xxx',  // Votre clé secrète
);

// Créer une session de paiement
$session = $dexpay->checkoutSessions->create([
    'reference'   => 'ORDER_123',
    'item_name'   => 'Premium Plan',
    'amount'      => 10000, // 10 000 XOF
    'currency'    => 'XOF',
    'success_url' => 'https://example.com/success',
    'failure_url' => 'https://example.com/cancel',
    'webhook_url' => 'https://example.com/webhook',
]);

// Rediriger le client vers la page de paiement
header('Location: ' . $session['data']['payment_url']);
```

Checkout Sessions
-----------------

[](#checkout-sessions)

### Créer une session

[](#créer-une-session)

```
$session = $dexpay->checkoutSessions->create([
    'reference'          => 'ORDER_123',
    'item_name'          => 'Abonnement Premium',
    'amount'             => 10000,
    'currency'           => 'XOF',
    'success_url'        => 'https://example.com/success',
    'failure_url'        => 'https://example.com/cancel',
    'webhook_url'        => 'https://example.com/webhook',
    'metadata'           => ['user_id' => '123'],
    'expires_at'         => '2025-12-31T23:59:59Z', // Optionnel
    'client_support_fee' => true,                    // Optionnel
]);
```

### Récupérer une session

[](#récupérer-une-session)

```
// Par ID
$session = $dexpay->checkoutSessions->retrieve('session_id');

// Par référence
$session = $dexpay->checkoutSessions->retrieveByReference('ORDER_123');
```

### Lister les sessions

[](#lister-les-sessions)

```
$sessions = $dexpay->checkoutSessions->list(['page' => 1, 'limit' => 10]);
```

### Créer une tentative de paiement Mobile Money

[](#créer-une-tentative-de-paiement-mobile-money)

```
$attempt = $dexpay->checkoutSessions->createPaymentAttempt('ORDER_123', [
    'payment_method' => 'MOBILE_MONEY',
    'operator'       => 'wave',  // wave, orange_money, mtn, moov
    'countryISO'     => 'SN',    // SN, CI, ML, BF, etc.
    'customer'       => [
        'name'  => 'Jean Dupont',
        'phone' => '+221771234567',
        'email' => 'jean@example.com',
    ],
]);

echo $attempt['data']['payment_url'];
```

### Rembourser une session

[](#rembourser-une-session)

```
$refund = $dexpay->checkoutSessions->refund('ORDER_123');
echo $refund['status']; // success
```

Payouts (Retraits)
------------------

[](#payouts-retraits)

```
$payout = $dexpay->payouts->create([
    'amount'              => 10000,
    'currency'            => 'XOF',
    'destination_phone'   => '+221771234567',
    'destination_details' => [
        'operator'       => 'wave',
        'countryISO'     => 'SN',
        'recipient_name' => 'Jean Dupont',
    ],
    'metadata' => ['invoice_id' => 'INV_123'],
]);

// Récupérer, lister
$dexpay->payouts->retrieve('payout_id');
$dexpay->payouts->list(['page' => 1, 'limit' => 10, 'status' => 'COMPLETED']);
```

Balances
--------

[](#balances)

```
$res = $dexpay->balances->list();
echo $res['data'][0]['balance'] . ' ' . $res['data'][0]['currency'];
```

Providers
---------

[](#providers)

```
// Providers de collecte (paiement)
$payment = $dexpay->paymentProviders->list(['provider_country' => 'SN']);

// Providers de retrait (payout)
$payout = $dexpay->payoutProviders->list();
```

Products
--------

[](#products)

```
// Produit ponctuel
$product = $dexpay->products->create([
    'name'     => 'T-Shirt',
    'price'    => 5000,
    'currency' => 'XOF',
    'type'     => 'ONE_TIME',
]);

// Produit récurrent
$plan = $dexpay->products->create([
    'name'           => 'Premium Plan',
    'price'          => 10000,
    'currency'       => 'XOF',
    'type'           => 'RECURRING',
    'billing_period' => 'MONTHLY',
]);

$dexpay->products->list(['type' => 'RECURRING', 'is_active' => true]);
$dexpay->products->update('prod_123', ['price' => 15000]);
$dexpay->products->delete('prod_123');
```

Customers
---------

[](#customers)

```
$customer = $dexpay->customers->create([
    'name'    => 'Jean Dupont',
    'email'   => 'jean@example.com',
    'phone'   => '+221771234567',
    'country' => 'SN',
]);

// Rechercher
$dexpay->customers->list(['email' => 'jean@example.com']);
$dexpay->customers->list(['phone' => '+221771234567']);
$dexpay->customers->update('cus_123', ['country' => 'CI']);
```

Subscriptions
-------------

[](#subscriptions)

```
$sub = $dexpay->subscriptions->create([
    'customer_id' => 'cus_123',
    'product_id'  => 'prod_456',
]);

$dexpay->subscriptions->update('sub_123', ['status' => 'PAUSED']);
$dexpay->subscriptions->cancel('sub_123');
```

Gestion des erreurs
-------------------

[](#gestion-des-erreurs)

```
use DexchangePay\DexPay;
use DexchangePay\Exceptions\DexPayException;

try {
    $session = $dexpay->checkoutSessions->create([...]);
} catch (DexPayException $e) {
    echo $e->getErrorCode();   // VALIDATION_ERROR
    echo $e->getMessage();     // Invalid amount
    echo $e->getStatusCode();  // 400
}
```

Intégration frameworks
----------------------

[](#intégration-frameworks)

### Laravel

[](#laravel)

```
// config/services.php
'dexpay' => [
    'key'     => env('DEXPAY_API_KEY'),
    'secret'  => env('DEXPAY_API_SECRET'),
    'sandbox' => env('DEXPAY_SANDBOX', false),
],

// AppServiceProvider.php
use DexchangePay\DexPay;

$this->app->singleton(DexPay::class, fn() => new DexPay(
    apiKey:    config('services.dexpay.key'),
    apiSecret: config('services.dexpay.secret'),
    sandbox:   config('services.dexpay.sandbox'),
));

// PaymentController.php
public function webhook(Request $request): JsonResponse
{
    $event = $request->json()->all();

    match ($event['type']) {
        'checkout.completed' => $this->handleSuccess($event['data']),
        'checkout.failed'    => $this->handleFailure($event['data']),
        'payout.completed'   => $this->handlePayout($event['data']),
        default              => null,
    };

    return response()->json(['received' => true]);
}
```

### Symfony

[](#symfony)

```
// services.yaml
DexchangePay\DexPay:
    arguments:
        $apiKey:    '%env(DEXPAY_API_KEY)%'
        $apiSecret: '%env(DEXPAY_API_SECRET)%'
        $sandbox:   '%env(bool:DEXPAY_SANDBOX)%'

// WebhookController.php
#[Route('/webhook', methods: ['POST'])]
public function webhook(Request $request): JsonResponse
{
    $event = json_decode($request->getContent(), true);
    // traiter $event['type']
    return new JsonResponse(['received' => true]);
}
```

### WordPress

[](#wordpress)

```
require_once plugin_dir_path(__FILE__) . 'vendor/autoload.php';

use DexchangePay\DexPay;

$dexpay = new DexPay(
    apiKey:    get_option('dexpay_api_key'),
    apiSecret: get_option('dexpay_api_secret'),
    sandbox:   (bool) get_option('dexpay_sandbox'),
);

// Webhook via WP REST API
add_action('rest_api_init', function () {
    register_rest_route('dexpay/v1', '/webhook', [
        'methods'  => 'POST',
        'callback' => function ($request) {
            $event = $request->get_json_params();
            // traiter $event['type']
            return ['received' => true];
        },
        'permission_callback' => '__return_true',
    ]);
});
```

Webhooks
--------

[](#webhooks)

Évènements envoyés par DEXPAY (POST JSON sur votre `webhook_url`) :

ÉvènementDescription`checkout.completed`Paiement réussi`checkout.failed`Paiement échoué`payout.completed`Payout réussi`payout.failed`Payout échoué`subscription.created`Abonnement créé`subscription.cancelled`Abonnement annuléConfiguration avancée
---------------------

[](#configuration-avancée)

```
// Production (défaut)
$dexpay = new DexPay(apiKey: 'pk_live_xxx', apiSecret: 'sk_live_xxx');

// Sandbox (test)
$dexpay = new DexPay(
    apiKey:    'pk_test_xxx',
    apiSecret: 'sk_test_xxx',
    sandbox:   true,
);

// Personnalisée
$dexpay = new DexPay(
    apiKey:    'pk_live_xxx',
    apiSecret: 'sk_live_xxx',
    baseUrl:   'https://api.dexpay.africa/api/v1',
    timeout:   60,
);
```

### URLs de l'API

[](#urls-de-lapi)

EnvironnementURLProductionSandboxDevises supportées
------------------

[](#devises-supportées)

CodeDeviseXOFFranc CFA BCEAO (Sénégal, Côte d'Ivoire, Mali, Burkina Faso, etc.)XAFFranc CFA BEAC (Cameroun, Gabon, Congo, etc.)GNFFranc GuinéenOpérateurs supportés
--------------------

[](#opérateurs-supportés)

OpérateurCodePaysWave`wave`SN, CI, ML, BFOrange Money`orange_money`SN, CI, ML, BF, GNMTN`mtn`CI, BFMoov`moov`CI, BFPrérequis
---------

[](#prérequis)

- PHP 8.1+
- Extension `ext-curl`
- Extension `ext-json`

Développement
-------------

[](#développement)

```
composer install
composer test       # Lance PHPUnit
```

Support
-------

[](#support)

- 📧 Email :
- 📖 Documentation :
- 🐙 GitHub :
- 🐛 Issues :

License
-------

[](#license)

MIT © [DEXCHANGE GROUP](https://dexchange.sn)

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance65

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/119123572?v=4)[Oumar Kane](/maintainers/KaneDev7)[@KaneDev7](https://github.com/KaneDev7)

---

Top Contributors

[![KaneDev7](https://avatars.githubusercontent.com/u/119123572?v=4)](https://github.com/KaneDev7 "KaneDev7 (2 commits)")

### Embed Badge

![Health badge](/badges/dexchangepay-dexpay-php/health.svg)

```
[![Health](https://phpackages.com/badges/dexchangepay-dexpay-php/health.svg)](https://phpackages.com/packages/dexchangepay-dexpay-php)
```

###  Alternatives

[omnipay/coinbase

Coinbase driver for the Omnipay payment processing library

18570.2k1](/packages/omnipay-coinbase)[yenepay/php-sdk

YenePay SDK for PHP

112.7k](/packages/yenepay-php-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
