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

ActiveLibrary[Payment Processing](/categories/payments)

shubhamc4/cgrate-php
====================

Core PHP package for integrating with CGrate payment service (543 Konse Konse)

2.0.2(10mo ago)3401MITPHPPHP ^8.2

Since May 9Pushed 10mo ago1 watchersCompare

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

READMEChangelog (4)DependenciesVersions (5)Used By (1)

CGrate PHP Package
==================

[](#cgrate-php-package)

[![Latest Version on Packagist](https://camo.githubusercontent.com/8f07f9759b3fabe9948fa951d11c6c7499938d8378890b87814eabf936f38431/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7368756268616d63342f6367726174652d7068702e737667)](https://packagist.org/packages/shubhamc4/cgrate-php)[![Total Downloads](https://camo.githubusercontent.com/3606496f5db9ae2f3adb7b216731b66644952db93102170f586f51702910c40b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7368756268616d63342f6367726174652d7068702e737667)](https://packagist.org/packages/shubhamc4/cgrate-php)[![License](https://camo.githubusercontent.com/e76ded095453403f8f2f7bfa047016a7d046361d586b4267959dfa69990654f7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7368756268616d63342f6367726174652d7068702e737667)](https://github.com/shubhamc4/cgrate-php/blob/main/LICENSE)

A Core PHP package for integrating with the CGrate payment service to process mobile money transactions in Zambia.

Table of Contents
-----------------

[](#table-of-contents)

- [Introduction](#introduction)
- [Requirements](#requirements)
- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
    - [Check Account Balance](#check-account-balance)
    - [Get Available Cash Deposit Issuers](#get-available-cash-deposit-issuers)
    - [Process Customer Payment](#process-customer-payment)
    - [Query Customer Payment](#query-customer-payment)
    - [Process Cash Deposit](#process-cash-deposit)
    - [Generate Transaction Reference](#generate-transaction-reference)
    - [Get Customer Account Issuer Name](#get-customer-issuer-name)
- [Data Transfer Objects](#data-transfer-objects)
- [Response Codes](#response-codes)
- [Changelog](#changelog)
- [Credits](#credits)
- [License](#license)

Introduction
------------

[](#introduction)

[CGrate](https://cgrate.co.zm) ([543 Konse Konse](https://www.543.co.zm)) is a payment service provider based in Zambia that facilitates mobile money transactions. This Core PHP package allows businesses to:

- Process payments from mobile money accounts
- Check account balances in real-time
- Verify transaction status
- Reverse/refund payments when necessary

The service operates via a SOAP API that requires WS-Security authentication. CGrate is widely used for integrating with local payment systems in Zambia, making it easier for businesses to accept mobile payments from customers.

For more information about CGrate payment service, visit their [official website](https://cgrate.co.zm) or contact their support team at .

### Official Documentation

[](#official-documentation)

For detailed information on the CGrate SOAP API, including setup instructions, request formats, and response codes, please refer to the official [EVDSpec 2024.pdf](./docs/EVDSpec_2024.pdf) document. This comprehensive guide provides all the technical specifications required for integrating with the CGrate service.

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

[](#requirements)

- PHP 8.2 or higher
- PHP SOAP extension

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

[](#installation)

```
composer require shubhamc4/cgrate-php
```

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

[](#configuration)

```
$config = [
    'username' => 'your-username',  // Required
    'password' => 'your-password',  // Required
    'endpoint' => 'https://543.cgrate.co.zm/Konik/KonikWs?wsdl',  // Production endpoint
    'testEndpoint' => 'http://test.543.cgrate.co.zm:55555/Konik/KonikWs?wsdl',  // Test endpoint
    'testMode' => false,  // Set to true for test environment
    'options' => [  // SOAP client options
        'soap_version' => SOAP_1_1,
        'connection_timeout' => 30,
        'keep_alive' => false,
        'cache_wsdl' => WSDL_CACHE_NONE,
        'exceptions' => true,
        'trace' => false,  // Set to true for test environment
    ],
];

$client = new \CGrate\Php\Services\CGrateService($config);
```

Alternatively, you can use the config helper:

```
use CGrate\Php\Config\CGrateConfig;
use CGrate\Php\Services\CGrateService;

// Create config with username, password and test mode (optional)
$config = CGrateConfig::create(
    username: 'your-username',
    password: 'your-password',
    testMode: true
);
$client = new CGrateService($config);
```

Available Soap Methods
----------------------

[](#available-soap-methods)

MethodDescription`getAccountBalance()`Get the account balance`getAvailableCashDepositIssuers()`Get Available Cash Deposit Issuers`processCustomerPayment(PaymentRequestDTO $payment)`Process a new customer payment`queryCustomerPayment(string $transactionReference)`Check the status of a customer payment`processCashDeposit(string $paymentReference)`Process Cash DepositAvailable Static Helper Methods
-------------------------------

[](#available-static-helper-methods)

MethodDescription`generateTransactionReference(string $prefix = 'CG')`Generate a unique transaction reference`getCustomerIssuerName(string $customerAccount)`Get Customer Account Issuer NameUsage
-----

[](#usage)

### Check Account Balance

[](#check-account-balance)

```
try {
    $response = $client->getAccountBalance();

    if ($response->isSuccessful()) {
        echo "Balance: " . $response->displayBalance();
    } else {
        echo "Error: " . $response->responseMessage;
    }
} catch (\CGrate\Php\Exceptions\CGrateException $e) {
    echo "Exception: " . $e->getMessage();
}
```

### Get Available Cash Deposit Issuers

[](#get-available-cash-deposit-issuers)

```
try {
    $response = $client->getAvailableCashDepositIssuers();
    print_r($response);
} catch (\CGrate\Php\Exceptions\CGrateException $e) {
    echo "Exception: " . $e->getMessage();
}
```

### Process Customer Payment

[](#process-customer-payment)

```
try {
    $payment = new \CGrate\Php\DTOs\PaymentRequestDTO(
        10.50,  // Amount
        '260970000000',  // Customer mobile number
        'PAYMENT-' . time()  // Unique payment reference
    );

    $response = $client->processCustomerPayment($payment);

    if ($response->isSuccessful()) {
        echo "Payment ID: " . $response->paymentID;
    } else {
        echo "Payment failed: " . $response->responseMessage;
    }
} catch (\CGrate\Php\Exceptions\CGrateException $e) {
    echo "Exception: " . $e->getMessage();
}
```

### Query Customer Payment

[](#query-customer-payment)

```
try {
    $response = $client->queryCustomerPayment('YOUR-TRANSACTION-REFERENCE');

    if ($response->isSuccessful()) {
        echo "Transaction status: " . $response->responseMessage;
    } else {
        echo "Query failed: " . $response->responseMessage;
    }
} catch (\CGrate\Php\Exceptions\CGrateException $e) {
    echo "Exception: " . $e->getMessage();
}
```

### Process Cash Deposit

[](#process-cash-deposit)

```
try {
    $customerAccount = '260970000000';  // Customer mobile number
    $cashDeposit = new \CGrate\Php\DTOs\CashDepositRequestDTO(
        10.50,  // Amount
        $customerAccount,
        \CGrate\Php\Services\CGrateService::getCustomerIssuerName($customerAccount),
        'CD-' . time()  // Unique cash deposit reference
    );

    $response = $client->processCashDeposit($cashDeposit);

    if ($response->isSuccessful()) {
        echo "Depositor reference: " . $response->depositorReference;
    } else {
        echo "Cash deposit failed: " . $response->responseMessage;
    }
} catch (\CGrate\Php\Exceptions\CGrateException $e) {
    echo "Exception: " . $e->getMessage();
}
```

### Generate Transaction Reference

[](#generate-transaction-reference)

```
// Generate a reference with the default prefix 'CG'
$reference = \CGrate\Php\Services\CGrateService::generateTransactionReference();
// Result: CG-1714504562-a1b2c3d4e5f6

// Generate a reference with a custom prefix
$reference = \CGrate\Php\Services\CGrateService::generateTransactionReference('ORDER');
// Result: ORDER-1714504562-a1b2c3d4e5f6
```

### Get Customer Account Issuer Name

[](#get-customer-account-issuer-name)

```
// Get issuer name using the the customer account

$issuerName = \CGrate\Php\Services\CGrateService::getCustomerIssuerName('26097XXXXXXX');
// Result: Airtel

$issuerName = \CGrate\Php\Services\CGrateService::getCustomerIssuerName('26076XXXXXXX');
// Result: MTN

$issuerName = \CGrate\Php\Services\CGrateService::getCustomerIssuerName('26095XXXXXXX');
// Result: Zamtel

$issuerName = \CGrate\Php\Services\CGrateService::getCustomerIssuerName('26065XXXXXXX');
// Result: Unknown Issuer
```

Data Transfer Objects
---------------------

[](#data-transfer-objects)

The package uses read-only DTOs to handle API requests and responses:

### Request DTOs

[](#request-dtos)

- `PaymentRequestDTO`: Contains payment request data (transactionAmount, customerMobile, paymentReference)
- `CashDepositRequestDTO`: Contains cash deposit request data (transactionAmount, customerAccount, issuerName, depositorReference)

### Response DTOs

[](#response-dtos)

- `BalanceResponseDTO`: Contains account balance information
- `PaymentResponseDTO`: Contains payment response information
- `CashDepositResponseDTO`: Contains cash deposit response information

Response Codes
--------------

[](#response-codes)

The package includes a comprehensive `ResponseCode` enum that provides all possible response codes from the CGrate API along with their descriptions:

```
use CGrate\Php\Enums\ResponseCode;

// Check if a response matches a specific code
if ($response->responseCode->is(ResponseCode::SUCCESS)) {
    // Handle successful response
}

// Get the description for any response code
$description = ResponseCode::descriptionFromValue(0); // "Success"
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Credits
-------

[](#credits)

- [Shubham Chaudhary](https://github.com/shubhamc4)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance55

Moderate activity, may be stable

Popularity12

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 54.5% 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 ~22 days

Total

4

Last Release

301d ago

Major Versions

1.0.0 → 2.0.02025-05-12

PHP version history (2 changes)1.0.0PHP ^7.4

2.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/4df3986ee2b0216b86805e5234dc7bff68c91b60b8f7568750e1e7996a9c7018?d=identicon)[shubhamc04](/maintainers/shubhamc04)

---

Top Contributors

[![Shubhamc4](https://avatars.githubusercontent.com/u/71214613?v=4)](https://github.com/Shubhamc4 "Shubhamc4 (6 commits)")[![shubhamc04](https://avatars.githubusercontent.com/u/165019453?v=4)](https://github.com/shubhamc04 "shubhamc04 (5 commits)")

---

Tags

phplibrarysoapKonse Konsecgrate payment service543 payment service

### Embed Badge

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

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

###  Alternatives

[cartalyst/stripe-laravel

Laravel 11 integration for the Cartalyst Stripe package.

3382.6M9](/packages/cartalyst-stripe-laravel)[cryptonator/merchant-php-sdk

Cryptonator.com Merchant API SDK for PHP

2713.7k](/packages/cryptonator-merchant-php-sdk)

PHPackages © 2026

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