PHPackages                             hachchadi/cmi-payment - 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. hachchadi/cmi-payment

ActiveLibrary[Payment Processing](/categories/payments)

hachchadi/cmi-payment
=====================

A Laravel package for CMI payment integration

v1.0.2(1y ago)124MITPHPPHP &gt;=8.0

Since Jul 12Pushed 1y ago1 watchersCompare

[ Source](https://github.com/hachchadi/CmiPayment)[ Packagist](https://packagist.org/packages/hachchadi/cmi-payment)[ Docs](https://github.com/hachchadi/cmi-payment)[ RSS](/packages/hachchadi-cmi-payment/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

CmiPayment Laravel Package
==========================

[](#cmipayment-laravel-package)

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

[](#introduction)

This Laravel package integrates the CMI (Centre Monétique Interbancaire) payment gateway into your Laravel application. It provides convenient methods to initiate payments, generate hashes, and check the status of orders.

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

[](#installation)

You can install the package via Composer. Run the following command:

```
composer require hachchadi/cmi-payment
```

Next, publish the configuration file:

```
php artisan vendor:publish --provider="Hachchadi\CmiPayment\CmiPaymentServiceProvider"
```

This command will publish the cmi.php configuration file in your config directory.

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

[](#configuration)

Update your .env file with the necessary CMI configuration values:

```
CMI_CLIENT_ID=your_cmi_client_id
CMI_STORE_KEY=your_cmi_store_key
CMI_BASE_URI=https://testpayment.cmi.co.ma/fim/est3Dgate
CMI_OK_URL=https://your-app.com/payment/success
CMI_FAIL_URL=https://your-app.com/payment/failure
CMI_CALLBACK_URL=https://your-app.com/payment/callback
CMI_SHOP_URL=(https://your-app.com)
```

For checking order status via the CMI API, add the following to your .env:

```
CMI_BASE_URI_API=https://testpayment.cmi.co.ma/fim/api
CMI_API_CREDENTIALS_NAME=your_cmi_name
CMI_API_CREDENTIALS_PASSWORD=your_cmi_password
CMI_API_CREDENTIALS_CLIENT_ID=your_cmi_client_id
```

Modify config/cmi.php directly if you prefer hardcoding values or need to adjust defaults.

Usage
-----

[](#usage)

### 1. Process Payment

[](#1-process-payment)

You can initiate a payment using the CmiClient class. Here's an example of processing a payment in a controller:

```
use Illuminate\Http\Request;
use Hachchadi\CmiPayment\CmiClient;

class PaymentController extends Controller
{
    public function processPayment(Request $request, CmiClient $cmiClient)
    {
        try {
            $data = [
                'amount' => $request->input('amount'),
                'currency' => $request->input('currency'),
                'oid' => $request->input('orderid'),
                'email' => $request->input('email'),
                'billToName' => $request->input('billToName'),
                // Add other required fields as needed
            ];

            // Process the payment
            $cmiClient->processPayment($data);

        } catch (\Exception $e) {
            // Handle any exceptions
            return response()->json(['error' => $e->getMessage()], 500);
        }
    }
}
```

### 2. Check Order Status

[](#2-check-order-status)

To check the status of an order using the CMI API, use the getCmiStatus method in your controller:

```
use Hachchadi\CmiPayment\CmiClient;

class OrderController extends Controller
{
    public function checkOrderStatus($orderId, CmiClient $cmiClient)
    {
        try {
            $status = $cmiClient->getCmiStatus($orderId);

            // Handle status response
            return response()->json(['status' => $status]);

        } catch (\Exception $e) {
            // Handle any exceptions
            return response()->json(['error' => $e->getMessage()], 500);
        }
    }
}
```

### 3. Validating the Response Hash

[](#3-validating-the-response-hash)

```
use Hachchadi\CmiPayment\CmiClient;
use Hachchadi\CmiPayment\Exceptions\InvalidResponseHash;

public function handleCallback(Request $request)
{
    try {
        $responseData = $request->all();

        if ($responseData) {

            // Validate the hash
            $isValid = $this->cmiClient->validateHash($responseData);

            if ($isValid && $_POST['ProcReturnCode'] == '00') {
                $response = 'ACTION=POSTAUTH';
            } else {
                $response = 'FAILURE';
            }
        } else {
            $response = 'No Data POST';
        }

        return $response;

    } catch (InvalidResponseHash $e) {
        Log::error($e->getMessage());
    }
}
```

Important Notes
---------------

[](#important-notes)

#### Ensure your `.env` file is properly configured with your CMI credentials and URLs.

[](#ensure-your-env-file-is-properly-configured-with-your-cmi-credentials-and-urls)

#### Customize the CMI configuration in `config/cmi.php` as per your integration requirements.

[](#customize-the-cmi-configuration-in-configcmiphp-as-per-your-integration-requirements)

#### Handle exceptions and error responses appropriately in your application to provide a smooth payment experience for users.

[](#handle-exceptions-and-error-responses-appropriately-in-your-application-to-provide-a-smooth-payment-experience-for-users)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

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

669d ago

### Community

Maintainers

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

---

Top Contributors

[![hachchadi](https://avatars.githubusercontent.com/u/32658825?v=4)](https://github.com/hachchadi "hachchadi (10 commits)")

---

Tags

laravelcmi paymenthachchadi

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/hachchadi-cmi-payment/health.svg)

```
[![Health](https://phpackages.com/badges/hachchadi-cmi-payment/health.svg)](https://phpackages.com/packages/hachchadi-cmi-payment)
```

###  Alternatives

[sebdesign/laravel-viva-payments

A Laravel package for integrating the Viva Payments gateway

4845.9k](/packages/sebdesign-laravel-viva-payments)[luigel/laravel-paymongo

A laravel wrapper for Paymongo API

7956.2k1](/packages/luigel-laravel-paymongo)[musahmusah/laravel-multipayment-gateways

A Laravel Package that makes implementation of multiple payment Gateways endpoints and webhooks seamless

852.2k1](/packages/musahmusah-laravel-multipayment-gateways)[henryejemuta/laravel-monnify

A laravel package to seamlessly integrate monnify api within your laravel application

132.1k](/packages/henryejemuta-laravel-monnify)

PHPackages © 2026

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