PHPackages                             mouadziani/laravel-mercanet - 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. mouadziani/laravel-mercanet

ActiveLibrary

mouadziani/laravel-mercanet
===========================

A laravel wrapper for BnpParibas Mercanet payment gateway

v1.3.0(4y ago)33354MITPHPPHP ^7.4.0|^8.0

Since Sep 25Pushed 1y ago4 watchersCompare

[ Source](https://github.com/MouadZIANI/laravel-mercanet)[ Packagist](https://packagist.org/packages/mouadziani/laravel-mercanet)[ Docs](https://github.com/mouadziani/laravel-mercanet)[ GitHub Sponsors](https://github.com/mouadziani)[ RSS](/packages/mouadziani-laravel-mercanet/feed)WikiDiscussions main Synced 1mo ago

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

 [![Logo Laravel Mercanet](/art/banner.png)](/art/banner.png)

Laravel Mercanet
================

[](#laravel-mercanet)

A laravel wrapper for [BnpParibas Mercanet](https://mabanquepro.bnpparibas/fr/notre-offre-pro/comptes-cartes-et-services/solutions-d-encaissement/encaissement-internet-et-mobile/offre-e-commerce-mercanet) which provide a lightweight public api to process your online payments from your laravel application.

[![License](https://camo.githubusercontent.com/a9e8b09b2abe4cdc102c4a5ef5c63975f6c77b3aea13722aad628256c0b04d22/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d6f7561647a69616e692f6c61726176656c2d6d657263616e6574)](https://camo.githubusercontent.com/a9e8b09b2abe4cdc102c4a5ef5c63975f6c77b3aea13722aad628256c0b04d22/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d6f7561647a69616e692f6c61726176656c2d6d657263616e6574)

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

[](#installation)

You can install the package via composer:

```
composer require mouadziani/laravel-mercanet
```

You can publish the config file with:

```
php artisan vendor:publish --provider="Mouadziani\Mercanet\MercanetServiceProvider"
```

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

[](#configuration)

As a first step, you need to change the following credentials located in the `config/mercanet.php` file, with your own credentials given from your mercanet account.

```
return [
    /**
     * Can only be 'TEST' Or 'Production'. If empty or invalid, 'TEST' will be used.
     */
    'mode' => env('MERCANET_MODE', 'TEST'),

    // Credentials of testing environment
    'test' => [
        'merchant_id' => env('MERCANET_TEST_MERCHANT_ID', ''), // Required
        'key_version' => env('MERCANET_TEST_KEY_VERSION', '1'),
        'secret_key' => env('MERCANET_TEST_SECRET_KEY', ''), // Required
    ],

    // Credentials of production environment
    'production' => [
        'merchant_id' => env('MERCANET_PRODUCTION_MERCHANT_ID', ''), // Required
        'key_version' => env('MERCANET_PRODUCTION_KEY_VERSION', '1'), // Required
        'secret_key' => env('MERCANET_PRODUCTION_SECRET_KEY', ''), // Required
    ],

    'currency' => env('MERCANET_CURRENCY', 'EUR'),

    // Should be replaced with a url of your callback post route,
    // which will be invoked by mercanet service after processing of any payment.
    'normal_return_url' => env('MERCANET_NORMAL_RETURN_URL', 'https://example.com/payments/callback'),

    /**
    * You can set the default locale that you need to be used to translate the mercanet payment page
     * Allowed languages 'nl', 'fr', 'de', 'it', 'es', 'cy', 'en'
     */
    'language' => env('MERCANET_LOCALE', 'en'),
];
```

Usage
-----

[](#usage)

Following are some ways through which you can bootstrap the process of payment:

```
// Import the class namespaces first, before using it directly
use Mouadziani\Mercanet\Mercanet;

// You can either create new instance from Mercanet
$mercanet = new Mercanet();

// Or through static constructor boot.
$mercanet = Mercanet::boot();
```

### Prepare and process payment request

[](#prepare-and-process-payment-request)

In order to process new payment you need to call `newPaymentRequest()` from the existing mercanet instance and then set the following arguments

```
$mercanet->newPaymentRequest();

// Required
$mercanet->setTransactionReference('123456789');

// By default the currency used is EUR. If you wish to change it,
// you may call setCurrency method to set a different currency before calling pay() method
$mercanet->setCurrency('EUR');

// Optionally, You can also call setLanguage method to change the default locale of payment page
$mercanet->setLanguage('fr');

// Required and it should be integer
// Make sure to multiply the original amount * 100 (eg: 199.00 * 100 = 19000)
$mercanet->setAmount(19000);

// Optional
$mercanet->setBillingContactFirstname('John');

 // Optional
$mercanet->setBillingContactLastname('Doe');

 // Optional
$mercanet->setCustomerContactEmail('john@doe.com');

// Then you can call pay() method to redirect user to the payment page of mercanet website.
$mercanet->pay();
```

Instead of creation new instance from Mercanet class and call method separately on it, you can use also the static constructor as the following example:

```
use Mouadziani\Mercanet\Mercanet;

Mercanet::boot()
    ->newPaymentRequest()
    ->setTransactionReference('123456789')
    ->setCurrency('EUR')
    ->setLanguage('fr')
    ->setAmount(19000)
    ->setBillingContactFirstname('John')
    ->setBillingContactLastname('Doe')
    ->setCustomerContactEmail('john@doe.com')
    ->pay();
```

### Validate payment transaction from callback request

[](#validate-payment-transaction-from-callback-request)

In order to retrieve transaction reference and payment status from the given callback request, you can use the following methods.

```
use Mouadziani\Mercanet\Mercanet;

// Create new instance or call the static constructor from Mercanet class
// and then call fromRequest() method and pass request parameters into it.
$paymentResponse = Mercanet::boot()->fromResponse(request()->all());

// Then you can check if the given payment response is successfully passed by calling isSuccessfullyPassed() method
if($paymentResponse->isSuccessfullyPassed()) {
    // The payment is accepted.

    // You can get the transaction reference from the initialized payment request object
    $transactionReference = $paymentResponse->getTransactionReference();

    // Then you can do what you want, eg. change the status of the order related to the transaction reference, or mark it as paid...
    App\Order::query()
        ->where('transaction_reference', $transactionReference)
        ->update([
            'is_paid' => true
        ]);
} else {
    // The payment is failed
}
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

Credits
-------

[](#credits)

- [MouadZIANI](https://github.com/mouadziani)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

Sponsors
--------

[](#sponsors)

    [ ![](https://user-images.githubusercontent.com/15586492/96636404-2c18dd00-1315-11eb-9520-736dffaaf0a7.png) ](https://www.jetbrains.com/?from=https://github.com/mouadziani)   featured\_repository

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance26

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 97.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 ~14 days

Total

4

Last Release

1647d ago

PHP version history (2 changes)v1.0PHP ^7.4.0

v1.2.0PHP ^7.4.0|^8.0

### Community

Maintainers

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

---

Top Contributors

[![mouadziani](https://avatars.githubusercontent.com/u/29683939?v=4)](https://github.com/mouadziani "mouadziani (41 commits)")[![achrafjdily](https://avatars.githubusercontent.com/u/42965792?v=4)](https://github.com/achrafjdily "achrafjdily (1 commits)")

---

Tags

laravelmercanetpayment-gatewayphplaravelmercanetlaravel-mercanet

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/mouadziani-laravel-mercanet/health.svg)

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

###  Alternatives

[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[spatie/laravel-prometheus

Export Laravel metrics to Prometheus

2651.3M6](/packages/spatie-laravel-prometheus)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)[scalar/laravel

Render your OpenAPI-based API reference

6183.9k2](/packages/scalar-laravel)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)[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)

PHPackages © 2026

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