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

ActiveLibrary[Payment Processing](/categories/payments)

fynduck/laravel-maib-ecommerce
==============================

Laravel package for the maib (Moldova Agroindbank) e-Commerce payment gateway.

1.0.0(1mo ago)21↓50%MITPHPPHP ^8.2CI passing

Since Jun 12Pushed 1mo agoCompare

[ Source](https://github.com/fynduck/laravel-maib-ecommerce)[ Packagist](https://packagist.org/packages/fynduck/laravel-maib-ecommerce)[ Docs](https://github.com/fynduck/laravel-maib-ecommerce)[ RSS](/packages/fynduck-laravel-maib-ecommerce/feed)WikiDiscussions main Synced 1w ago

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

Laravel maib e-Commerce
=======================

[](#laravel-maib-e-commerce)

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Latest Version on Packagist](https://camo.githubusercontent.com/31cf9d2d5f974c3d7be62d6dc8e56bedc2886b4f93c816fe26b5910c16ff85c7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f66796e6475636b2f6c61726176656c2d6d6169622d65636f6d6d657263652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/laravel-maib-ecommerce)[![Tests](https://github.com/fynduck/laravel-maib-ecommerce/actions/workflows/tests.yml/badge.svg)](https://github.com/fynduck/laravel-maib-ecommerce/actions/workflows/tests.yml)[![Total Downloads](https://camo.githubusercontent.com/04ddd861fa54eb1d550ff04709ba4e7c6bead6cae71e121747ef156ec796f3eb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f66796e6475636b2f6c61726176656c2d6d6169622d65636f6d6d657263652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/laravel-maib-ecommerce)

A Laravel package for the [maib](https://www.maib.md/) (Moldova Agroindbank) e-Commerce payment gateway. It implements the [maibmerchants e-Commerce API](https://docs.maibmerchants.md)natively in Laravel — HTTP client, container bindings, a facade, config, events, signature verification and an optional payments table.

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

[](#requirements)

- PHP 8.2+
- Laravel 10, 11, 12 or 13

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

[](#installation)

```
composer require fynduck/laravel-maib-ecommerce
```

Publish the config:

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

Add your project credentials (issued in the maibmerchants.md dashboard after activation) to `.env`:

```
MAIB_PROJECT_ID=your-project-id
MAIB_PROJECT_SECRET=your-project-secret
MAIB_SIGNATURE_KEY=your-signature-key

# Optional
MAIB_BASE_URL=https://api.maibmerchants.md/v1/
MAIB_CALLBACK_ROUTE=/maib/callback
MAIB_STORE_PAYMENTS=false
```

The access token is generated, cached and refreshed automatically — you never handle tokens.

Usage
-----

[](#usage)

All methods are available on the `Maib` facade and return a `PaymentResult` object.

### Direct payment

[](#direct-payment)

Only `amount`, `currency` and `clientIp` are required; everything else is optional. You can pass the `Currency` and `Language` enums instead of raw strings to avoid mistyping — the client converts them automatically:

```
use Fynduck\MaibEcommerce\Facades\Maib;
use Fynduck\MaibEcommerce\Enums\Currency;
use Fynduck\MaibEcommerce\Enums\Language;

$payment = Maib::pay([
    // required
    'amount' => 10.25,
    'currency' => Currency::MDL,        // or 'MDL'
    'clientIp' => $request->ip(),
    'language' => Language::EN,          // or 'en' (ro | ru | en)

    // optional
    'description' => 'Order #123',       // max 124 chars
    'clientName' => 'John Doe',          // max 128 chars
    'email' => 'john@example.com',
    'phone' => '069123456',              // max 40 chars
    'orderId' => '123',                  // max 36 chars
    'delivery' => 1.25,                  // delivery price
    'items' => [
        ['id' => 'SKU-1', 'name' => 'Product 1', 'price' => 2.50, 'quantity' => 2],
        ['id' => 'SKU-2', 'name' => 'Product 2', 'price' => 4.00, 'quantity' => 1],
    ],
    'callbackUrl' => route('maib.callback'),
    'okUrl' => route('checkout.success'),
    'failUrl' => route('checkout.failed'),
]);

// Persist $payment->payId, then redirect the customer to the maib checkout page:
return redirect()->away($payment->payUrl);
```

The same optional keys (`description`, `clientName`, `email`, `phone`, `orderId`, `delivery`, `items`, `okUrl`, `failUrl`, `callbackUrl`) apply to `hold()`, `saveRecurring()`and `saveOneclick()`. For the authoritative, always-current list of every parameter and its constraints, see the **[maib e-Commerce API docs](https://docs.maibmerchants.md/e-commerce/maib-e-commerce-api)**.

### Two-step payment (hold + complete)

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

```
$hold = Maib::hold(['amount' => 10.25, 'currency' => 'MDL', 'clientIp' => $request->ip()]);
// ...later, capture all or part of the held amount:
$captured = Maib::complete(['payId' => $hold->payId, 'confirmAmount' => 10.25]);
```

### Refund

[](#refund)

```
$refund = Maib::refund(['payId' => $payId, 'refundAmount' => 10.25]);
```

### Payment info

[](#payment-info)

```
$info = Maib::payInfo($payId); // 36-char payId
$info->statusEnum(); // PaymentStatus enum
```

### Recurring &amp; one-click

[](#recurring--one-click)

```
// Register a card (redirects to checkout); maib returns a billerId on the callback.
$save = Maib::saveRecurring(['billerExpiry' => '1230', 'currency' => 'MDL', 'clientIp' => $ip]);
return redirect()->away($save->payUrl);

// Later, charge the stored card without customer interaction:
$charge = Maib::executeRecurring(['billerId' => $billerId, 'amount' => 6.25, 'currency' => 'MDL']);

// One-click works the same way:
$save = Maib::saveOneclick(['billerExpiry' => '1230', 'currency' => 'MDL', 'clientIp' => $ip]);
$charge = Maib::executeOneclick(['billerId' => $billerId, 'amount' => 6.25, 'currency' => 'MDL', 'clientIp' => $ip]);

// Remove a stored card:
Maib::deleteCard($billerId);
```

Callbacks (webhooks)
--------------------

[](#callbacks-webhooks)

maib sends a signed notification to your `callbackUrl` after each payment. The package registers a route (default `POST /maib/callback`, named `maib.callback`) guarded by a signature-verification middleware. Requests with an invalid signature are rejected with a `403` before reaching your application.

On a valid callback the package dispatches:

- `Fynduck\MaibEcommerce\Events\PaymentCallbackReceived` — every callback
- `Fynduck\MaibEcommerce\Events\PaymentSucceeded` — when status is `OK`
- `Fynduck\MaibEcommerce\Events\PaymentFailed` — when status is `FAILED`

Each event carries a `CallbackResult` (`$event->callback`) with a typed `PaymentResult`(`$event->callback->payment`) and the raw verified `result` array.

### Registering listeners

[](#registering-listeners)

Map a listener to the event in your `App\Providers\EventServiceProvider`:

```
namespace App\Providers;

use App\Listeners\MarkOrderAsPaid;
use Fynduck\MaibEcommerce\Events\PaymentFailed;
use Fynduck\MaibEcommerce\Events\PaymentSucceeded;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;

class EventServiceProvider extends ServiceProvider
{
    protected $listen = [
        PaymentSucceeded::class => [
            MarkOrderAsPaid::class,
        ],
        PaymentFailed::class => [
            // App\Listeners\NotifyCustomerOfFailure::class,
        ],
    ];
}
```

> On Laravel 11+ the `EventServiceProvider` is no longer in the default skeleton. You can still create it (and register it in `bootstrap/providers.php`), or just bind the listener in `AppServiceProvider::boot()`: `Event::listen(PaymentSucceeded::class, MarkOrderAsPaid::class);`

### Run listeners on the queue (recommended)

[](#run-listeners-on-the-queue-recommended)

The callback request comes from maib and is **waiting on your HTTP response** — and maib may **retry** the notification if you are slow or error out. Do not do slow work (DB writes, sending mail, calling other APIs) inline in the listener: that blocks the response and risks duplicate callbacks. Instead make the listener queued by implementing `ShouldQueue`, so the controller returns `200` immediately and the work runs on a worker:

```
namespace App\Listeners;

use Fynduck\MaibEcommerce\Events\PaymentSucceeded;
use Illuminate\Contracts\Queue\ShouldQueue;

class MarkOrderAsPaid implements ShouldQueue
{
    public string $queue = 'payments';

    public function handle(PaymentSucceeded $event): void
    {
        $payId = $event->callback->payId();
        // mark your order as paid, notify the customer, etc.
    }
}
```

Make sure a queue worker is running (`php artisan queue:work`). Because callbacks can be re-delivered, keep listeners **idempotent** — key off `payId` so processing the same notification twice is harmless.

> **Security:** the signature is validated using your `MAIB_SIGNATURE_KEY` with the maib algorithm (recursive key sort → append key → `:`-join → `base64(sha256())`) and a timing-safe comparison. Never expose the signature key.

Optional payment persistence
----------------------------

[](#optional-payment-persistence)

To record every callback in a `maib_payments` table:

```
php artisan vendor:publish --tag=maib-migrations
php artisan migrate
```

Then set `MAIB_STORE_PAYMENTS=true`. Incoming callbacks are upserted into the `Fynduck\MaibEcommerce\Models\MaibPayment` model (keyed by `pay_id`). The core client works without this table — persistence is entirely opt-in.

Testing
-------

[](#testing)

```
composer test      # Pest
composer lint      # Pint (dry run)
composer analyse   # PHPStan / Larastan
```

License
-------

[](#license)

MIT

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance90

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community6

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

46d ago

### Community

Maintainers

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

---

Top Contributors

[![fynduck](https://avatars.githubusercontent.com/u/12099534?v=4)](https://github.com/fynduck "fynduck (8 commits)")

---

Tags

laravelmaibpackagesphp8laravelpaymentecommercemaibMoldovamaibmerchants

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.3M348](/packages/psalm-plugin-laravel)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)[sebdesign/laravel-viva-payments

A Laravel package for integrating the Viva Payments gateway

4851.0k](/packages/sebdesign-laravel-viva-payments)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5022.6k](/packages/simplestats-io-laravel-client)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1235.9k21](/packages/fleetbase-core-api)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

293.1k](/packages/eslazarev-wildberries-sdk)

PHPackages © 2026

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