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

ActiveLibrary

blessdarah/php-campay
=====================

PHP package wrapper for campay momo integration

1.0.0(10mo ago)5122↓100%2MITPHP

Since Sep 27Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/blessdarah/php-campay)[ Packagist](https://packagist.org/packages/blessdarah/php-campay)[ RSS](/packages/blessdarah-php-campay/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (5)Versions (5)Used By (0)

PHP Campay
==========

[](#php-campay)

This is a php wrapper for the campay API that enables a seemless integration of momo with PHP and Campay.

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

[](#requirements)

This package works as from `php@7.4` and above. Ensure that you have the latest version of php installed.

How to install this package
---------------------------

[](#how-to-install-this-package)

To install this package, run:

```
composer require blessdarah/php-campay
```

Usage
-----

[](#usage)

The package automatically manages your tokens for all transactions with campay.

### Configuration

[](#configuration)

This packages uses the `dotenv` package and thus if you're not using something like laravel which automatically loads env variables, you can set it up like this:

1. Create a `.env` file in the root of your project if you don't already have one
2. Copy your application `username` and `password` from your campay dashboard and add them like this:

```
CAMPAY_USERNAME="YOUR CAMPAY APPLICATION USERNAME"
CAMPAY_PASSWORD="YOUR CAMPAY APPLICATION PASSWORD"
```

3. In your `index.php` file or your root application entry point, you have to load up the `dotenv` package

```
require_once "vendor/autoload.php";
use BlessDarah\PhpCampay\Campay;
use Dotenv\Dotenv;

$dotenv = Dotenv::createImmutable(__DIR__);
$dotenv->load();
```

If you're not using composer, you can ignore the above steps and set up your `.env` vars using the php global `$_ENV` to setup your campay configurations in the location you want as follows:

```
$_ENV['CAMPAY_USERNAME']="YOUR CAMPAY APPLICATION USERNAME"
$_ENV['CAMPAY_PASSWORD']="YOUR CAMPAY APPLICATION PASSWORD"
```

Configure campay base url

```
$_ENV['CAMPAY_BASE_URL']="https://demo.campay.net/api/" # for local testing or
$_ENV['CAMPAY_BASE_URL']="https://campay.net/api/" # for production
```

> **Remark**: You should make sure that you don't expose your config variables online as it will be a potential security issue for your application

### Collect payment

[](#collect-payment)

```
use BlessDarah\PhpCampay\Campay;

$campay = new Campay();

$data = array(
    "amount" => 3,
    "currency" => "XAF",
    "from" => "237******",
    "description" => "test payment"
);
$res = $campay->collect($data);
// handle your response data from here
echo $res;
```

### Withdraw funds

[](#withdraw-funds)

For withdrawal, we use the **withdraw** function

```
use BlessDarah\PhpCampay\Campay;

$campay = new Campay();

$data = array(
    "amount" => 3,
    "currency" => "XAF",
    "to" => "237******",
    "description" => "test payment"
);
$res = $campay->withdraw($data);
echo $res;
```

The above response contains the info and the `reference` for your transaction that will enable you check its status using the `getTransactionStatus` function

### Check transaction status

[](#check-transaction-status)

For checking transaction status after using the `collect` or the `withdraw` functions, you can pass the resulting reference key in order to check your transaction status

```
use BlessDarah\PhpCampay\Campay;

$campay = new Campay();

/*
* Suppose you have carried out a collection request from user then you can
* collection logic here
* /
$ref = $res->reference; // e.g: b1d44bc7-648d-451b-a3ef-c5807738ec82

$transaction_feedback = $campay->getTransactionStatus($ref) /* your reference code */

if($transaction_feedback->status == 'SUCCESSFUL')
{
    /* success logic here */
}

if($transaction_feedback->status == 'PENDING')
{
    /* Pending logic here */
}

if($transaction_feedback->status == 'FAILED')
{
    /* Erro logic here */
}
```

### Get your application balance

[](#get-your-application-balance)

```
use BlessDarah\PhpCampay\Campay;

$campay = new Campay();
$res = $campay->getAppBalance();

// handle your response data from here
echo $res;
```

### Get transaction history with an interval

[](#get-transaction-history-with-an-interval)

By default, your transaction history will return all your app's transactions for the past **7 days** or past week

```
use BlessDarah\PhpCampay\Campay;

$campay = new Campay();
$res = $campay->transactionHistory();

// handle your response data from here
echo $res;
```

If you want the dates to be specific, you can pass your `start` and `end` dates like so:

```
$start_date = new Date("2022-06-13");
$end_date = new Date("2022-08-13");

$res = $campay->transactionHistory($start_date, $end_date);
```

### Generate payment link

[](#generate-payment-link)

As per the campay documentation, you can generate a payment link or url that can be utilized for payments. Here's how you do it:

```
use BlessDarah\PhpCampay\Campay;

$campay = new Campay();

$params = [
    "amount" => 4,
    "currency" => "XAF",
    "description" => "Sample description",
    "first_name" =>  "John",
    "last_name" =>  "Doe",
    "email" => "example@mail.com",
    "external_reference" =>  "",
    "redirect_url" =>  "https://example.com",
    "failure_redirect_url" => "https://example.com",
    "payment_options" => "MOMO" // or CARD for credit card payments
];
$res = $campay->generatePaymentUrl($params);

// handle your response data from here
echo $res;
```

###  Health Score

37

—

LowBetter than 82% of packages

Maintenance60

Regular maintenance activity

Popularity20

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity49

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

310d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/cd704f513d1b2f0c70d8ad3099c683820ad480b0276db7b98dada3f8cd9e6b1f?d=identicon)[blessdarah](/maintainers/blessdarah)

---

Top Contributors

[![blessdarah](https://avatars.githubusercontent.com/u/30869302?v=4)](https://github.com/blessdarah "blessdarah (38 commits)")

###  Code Quality

TestsPest

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[laravel/framework

The Laravel Framework.

34.6k509.9M16.9k](/packages/laravel-framework)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[ashallendesign/laravel-exchange-rates

A wrapper package for interacting with the exchangeratesapi.io API.

485677.8k](/packages/ashallendesign-laravel-exchange-rates)[tempest/framework

The PHP framework that gets out of your way.

2.1k23.1k9](/packages/tempest-framework)[concrete5/core

Concrete core subtree split

19159.3k48](/packages/concrete5-core)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

7310.3k29](/packages/open-dxp-opendxp)

PHPackages © 2026

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