macdanson/jpesa-php-sdk
最新稳定版本:V1.0
Composer 安装命令:
composer require macdanson/jpesa-php-sdk
包简介
PHP SDK for JPesa API (Credit/Debit GWallet, Transaction lookup, KYC) with optional Laravel integration.
README 文档
README
A lightweight, Composer-ready PHP SDK for the JPesa API: Credit/Debit GWallet, Transaction Info, and KYC.
- Base URL:
https://my.jpesa.com/api/ - Auth: Provide your
_key_(API key).
Installation
composer require macdanson/jpesa-php-sdk
Quick start (vanilla PHP)
use JPesa\SDK\JPesaClient; $client = new JPesaClient( baseUrl: 'https://my.jpesa.com/api/', apiKey: getenv('JPESA_API_KEY') ?: 'YOUR_KEY' ); // Credit $res = $client->credit([ 'mobile' => '256752567374', 'amount' => 1000, 'tx' => 'ORDER-12345', ]);
Other calls
$client->debit([ 'mobile'=>'2567...', 'amount'=>500, 'tx'=>'PAYOUT-1' ]); $client->transactionInfo([ 'tid'=>'TXN-ID-ABC' ]); // or: $client->transactionInfo([ 'pid'=>'PAYMENT-ID-XYZ' ]); // or: $client->transactionInfo([ 'cur'=>'UGX' ]); $client->kyc('2567...');
Laravel usage
- Publish config (optional):
php artisan vendor:publish --tag=config --provider="JPesa\SDK\Laravel\JPesaServiceProvider"
This will create config/jpesa.php.
- Set env:
JPESA_API_KEY=your_live_or_sandbox_key
JPESA_BASE_URL=https://my.jpesa.com/api/
JPESA_TIMEOUT=30
- Resolve via DI:
use JPesa\SDK\JPesaClient; public function charge(JPesaClient $jpesa) { $jpesa->credit(['mobile'=>'2567...','amount'=>1000,'tx'=>'ORDER-1']); }
- Or use Facade:
use JPesa\SDK\Laravel\Facades\JPesa; JPesa::debit(['mobile'=>'2567...','amount'=>500,'tx'=>'PAYOUT-1']);
Webhooks / Callbacks
Pass a callback URL in credit()/debit() if you want JPesa to notify your app.
Always verify fields like tid and your tx to ensure idempotency.
Testing
composer install
composer test
Unit tests use Guzzle's MockHandler to simulate API responses.
License
MIT
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-11-11