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

ActiveLibrary[Payment Processing](/categories/payments)

shubhamc4/cgrate-laravel
========================

Laravel package for integrating with CGrate payment service (543 Konse Konse)

2.0.2(10mo ago)342MITPHPPHP ^8.2

Since May 8Pushed 10mo ago1 watchersCompare

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

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

CGrate Laravel Package
======================

[](#cgrate-laravel-package)

[![Latest Version on Packagist](https://camo.githubusercontent.com/a94b4c64f1067653164c5795647952f1cb793576fe6e17a5f6d39e33d8cb2de0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7368756268616d63342f6367726174652d6c61726176656c2e737667)](https://packagist.org/packages/shubhamc4/cgrate-laravel)[![Total Downloads](https://camo.githubusercontent.com/728b123e905228b8ff007a243aa4f4f2dfc1f26f99a5a5bdbbdc5819df815f17/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7368756268616d63342f6367726174652d6c61726176656c2e737667)](https://packagist.org/packages/shubhamc4/cgrate-laravel)[![License](https://camo.githubusercontent.com/b45f2396e9845e5b3ad2cf644bb7fb9ee403a3783936a53b9b327ec6008de1ac/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7368756268616d63342f6367726174652d6c61726176656c2e737667)](https://github.com/shubhamc4/cgrate-laravel/blob/main/LICENSE)

A Laravel package for integrating with the CGrate payment service to process mobile money transactions in Zambia. This package provides a seamless Laravel wrapper around the [cgrate-php](https://github.com/Shubhamc4/cgrate-php) core package.

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

[](#table-of-contents)

- [Introduction](#introduction)
- [Requirements](#requirements)
- [Installation](#installation)
- [Configuration](#configuration)
- [Available Soap Methods](#available-soap-methods)
- [Available Static Helper Methods](#available-static-helper-methods)
- [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)
- [Events](#events)
- [Data Transfer Objects](#data-transfer-objects)
- [Artisan Commands](#artisan-commands)
- [Core PHP Package](#core-php-package)
- [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 Laravel 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
- Laravel 11.0 or higher
- PHP SOAP extension

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

[](#installation)

You can install the package via composer:

```
composer require shubhamc4/cgrate-laravel
```

The package will automatically register its service provider and facade through Laravel's package auto-discovery feature.

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

[](#configuration)

Publish the configuration file:

```
php artisan vendor:publish --provider="CGrate\Laravel\CGrateServiceProvider"
```

This will create a `config/cgrate.php` configuration file in your application where you can modify the settings.

### Environment Variables

[](#environment-variables)

The package requires the following environment variables to be set in your `.env` file:

```
# Required variables
CGRATE_USERNAME=your_username           # Your CGrate account username
CGRATE_PASSWORD=your_password           # Your CGrate account password

# Optional variables (with defaults)
CGRATE_TEST_MODE=true                   # Set to false for production
```

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)

### Getting Account Balance

[](#getting-account-balance)

```
use CGrate\Laravel\Facades\CGrate;

// Get account balance
try {
    $response = CGrate::getAccountBalance();

    if ($response->isSuccessful()) {
        echo 'Account Balance: ' . $response->balance;
    } else {
        echo 'Error: ' . $response->responseMessage;
    }
} catch (\CGrate\Php\Exceptions\CGrateException $e) {
    echo 'API Error: ' . $e->getMessage();
}
```

### Get Available Cash Deposit Issuers

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

```
use CGrate\Laravel\Facades\CGrate;

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

### Processing a Payment

[](#processing-a-payment)

```
use CGrate\Php\DTOs\PaymentRequestDTO;
use CGrate\Laravel\Facades\CGrate;

// Create a payment request
$payment = new PaymentRequestDTO(
    transactionAmount: 10.50,
    customerMobile: '260970000000', // Zambian mobile number format (without the + sign)
    paymentReference: 'INVOICE-123'
);

// Or use the factory method for convenience
$payment = PaymentRequestDTO::create(
    transactionAmount: 10.50,
    customerMobile: '260970000000',
    paymentReference: 'INVOICE-123'
);

// Process the payment
try {
    $response = CGrate::processCustomerPayment($payment);

    if ($response->isSuccessful()) {
        echo 'Payment successful! Payment ID: ' . $response->paymentID;
    } else {
        echo 'Payment failed: ' . $response->responseMessage;
    }
} catch (\CGrate\Php\Exceptions\ValidationException $e) {
    echo 'Validation Error: ' . $e->getMessage();
    foreach ($e->errors() as $field => $errors) {
        echo "\n- {$field}: " . implode(', ', $errors);
    }
} catch (\CGrate\Php\Exceptions\CGrateException $e) {
    echo 'API Error: ' . $e->getMessage();
}
```

### Query Customer Payment

[](#query-customer-payment)

```
use CGrate\Laravel\Facades\CGrate;

// Query transaction status
try {
    $response = CGrate::queryCustomerPayment('INVOICE-123');

    if ($response->isSuccessful()) {
        echo 'Transaction reference: ' . $response->transactionReference;
    } else {
        echo 'Status query failed: ' . $response->responseMessage;
    }
} catch (\CGrate\Php\Exceptions\CGrateException $e) {
    echo 'API Error: ' . $e->getMessage();
}
```

### Process Cash Deposit

[](#process-cash-deposit)

```
use CGrate\Php\DTOs\CashDepositRequestDTO;
use CGrate\Laravel\Facades\CGrate;

$customerAccount = '260970000000';  // Customer account number

// Create a cash deposit request
$cashDeposit = new CashDepositRequestDTO(
    transactionAmount: 10.50,
    customerAccount: $customerAccount,
    issuerName: CGrate::getCustomerIssuerName($customerAccount),
    depositorReference: 'INVOICE-123'
);

// Or use the factory method for convenience
$cashDeposit = CashDepositRequestDTO::create(
    transactionAmount: 10.50,
    customerAccount: $customerAccount,
    issuerName: CGrate::getCustomerIssuerName($customerAccount),
    depositorReference: 'INVOICE-123'
);

try {
    $response = CGrate::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();
}
```

Events
------

[](#events)

The package includes following events that you can dispatch and listen for in your application:

EventDescriptionProperties`PaymentProcessed`Dispatch this when a payment is successful`response` (PaymentResponseDTO), `paymentData` (array)`PaymentFailed`Dispatch this when a payment fails`request` (PaymentRequestDTO), `errorMessage` (string), `responseCode` (ResponseCode or null), `exception` (CGrateException or null)`CashDeposit`Dispatch this when a cash deposit is successful`response` (CashDepositResponse), `cashDepositData` (array)Data Transfer Objects
---------------------

[](#data-transfer-objects)

The package uses DTOs to handle API requests and responses:

### Request DTOs

[](#request-dtos)

- `PaymentRequestDTO`: Contains payment request data (transactionAmount, customerMobile, paymentReference)

### Response DTOs

[](#response-dtos)

- `BalanceResponseDTO`: Contains account balance information
- `PaymentResponseDTO`: Contains payment response information
- `CashDepositResponse`: Contains payment reversal response information

Artisan Commands
----------------

[](#artisan-commands)

The package provides the following Artisan commands:

```
php artisan cgrate:balance
```

This command will check your account balance and display it in the console.

Core PHP Package
----------------

[](#core-php-package)

This Laravel package is a wrapper around the [cgrate-php](https://github.com/Shubhamc4/cgrate-php) core package. The core package handles all the low-level SOAP API interactions, request validation, and response parsing.

If you need to use CGrate with a non-Laravel PHP application, you can use the core package directly. See the [cgrate-php repository](https://github.com/Shubhamc4/cgrate-php) for documentation on direct usage.

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

34

—

LowBetter than 77% of packages

Maintenance55

Moderate activity, may be stable

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

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

PHP version history (2 changes)1.0.0PHP ^8.1

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 (7 commits)")[![shubhamc04](https://avatars.githubusercontent.com/u/165019453?v=4)](https://github.com/shubhamc04 "shubhamc04 (4 commits)")

---

Tags

phplaravelpackagelibrarysoapKonse Konsecgrate payment service543 payment service

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[threesquared/laravel-paymill

Laravel wrapper for the Paymill API

121.3k](/packages/threesquared-laravel-paymill)

PHPackages © 2026

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