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

ActiveLibrary[Payment Processing](/categories/payments)

zayono/zayono-php
=================

Official PHP SDK for the Zayono unified Mobile Money payment gateway.

v1.0.0(1mo ago)01↓50%MITPHPPHP ^8.1

Since Jun 12Pushed 1mo agoCompare

[ Source](https://github.com/RomualdAKM/zayono-php)[ Packagist](https://packagist.org/packages/zayono/zayono-php)[ Docs](https://github.com/RomualdAKM/zayono-php)[ RSS](/packages/zayono-zayono-php/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (5)Versions (2)Used By (0)

Zayono PHP SDK
==============

[](#zayono-php-sdk)

[![Packagist](https://camo.githubusercontent.com/a20d4b24105920713895c8b582f9fe6de78799b76525091dacc1d1f361c8d545/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7a61796f6e6f2f7a61796f6e6f2d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/zayono/zayono-php)[![License](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![PHP](https://camo.githubusercontent.com/b1f1b822d9dad7c7df5c1813ffb46e57218ed5d5aa6980fd4a0125bc037c1a3d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e312d3737374242342e7376673f7374796c653d666c61742d737175617265)](composer.json)

Official PHP SDK for [Zayono](https://zayono.com), the unified Mobile Money payment gateway for Africa.

Wraps the Zayono REST API with authentication, automatic retries, idempotency, lazy pagination, typed exceptions, and webhook signature verification.

- Package: [`zayono/zayono-php`](https://packagist.org/packages/zayono/zayono-php)
- Source: [github.com/RomualdAKM/zayono-php](https://github.com/RomualdAKM/zayono-php)
- Documentation: [docs.zayono.com/sdks/php](https://docs.zayono.com/sdks/php)

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

[](#requirements)

- PHP 8.1 or higher
- ext-json
- Guzzle 7 (or any PSR-18 HTTP client)

Installation
------------

[](#installation)

```
composer require zayono/zayono-php
```

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

[](#quick-start)

```
use Zayono\Zayono;

$zayono = new Zayono('zyn_test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');

$payment = $zayono->payments->create([
    'amount'         => 5000,
    'currency'       => 'XOF',
    'description'    => 'T-shirt premium',
    'customer_email' => 'customer@example.com',
    'return_url'     => 'https://example.com/success',
    'cancel_url'     => 'https://example.com/cancel',
]);

header('Location: ' . $payment['checkout_url']);
```

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

[](#configuration)

```
$zayono = new Zayono(
    apiKey:     'zyn_test_xxxxx',
    baseUrl:    'https://backend.zayono.com/api/v1',  // default
    timeout:    30,                                    // seconds
    maxRetries: 3,                                     // 5xx + 429 + network
    logger:     $psrLogger,                            // optional PSR-3
);
```

The environment (sandbox vs live) is derived server-side from the API key prefix:

- `zyn_test_*` keys produce sandbox-environment transactions
- `zyn_live_*` keys produce production transactions

Examples
--------

[](#examples)

### 1. Initialize a payment

[](#1-initialize-a-payment)

```
$payment = $zayono->payments->create([
    'amount'         => 5000,
    'currency'       => 'XOF',
    'description'    => 'Order #1234',
    'customer_email' => 'jean@example.com',
    'metadata'       => ['order_id' => 'ORD-1234'],
]);

echo $payment['checkout_url'];
```

### 2. Retrieve and verify a payment

[](#2-retrieve-and-verify-a-payment)

```
$payment = $zayono->payments->retrieve('019e5eaf-cb99-7351-a6d5-c219e28534db');

if ($payment['status'] === 'success') {
    // Deliver the order.
}

// Force a fresh check against the upstream aggregator:
$payment = $zayono->payments->verify('019e5eaf-cb99-7351-a6d5-c219e28534db');
```

### 3. Send a payout

[](#3-send-a-payout)

```
$payout = $zayono->payouts->create([
    'amount'      => 10000,
    'currency'    => 'XOF',
    'operator'    => 'mtn_bj',
    'phone'       => '+22961000000',
    'description' => 'Payout for order ORD-1234',
]);
```

> **Refunds**: the public API-key v1 surface does not yet expose `POST /v1/payments/{id}/refunds`. For now, trigger refunds from the Zayono merchant dashboard. A `refunds` resource will be added to this SDK once the endpoint ships on the v1 surface.

### 4. Verify a webhook signature

[](#4-verify-a-webhook-signature)

```
$payload   = file_get_contents('php://input');
$signature = $_SERVER['HTTP_X_ZAYONO_SIGNATURE'] ?? '';

if (!$zayono->webhooks->verify($payload, $signature, getenv('ZAYONO_WEBHOOK_SECRET'))) {
    http_response_code(401);
    exit('Invalid signature');
}

$event = json_decode($payload, true);

match ($event['event']) {
    'payment.succeeded' => handlePaymentSuccess($event['data']),
    'payment.failed'    => handlePaymentFailure($event['data']),
    default             => null,
};
```

### 5. Paginate through every payment

[](#5-paginate-through-every-payment)

```
foreach ($zayono->payments->list(['status' => 'success']) as $payment) {
    echo $payment['id'], PHP_EOL;
}
```

For a single page:

```
$page = $zayono->payments->listPage(['status' => 'success', 'per_page' => 50]);
foreach ($page['payments'] as $payment) {
    // …
}
```

Idempotency
-----------

[](#idempotency)

Every `POST`, `PATCH`, `PUT`, and `DELETE` request automatically receives a fresh `X-Idempotency-Key` (UUID v4) so retried calls never double-process a transaction. Override the key explicitly when you need to:

```
$zayono->payments->create([
    'amount'           => 5000,
    'currency'         => 'XOF',
    'idempotency_key'  => '019e5eaf-cb99-4351-a6d5-c219e28534db',
]);
```

Retries
-------

[](#retries)

Transient failures are retried 3 times by default with exponential backoff (250 ms → 1 s → 4 s):

- Network errors (DNS, connect, timeout)
- HTTP 429 (respects `Retry-After`)
- HTTP 502 / 503 / 504

4xx responses (other than 429) are never retried.

Error handling
--------------

[](#error-handling)

Every API error is mapped to a typed exception extending `Zayono\Exceptions\ZayonoException`:

```
use Zayono\Exceptions\{
    AuthenticationException,
    ValidationException,
    RateLimitException,
    ResourceNotFoundException,
    ServerException,
    NetworkException,
};

try {
    $payment = $zayono->payments->create([/* … */]);
} catch (ValidationException $e) {
    foreach ($e->errors as $field => $messages) {
        echo "$field: ", implode(', ', $messages), PHP_EOL;
    }
} catch (AuthenticationException $e) {
    // 401: key revoked / wrong / expired
} catch (RateLimitException $e) {
    sleep($e->retryAfter ?? 1);
} catch (ResourceNotFoundException $e) {
    // 404
} catch (ServerException $e) {
    // 5xx after exhausting retries
} catch (NetworkException $e) {
    // No response received after retries
}
```

Every exception exposes:

- `getStatusCode(): ?int`: HTTP status (when applicable)
- `getErrors(): ?array`: server-side `errors` envelope field
- `getRequestId(): ?string`: `X-Request-Id` header value for support tickets

Logging
-------

[](#logging)

The SDK accepts any PSR-3 logger. Requests log at `info`; 4xx/5xx and retries log at `warning`.

```
use Monolog\Logger;
use Monolog\Handler\StreamHandler;

$log = new Logger('zayono');
$log->pushHandler(new StreamHandler('zayono.log'));

$zayono = new Zayono('zyn_test_xxxxx', logger: $log);
```

PSR-18 / custom HTTP clients
----------------------------

[](#psr-18--custom-http-clients)

Swap Guzzle for any PSR-18 implementation by passing it to the constructor:

```
$zayono = new Zayono(
    apiKey:     'zyn_test_xxxxx',
    httpClient: $myPsr18Client,
);
```

Testing
-------

[](#testing)

```
composer install
composer test
```

License
-------

[](#license)

[MIT](LICENSE) © Zayono

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance90

Actively maintained with recent releases

Popularity1

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

46d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/449e5c09216160f69ce76dc7859e82cc3c4dcf8a3e2399591e10182b7d699556?d=identicon)[RomualdAKM](/maintainers/RomualdAKM)

---

Top Contributors

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

---

Tags

sdkpaymentspayment gatewaymobile-moneyafricazayono

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k16](/packages/tempest-framework)[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.2k543.5M2.7k](/packages/aws-aws-sdk-php)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M754](/packages/sylius-sylius)[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k46](/packages/neuron-core-neuron-ai)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

85036.3k](/packages/flow-php-flow)

PHPackages © 2026

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