承接 dexchangepay/dexpay-php 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

dexchangepay/dexpay-php

Composer 安装命令:

composer require dexchangepay/dexpay-php

包简介

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

README 文档

README

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 License: MIT PHP

Installation

composer require dexchangepay/dexpay-php

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

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

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

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

Lister les sessions

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

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

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

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

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

Providers

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

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

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

$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

$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

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

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

// 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

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

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

Évènement Description
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

// 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

Environnement URL
Production https://api.dexpay.africa/api/v1
Sandbox https://api-sandbox.dexpay.africa/api/v1

Devises supportées

Code Devise
XOF Franc CFA BCEAO (Sénégal, Côte d'Ivoire, Mali, Burkina Faso, etc.)
XAF Franc CFA BEAC (Cameroun, Gabon, Congo, etc.)
GNF Franc Guinéen

Opérateurs supportés

Opérateur Code Pays
Wave wave SN, CI, ML, BF
Orange Money orange_money SN, CI, ML, BF, GN
MTN mtn CI, BF
Moov moov CI, BF

Prérequis

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

Développement

composer install
composer test       # Lance PHPUnit

Support

License

MIT © DEXCHANGE GROUP

dexchangepay/dexpay-php 适用场景与选型建议

dexchangepay/dexpay-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 06 月 10 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「payment」 「wave」 「africa」 「Sénégal」 「mobile-money」 「orange-money」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 dexchangepay/dexpay-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 dexchangepay/dexpay-php 我们能提供哪些服务?
定制开发 / 二次开发

基于 dexchangepay/dexpay-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 35
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-10