digitalpaye/digitalpaye-php
Composer 安装命令:
composer require digitalpaye/digitalpaye-php
包简介
Official PHP SDK for the DigitalPaye API — Mobile Money payments (Orange Money, MTN MoMo, Moov Flooz, Wave) in Côte d'Ivoire.
关键字:
README 文档
README
Official PHP SDK for the DigitalPaye API — accept and send Mobile Money payments (Orange Money, MTN MoMo, Moov Flooz, Wave) in Côte d'Ivoire.
Requires PHP 7.4+, the curl and json extensions (both bundled with PHP
by default on virtually every install).
Installation
composer require digitalpaye/digitalpaye-php
Quick start
<?php require 'vendor/autoload.php'; use DigitalPaye\DigitalPayeClient; use DigitalPaye\Exception\DigitalPayeException; $dp = new DigitalPayeClient( getenv('DIGITALPAYE_PUBLIC_KEY'), getenv('DIGITALPAYE_SECRET') ); // Directly collect a Mobile Money payment try { $result = $dp->transactions->collect([ 'amount' => 5000, 'currency' => 'XOF', 'operator_code' => 'ORANGE_MONEY_CI', 'external_ref' => 'INV-2026-001', 'otp' => '3378', // required for Orange Money 'payer_phone' => '0777101308', 'payer_first_name' => 'Jean', 'payer_last_name' => 'Konan', 'payer_email' => 'jean@example.ci', ]); echo $result['data']['status'] . ' — ' . $result['data']['reference']; } catch (DigitalPayeException $e) { echo $e->getErrorCode() . ': ' . $e->getMessage(); }
The SDK handles the Basic → Bearer token exchange automatically (and
caches/renews it) — you never need to call the /v1/auth/token endpoint
yourself.
Usage examples
Orders (cart-style checkout)
$order = $dp->orders->create([ 'currency' => 'XOF', 'items' => [ ['name' => 'T-shirt', 'quantity' => 2, 'unit_price' => 5000], ['name' => 'Shipping', 'quantity' => 1, 'unit_price' => 1000], ], 'url_success' => 'https://my-shop.com/thank-you', 'url_error' => 'https://my-shop.com/cart', ]); $dp->orders->pay($order['data']['reference'], [ 'operator_code' => 'MTN_MONEY_CI', 'external_ref' => 'ORDER-PAY-001', 'payer_phone' => '0546123456', 'payer_first_name' => 'Awa', 'payer_last_name' => 'Touré', 'payer_email' => 'awa@example.ci', ]);
Payment links
$link = $dp->paymentLinks->create([ 'label' => 'Support our school', 'amount' => 10000, 'currency' => 'XOF', ]); echo $link['data']['url']; // share this URL
Payouts (send money out)
$dp->payouts->create([ 'amount' => 25000, 'currency' => 'XOF', 'operator_code' => 'WAVE_MONEY_CI', 'external_ref' => 'PAYOUT-001', 'recipient_phone' => '0707112233', ]);
Balance
$result = $dp->balance->retrieve(); echo $result['data']['balance'] . ' ' . $result['data']['currency'];
Beneficiaries, Invoices, Bulk transfers, Scheduled transfers, Escrow, Contactless
All follow the same list() / create() / retrieve() / update() /
delete() pattern — browse src/Resources/*.php, each class is
self-contained and documented with PHPDoc.
Error handling
Every failed request throws a DigitalPayeException:
use DigitalPaye\Exception\DigitalPayeException; try { $dp->transactions->collect(['amount' => 50, 'currency' => 'XOF' /* ... */]); } catch (DigitalPayeException $e) { error_log($e->getErrorCode() . ' ' . $e->getStatusCode() . ' ' . $e->getMessage()); var_dump($e->getDetails()); }
Pagination
List methods accept a $params array forwarded as the query string
(e.g. ['page' => 2, 'limit' => 50, 'status' => 'successful']) and return
['data' => ..., 'meta' => ...] where meta contains pagination info.
$result = $dp->transactions->list(['page' => 1, 'limit' => 20]); $transactions = $result['data']; $meta = $result['meta'];
License
MIT
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-07-08