PHPackages                             devscast/flexpay - 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. [API Development](/categories/api)
4. /
5. devscast/flexpay

ActiveLibrary[API Development](/categories/api)

devscast/flexpay
================

FlexPay API PHP Client

2.1.1(2mo ago)73.6k3MITPHPPHP &gt;=8.4CI passing

Since May 17Pushed 2mo agoCompare

[ Source](https://github.com/devscast/flexpay-php)[ Packagist](https://packagist.org/packages/devscast/flexpay)[ RSS](/packages/devscast-flexpay/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (7)Dependencies (20)Versions (11)Used By (0)

Flexpay PHP
===========

[](#flexpay-php)

[![Lint](https://github.com/devscast/flexpay/actions/workflows/lint.yaml/badge.svg)](https://github.com/devscast/flexpay/actions/workflows/lint.yaml/badge.svg)[![Test](https://github.com/devscast/flexpay/actions/workflows/test.yaml/badge.svg)](https://github.com/devscast/flexpay/actions/workflows/test.yaml/badge.svg)[![Latest Stable Version](https://camo.githubusercontent.com/745873fd8a76f1f00ddff6cd763f7e2c84343b20da479a204da883977af7166e/68747470733a2f2f706f7365722e707567782e6f72672f64657673636173742f666c65787061792f76657273696f6e)](https://packagist.org/packages/devscast/flexpay)[![Total Downloads](https://camo.githubusercontent.com/4f35dc9c47dd5e483d4d2b03e7921d1197164c52b81ee3e086b4e609bb6864c9/68747470733a2f2f706f7365722e707567782e6f72672f64657673636173742f666c65787061792f646f776e6c6f616473)](https://packagist.org/packages/devscast/flexpay)[![License](https://camo.githubusercontent.com/e09382e5f1c0c78a09e2714ae0a170fe3b586cfa9bb65d3f1f5ab5588ac0fa9f/68747470733a2f2f706f7365722e707567782e6f72672f64657673636173742f666c65787061792f6c6963656e7365)](https://packagist.org/packages/devscast/flexpay)

For privacy reasons, Flexpay original documentation cannot be shared without written permission, for more information about credentials and implementation details, please reach them at flexpay.cd

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

[](#installation)

You can use the PHP client by installing the Composer package and adding it to your application’s dependencies:

```
composer require devscast/flexpay
```

Usage
-----

[](#usage)

### Authentication

[](#authentication)

- **Step 1**. Contact Flexpay to get a Merchant Account You will receive a Merchant Form to complete in order to provide your business details and preferred Cash out Wallet or Banking Details.
- **Step 2**. Once the paperwork is completed, you will be issued with Live and Sandbox Accounts (Merchant Code and Authorization token)

Then use these credentials to authenticate your client

```
use Devscast\Flexpay\Client as Flexpay;
use Devscast\Flexpay\Credential;
use Devscast\Flexpay\Environment;

$flexpay = new Flexpay(
    new Credential('token', 'merchant_code'),
    Environment::SANDBOX // use Environment::LIVE for production
);
```

### Create a Payment Request

[](#create-a-payment-request)

```
use Devscast\Flexpay\Data\Currency;
use Devscast\Flexpay\Request\CardRequest;
use Devscast\Flexpay\Request\MobileRequest;

$mobile = new MobileRequest(
    amount: 10, // 10 USD
    currency: Currency::USD,
    phone: "243999999999",
    reference: "your_unique_transaction_reference",
    description: "your_transaction_description",
    callbackUrl: "your_website_webhook_url",
);

$card = new CardRequest(
    amount: 10, // 10 USD
    currency: Currency::USD,
    reference: "your_unique_transaction_reference",
    description: "your_transaction_description",
    callbackUrl: "your_website_webhook_url",
    homeUrl: "your_website_home_url",
)
```

> **Note**: we highly recommend your `callbacks` urls to be unique for each transaction.

### Mobile Payment

[](#mobile-payment)

Once called, Flexpay will send a payment request to the user's mobile money account, and the user will have to confirm the payment on their phone. after that the payment will be processed and the callback url will be called with the transaction details.

```
$response = $flexpay->pay($mobile);
```

### Visa Card Payment

[](#visa-card-payment)

You can set up card payment via VPOS features, which is typically used for online payments. it's a gateway that allows you to accept payments from your customers using their credit cards.

```
$response = $flexpay->pay($card);
// redirect to $response->url to complete the payment
```

#### **handling callback (callbackUrl, approveUrl, cancelUrl, declineUrl)**

[](#handling-callback-callbackurl-approveurl-cancelurl-declineurl)

Flexpay will send a POST request to the defined callbackUrl and the response will contain the transaction details. you can use the following code to handle the callback by providing incoming data as array.

```
$state = $flexpay->handleCallback($_POST);
$state->isSuccessful(); // true or false
```

### Check Transaction state

[](#check-transaction-state)

You don't trust webhook ? you can always check the transaction state by providing the order number.

```
$state = $flexpay->check($payment->orderNumber);
$state->isSuccessful(); // true or false
```

###  Health Score

51

—

FairBetter than 95% of packages

Maintenance82

Actively maintained with recent releases

Popularity30

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 90% 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

Every ~91 days

Recently: every ~146 days

Total

9

Last Release

89d ago

Major Versions

1.0.1 → 2.0.02024-10-11

PHP version history (2 changes)1.0.0PHP &gt;=8.2

2.1.0PHP &gt;=8.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/31113941?v=4)[Bernard Ngandu](/maintainers/bernard-ng)[@bernard-ng](https://github.com/bernard-ng)

---

Top Contributors

[![bernard-ng](https://avatars.githubusercontent.com/u/31113941?v=4)](https://github.com/bernard-ng "bernard-ng (18 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![rooneyi](https://avatars.githubusercontent.com/u/139772169?v=4)](https://github.com/rooneyi "rooneyi (1 commits)")

---

Tags

apimobile-moneyngandupayment-gatewayapipayment gatewaymobile-moneyflexpay

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StyleECS

Type Coverage Yes

### Embed Badge

![Health badge](/badges/devscast-flexpay/health.svg)

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

###  Alternatives

[sylius/sylius

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

8.5k6.0M777](/packages/sylius-sylius)[craftcms/cms

Craft CMS

3.6k3.7M3.4k](/packages/craftcms-cms)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M236](/packages/sulu-sulu)[api-platform/core

Build a fully-featured hypermedia or GraphQL API in minutes!

2.6k52.2M377](/packages/api-platform-core)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.8M672](/packages/shopware-core)

PHPackages © 2026

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