macdanson/jpesa-php-sdk

PHP SDK for JPesa API (Credit/Debit GWallet, Transaction lookup, KYC) with optional Laravel integration.

Installs: 1

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/macdanson/jpesa-php-sdk

V1.0 2025-11-11 11:34 UTC

This package is auto-updated.

Last update: 2025-12-11 12:09:47 UTC


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

  1. Publish config (optional):
php artisan vendor:publish --tag=config --provider="JPesa\SDK\Laravel\JPesaServiceProvider"

This will create config/jpesa.php.

  1. Set env:
JPESA_API_KEY=your_live_or_sandbox_key
JPESA_BASE_URL=https://my.jpesa.com/api/
JPESA_TIMEOUT=30
  1. Resolve via DI:
use JPesa\SDK\JPesaClient;

public function charge(JPesaClient $jpesa) {
    $jpesa->credit(['mobile'=>'2567...','amount'=>1000,'tx'=>'ORDER-1']);
}
  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