PHPackages                             nikba/laravel-maib - 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. nikba/laravel-maib

ActiveLibrary[Payment Processing](/categories/payments)

nikba/laravel-maib
==================

Laravel 12 integration for the maib e-Commerce API — all payment types, token management, and webhook handling.

v1.0.0(3mo ago)121MITPHPPHP ^8.2

Since Mar 15Pushed 3mo agoCompare

[ Source](https://github.com/Nikba-Creative-Studio/Laravel-Maib)[ Packagist](https://packagist.org/packages/nikba/laravel-maib)[ Docs](https://github.com/Nikba-Creative-Studio/Laravel-Maib)[ RSS](/packages/nikba-laravel-maib/feed)WikiDiscussions main Synced 3w ago

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

laravel-maib
============

[](#laravel-maib)

 [![Nikba Creative Studio](logo.svg)](logo.svg)

[![Latest Version on Packagist](https://camo.githubusercontent.com/a486e0f1ad103ed4719f8650f76094ec24c3a6c261e980df4c26bd1da008ad5c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e696b62612f6c61726176656c2d6d6169622e737667)](https://packagist.org/packages/nikba/laravel-maib)[![License](https://camo.githubusercontent.com/872baf477fd9e5a5e10c33cc8f466c3224fc4a817f79c4dfebf23f269556f0f2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6e696b62612f6c61726176656c2d6d6169622e737667)](LICENSE)

A Laravel 12 package for the **maib e-Commerce API** — full coverage of all payment types, automatic token management, and HMAC-SHA256 callback webhook handling.

**API documentation:**

---

Features
--------

[](#features)

- Direct payment (one-step charge)
- Two-step payment (hold → capture or cancel)
- Recurring payments (register card + server-side execute)
- One-click payments (register card + redirect execute)
- Payment refund (partial or full)
- Payment information query
- Saved card deletion
- Callback webhook handling with HMAC-SHA256 signature validation
- Laravel Events dispatched on successful/failed callbacks
- Automatic Bearer token generation, caching, and refresh
- Full PHPUnit test suite

---

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

[](#requirements)

VersionPHP`^8.2`Laravel`^12.0`---

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

[](#installation)

```
composer require nikba/laravel-maib
```

### Publish the configuration

[](#publish-the-configuration)

```
php artisan vendor:publish --tag=maib-config
```

### Environment variables

[](#environment-variables)

Add the following to your `.env` file:

```
MAIB_PROJECT_ID=your-project-id
MAIB_PROJECT_SECRET=your-project-secret
MAIB_SIGNATURE_KEY=your-signature-key
MAIB_ENV=sandbox
MAIB_CALLBACK_ROUTE=/maib/callback
```

Credentials are available in [maibmerchants.md](https://maibmerchants.md) under your project settings.

---

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

[](#configuration)

After publishing, edit `config/maib.php`:

```
return [
    'project_id'     => env('MAIB_PROJECT_ID'),
    'project_secret' => env('MAIB_PROJECT_SECRET'),
    'signature_key'  => env('MAIB_SIGNATURE_KEY'),
    'environment'    => env('MAIB_ENV', 'production'),
    'base_url'       => 'https://api.maibmerchants.md/v1',
    'callback_route' => env('MAIB_CALLBACK_ROUTE', '/maib/callback'),
    'cache_driver'   => env('MAIB_CACHE_DRIVER', null),
    'cache_prefix'   => 'maib_token',
];
```

---

Usage
-----

[](#usage)

### Direct Payment

[](#direct-payment)

```
use Nikba\LaravelMaib\Facades\Maib;
use Nikba\LaravelMaib\Dto\Requests\DirectPaymentRequest;
use Nikba\LaravelMaib\Dto\PaymentItem;
use Nikba\LaravelMaib\Enums\Currency;
use Nikba\LaravelMaib\Enums\Language;

$response = Maib::directPayment(
    new DirectPaymentRequest(
        amount:      99.99,
        currency:    Currency::MDL,
        clientIp:    $request->ip(),
        language:    Language::RO,
        orderId:     'ORDER-001',
        description: 'Order #001',
        callbackUrl: route('maib.callback'),
        okUrl:       route('payment.success'),
        failUrl:     route('payment.fail'),
        items: [
            new PaymentItem(id: '1', name: 'Product A', price: 99.99, quantity: 1),
        ],
    )
);

return redirect($response->payUrl);
```

### Two-Step Payment (Hold → Capture)

[](#two-step-payment-hold--capture)

```
use Nikba\LaravelMaib\Dto\Requests\CapturePaymentRequest;
use Nikba\LaravelMaib\Dto\Requests\HoldPaymentRequest;

// Step 1: Hold
$hold = Maib::hold(new HoldPaymentRequest(
    amount:   99.99,
    currency: Currency::MDL,
    clientIp: $request->ip(),
    language: Language::RO,
));

return redirect($hold->payUrl);

// Step 2: Capture (after callback confirms hold)
$capture = Maib::capture(new CapturePaymentRequest(
    payId:         $payId,
    confirmAmount: 99.99, // optional — omit to capture full hold amount
));
```

### Recurring Payments

[](#recurring-payments)

```
use Nikba\LaravelMaib\Dto\Requests\ExecuteRecurringRequest;
use Nikba\LaravelMaib\Dto\Requests\SaveCardRecurringRequest;

// Registration (once per customer — redirect to 3DS checkout)
$save = Maib::savecardRecurring(new SaveCardRecurringRequest(
    billerExpiry: '1228',
    clientIp:     $request->ip(),
    currency:     Currency::MDL,
    language:     Language::RO,
    email:        'user@example.com',
));

return redirect($save->payUrl);
// Callback will return billerId — store it for the customer.

// Server-side execution (no customer redirect)
$response = Maib::executeRecurring(new ExecuteRecurringRequest(
    billerId: $user->maib_biller_id,
    amount:   29.99,
    currency: Currency::MDL,
    orderId:  'SUBSCRIPTION-' . now()->format('Y-m'),
));

if ($response->status === \Nikba\LaravelMaib\Enums\TransactionStatus::OK) {
    // subscription renewed
}
```

### One-Click Payments

[](#one-click-payments)

```
use Nikba\LaravelMaib\Dto\Requests\ExecuteOneclickRequest;
use Nikba\LaravelMaib\Dto\Requests\SaveCardOneclickRequest;

// Registration
$save = Maib::savecardOneclick(new SaveCardOneclickRequest(
    billerExpiry: '1228',
    clientIp:     $request->ip(),
    currency:     Currency::MDL,
    language:     Language::RO,
    email:        'user@example.com',
));

return redirect($save->payUrl);

// Execution (redirects customer to checkout for 3DS confirmation)
$response = Maib::executeOneclick(new ExecuteOneclickRequest(
    billerId:  $user->maib_biller_id,
    amount:    49.99,
    currency:  Currency::MDL,
    clientIp:  $request->ip(),
    language:  Language::RO,
));

return redirect($response->payUrl);
```

### Refund

[](#refund)

```
use Nikba\LaravelMaib\Dto\Requests\RefundRequest;

$response = Maib::refund(new RefundRequest(
    payId:        $payId,
    refundAmount: 30.00, // optional — omit to refund the full amount
));
```

### Payment Info

[](#payment-info)

```
$info = Maib::payInfo($payId);

echo $info->status->value;   // 'OK', 'FAILED', etc.
echo $info->cardNumber;
```

### Delete Saved Card

[](#delete-saved-card)

```
$response = Maib::deleteCard($billerId);
```

---

Handling Callbacks
------------------

[](#handling-callbacks)

The package automatically registers the callback route at `MAIB_CALLBACK_ROUTE` (default: `/maib/callback`). This route is excluded from CSRF middleware.

Register this URL in your maibmerchants.md project settings.

**Allowed callback IPs (optional firewall rule):** `91.250.245.70`, `91.250.245.71`, `91.250.245.142`

### Listening for Events

[](#listening-for-events)

```
// In App\Providers\EventServiceProvider (or using #[AsEventListener])
use Nikba\LaravelMaib\Events\MaibPaymentFailed;
use Nikba\LaravelMaib\Events\MaibPaymentReceived;

Event::listen(MaibPaymentReceived::class, function (MaibPaymentReceived $event) {
    $payload = $event->payload;

    Order::where('maib_pay_id', $payload->payId)
        ->update([
            'status'      => 'paid',
            'rrn'         => $payload->rrn,
            'approval'    => $payload->approval,
            'card_number' => $payload->cardNumber,
        ]);
});

Event::listen(MaibPaymentFailed::class, function (MaibPaymentFailed $event) {
    Order::where('maib_pay_id', $event->payload->payId)
        ->update(['status' => 'failed']);
});
```

> **Important:** Always return HTTP 200 from your listener logic — the package's callback handler already does this. maib retries the callback at increasing intervals (`10, 60, 300, 600, 3600, 43200, 86400` seconds) if it does not receive a 200 response. Implement idempotency in your listeners.

---

Testing
-------

[](#testing)

```
composer test
```

---

Author
------

[](#author)

**Nicolai Bargan**
[Nikba Creative Studio](https://nikba.com)

---

License
-------

[](#license)

The MIT License (MIT). See [LICENSE](LICENSE) for details.

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance81

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

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

103d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0bcd10cd5a6707af2160f69291d06ff63cada1a920921edf7e3a4bdca6950c84?d=identicon)[nikba](/maintainers/nikba)

---

Top Contributors

[![Nikba-Creative-Studio](https://avatars.githubusercontent.com/u/41567806?v=4)](https://github.com/Nikba-Creative-Studio "Nikba-Creative-Studio (4 commits)")

---

Tags

laravelrecurringpaymentgatewayecommercemaibMoldovaone-click

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/nikba-laravel-maib/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k51.0M7.6k](/packages/larastan-larastan)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

76518.2M120](/packages/laravel-mcp)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

815320.5k3](/packages/defstudio-telegraph)[api-platform/laravel

API Platform support for Laravel

59156.3k11](/packages/api-platform-laravel)[calebdw/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

15104.9k4](/packages/calebdw-larastan)

PHPackages © 2026

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