PHPackages                             djstar7/kpay-sdk - 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. djstar7/kpay-sdk

ActiveLibrary[Payment Processing](/categories/payments)

djstar7/kpay-sdk
================

SDK officiel KPay (PHP / Laravel) — paiements &amp; retraits Mobile Money, mode USSD ou passerelle hébergée. Sans dépendance imposée.

v2.0.0(2mo ago)02MITPHPPHP &gt;=8.1

Since May 17Pushed 2mo agoCompare

[ Source](https://github.com/Djstar7/kpay-php-sdk)[ Packagist](https://packagist.org/packages/djstar7/kpay-sdk)[ Docs](https://admin.kpay.site)[ RSS](/packages/djstar7-kpay-sdk/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependenciesVersions (2)Used By (0)

kpay/sdk — PHP / Laravel
========================

[](#kpaysdk--php--laravel)

SDK officiel KPay (PHP ≥ 8.1, cURL natif). Fonctionne en **PHP pur** ou **Laravel** (auto-discovery : ServiceProvider + façade `Kpay`).

PHP pur
-------

[](#php-pur)

```
use Kpay\Sdk\KpayClient;

$kpay = new KpayClient(
    baseUrl: 'https://admin.kpay.site', // sans /api
    apiKey: getenv('KPAY_API_KEY'),
    secretKey: getenv('KPAY_SECRET_KEY'),
    gatewaySecret: getenv('KPAY_GATEWAY_SECRET'),
    maxDuration: 300,                    // SEUL paramètre configurable (s)
);

$res = $kpay->initPayment([
    'amount' => 5000,
    'externalId' => 'ORDER-123',
    'returnUrl' => 'https://monsite.com/retour',
    'cancelUrl' => 'https://monsite.com/annule',
]);
// → rediriger vers $res['gatewayUrl']
```

USSD : `['amount'=>5000,'phoneNumber'=>'674693625','paymentMethod'=>'MTN_MONEY']`. Retrait : `$kpay->initWithdrawal([...])`.

Laravel
-------

[](#laravel)

```
php artisan vendor:publish --tag=kpay-config
```

`.env` :

```
KPAY_BASE_URL=https://admin.kpay.site
KPAY_API_KEY=...
KPAY_SECRET_KEY=...
KPAY_GATEWAY_SECRET=...
KPAY_MAX_DURATION=300

```

```
use Kpay\Sdk\Laravel\Kpay;

$res = Kpay::initPayment(['amount' => 5000, 'returnUrl' => route('kpay.return')]);
return redirect()->away($res['gatewayUrl']);
```

Hybride : webhook + attente
---------------------------

[](#hybride--webhook--attente)

Le chemin principal recommandé reste le **webhook** (résolution instantanée). En complément, à la page de retour :

```
if (! Kpay::verifyReturnSignature($request->query())) abort(400);

$final = Kpay::awaitFinalStatus($paymentId, 'payment'); // s'arrête au
// statut terminal (COMPLETED|FAILED|CANCELLED|EXPIRED|REFUNDED) ou à
// l'échéance max_duration
if (($final['status'] ?? null) === 'COMPLETED') { /* livrer */ }
```

`awaitFinalStatus` sonde l'API jusqu'à un statut terminal ou la durée maximale `max_duration` (seul paramètre configurable).

Flux mode passerelle (détail)
-----------------------------

[](#flux-mode-passerelle-détail)

1. `initPayment(['amount'=>..., 'externalId'=>..., 'returnUrl'=>..., 'cancelUrl'=>...])` → `$res['gatewayUrl']`
2. Rediriger le client vers `$res['gatewayUrl']` (page hébergée KPay : saisie nom / numéro / méthode).
3. KPay traite le paiement, puis renvoie le client vers `returnUrl` avec `?status&reference&externalId&ts&sig`.
4. À la page de retour : `verifyReturnSignature($request->query())`(HMAC-SHA256 sur `status|reference|externalId|ts` avec `gatewaySecret`), puis `awaitFinalStatus` en filet de sécurité. Le **webhook**(`callbackUrl` de l'application) reste la confirmation serveur-à-serveur de référence.

Temps réel — WebSocket (conseillé en complément)
------------------------------------------------

[](#temps-réel--websocket-conseillé-en-complément)

Le SDK PHP est synchrone (cURL natif) : le suivi temps réel se fait **côté navigateur**, via socket.io, pour un retour visuel instantané sans attendre le polling.

> Le WebSocket est un **complément UX**, pas la source de vérité : gardez le webhook (et `verifyReturnSignature`) comme confirmation autoritaire.

```

  // namespace /payments — aucune authentification socket, abonnement par id
  const socket = io("https://admin.kpay.site/payments");
  socket.emit("subscribe:transaction", { transactionId: "" });
  socket.on("payment:status_changed", (p) => {
    // p = { transactionId, status, amount, reference, externalId,
    //       completedAt, failedAt, failureReason, timestamp }
    if (["COMPLETED", "FAILED", "CANCELLED"].includes(p.status)) {
      socket.disconnect();
    }
  });

```

Abonnements disponibles (ack `{ event: "subscribed", data: { room } }`) :

ÉmettrePayloadReçoit`subscribe:transaction``{ transactionId }``payment:status_changed``subscribe:application``{ applicationId }``payment:status_changed` (toutes les transactions de l'app)`subscribe:withdrawal``{ withdrawalId }``withdrawal:status_changed`

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance86

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

69d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/195762603?v=4)[DJUNE STAEL BLAIRIO](/maintainers/Djstar7)[@Djstar7](https://github.com/Djstar7)

---

Top Contributors

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

---

Tags

laravelsdkpaymentsmobile-moneyOrange Moneykpaycamerounmtn-moneyfreemopay

### Embed Badge

![Health badge](/badges/djstar7-kpay-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/djstar7-kpay-sdk/health.svg)](https://phpackages.com/packages/djstar7-kpay-sdk)
```

PHPackages © 2026

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