PHPackages                             barkapay/payhub-php - 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. barkapay/payhub-php

ActiveLibrary[Payment Processing](/categories/payments)

barkapay/payhub-php
===================

Official PHP SDK for the PayHub payments API — mobile money &amp; crypto, one API across countries.

00PHPCI passing

Since Jun 28Pushed todayCompare

[ Source](https://github.com/BarkaPay/payhub-php)[ Packagist](https://packagist.org/packages/barkapay/payhub-php)[ RSS](/packages/barkapay-payhub-php/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

PayHub PHP SDK
==============

[](#payhub-php-sdk)

Official PHP client for the [PayHub](https://payhub.africa/developers) payments API — mobile money &amp; crypto, one API across countries.

- Zero dependencies (just `ext-curl` + `ext-json`) — safe to embed inside WordPress / WooCommerce.
- Typed payments, transfers and balance objects.
- Built-in webhook signature verification.
- Automatic retries on transient errors.

Requirements
------------

[](#requirements)

PHP **8.1+** with the `curl` and `json` extensions.

Install
-------

[](#install)

```
composer require barkapay/payhub-php
```

Quick start
-----------

[](#quick-start)

```
use PayHub\Client;

$payhub = new Client(
    apiKey:  'pk_live_xxx:sk_live_yyy', // the "key_id:secret" you copy from the dashboard
    country: 'bf',                       // default country, overridable per call
);

$payment = $payhub->payments->create([
    'operator'     => 'ORANGE',
    'phone_number' => '50123456789',
    'amount'       => 10000,
    'otp'          => '123456',          // only for synchronous-OTP operators (e.g. Orange)
    'order'        => ['id' => 'ORDER-2026-001'],
]);

echo $payment->publicId, ' ', $payment->status?->value;
```

> **Authentication:** pass the raw `key_id:secret` (or `keyId` + `secret` separately). The SDK adds the `Bearer` prefix — never include the word `Bearer` yourself.

Payments
--------

[](#payments)

```
$payhub->payments->create([...]);                 // returns PayHub\DTO\Payment
$payhub->payments->get('pay_… or order_id');      // by public_id or your order_id
$payhub->payments->list(['status' => 'SUCCESSFUL', 'per_page' => 50]); // PaymentCollection
$payhub->payments->confirmOtp($publicId, '123456'); // for AWAITING_OTP payments
$payhub->payments->resendOtp($publicId);
```

The flow depends on the operator — always branch on the returned `status`: synchronous (`SUCCESSFUL`/`FAILED`), `AWAITING_OTP` (confirm step), or `PROCESSING_OPERATOR` (final outcome arrives by webhook).

Transfers
---------

[](#transfers)

```
$payhub->transfers->create([
    'operator'     => 'ORANGE',
    'phone_number' => '50123456789',
    'amount'       => 50000,
    'order'        => ['id' => 'XFER-2026-001'],
]);
$payhub->transfers->get($id);
$payhub->transfers->list(['from_date' => '2026-06-01']);
```

Balance &amp; operators
-----------------------

[](#balance--operators)

```
$balance = $payhub->balance->get();   // PayHub\DTO\Balance: available / total / holds / currency
$payhub->operators->info();           // authoritative operator list for the country
$payhub->operators->availability();
$payhub->me();
```

Webhooks
--------

[](#webhooks)

Verify the `PayHub-Signature` header against the **raw** request body:

```
use PayHub\Webhook;
use PayHub\Exception\SignatureVerificationException;

try {
    $event = Webhook::parse(
        $rawBody,
        $_SERVER['HTTP_PAYHUB_SIGNATURE'] ?? '',
        $endpointSecret, // whsec_…
    );
} catch (SignatureVerificationException) {
    http_response_code(400);
    exit;
}

// No `event` field — derive it from $event['type'] + $event['status'].
// Deduplicate on $event['public_id'] (retries deliver the same body).
```

Errors
------

[](#errors)

Every API error throws a typed exception extending `PayHub\Exception\ApiException`(`getErrorCode()`, `getHttpStatus()`, `getRequestId()`, `getErrors()`):

ExceptionWhen`AuthenticationException`401 — bad credentials`AuthorizationException`403/410/451 — not allowed`ValidationException`422 — bad request (`getErrors()`)`NotFoundException`404`ConflictException`409 — duplicate`RateLimitException`429`ServiceUnavailableException`503 — retryable`NetworkException`request never reached a responseCatch everything from the SDK with `PayHub\Exception\PayHubException`.

Configuration
-------------

[](#configuration)

```
new Client(
    apiKey:     'key_id:secret',
    country:    'bf',
    baseUrl:    'https://hub.barkapay.com',
    maxRetries: 2,            // 429/503/network
    timeout:    30.0,         // seconds
    httpClient: $custom,      // any PayHub\Http\HttpClientInterface
);
```

License
-------

[](#license)

MIT.

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance65

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/82038528?v=4)[Youmanly](/maintainers/Youmanly)[@Youmanly](https://github.com/Youmanly)

---

Top Contributors

[![Youmanly](https://avatars.githubusercontent.com/u/82038528?v=4)](https://github.com/Youmanly "Youmanly (3 commits)")

### Embed Badge

![Health badge](/badges/barkapay-payhub-php/health.svg)

```
[![Health](https://phpackages.com/badges/barkapay-payhub-php/health.svg)](https://phpackages.com/packages/barkapay-payhub-php)
```

###  Alternatives

[omnipay/coinbase

Coinbase driver for the Omnipay payment processing library

18570.2k1](/packages/omnipay-coinbase)

PHPackages © 2026

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