PHPackages                             kemo/monri-client - 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. kemo/monri-client

ActiveLibrary[Payment Processing](/categories/payments)

kemo/monri-client
=================

Monri payment gateway PHP client

v1.1.0(2mo ago)01↓100%MITPHPPHP &gt;=8.1CI passing

Since Mar 8Pushed 2mo agoCompare

[ Source](https://github.com/kemo/monri-client)[ Packagist](https://packagist.org/packages/kemo/monri-client)[ RSS](/packages/kemo-monri-client/feed)WikiDiscussions main Synced 1mo ago

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

Monri PHP Client
================

[](#monri-php-client)

[![CI](https://github.com/kemo/monri-client/actions/workflows/ci.yml/badge.svg)](https://github.com/kemo/monri-client/actions/workflows/ci.yml)

PHP client for the [Monri](https://monri.com) payment gateway. Supports PHP 8.1+.

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

[](#installation)

```
composer require kemo/monri-client
```

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

[](#configuration)

```
use Kemo\Monri\Config;
use Kemo\Monri\Environment;
use Kemo\Monri\MonriClient;

$client = new MonriClient(new Config(
    merchantKey: 'your-merchant-key',
    authenticityToken: 'your-authenticity-token',
    environment: Environment::Production, // or Environment::Test
));
```

Or from environment variables (`MONRI_MERCHANT_KEY`, `MONRI_AUTHENTICITY_TOKEN`, `MONRI_ENVIRONMENT`):

```
$client = MonriClient::fromEnv();
```

Both credentials are available in the Monri merchant dashboard.

Authentication
--------------

[](#authentication)

All requests are signed using the documented `WP3-v2.1` digest scheme:

```
Authorization: WP3-v2.1 {authenticity_token} {timestamp} {SHA512(key+timestamp+token+path+body)}

```

This is handled automatically — no manual token management required.

Payments
--------

[](#payments)

### Create a payment

[](#create-a-payment)

```
$payment = $client->payments()->create([
    'order_number'     => 'ORD-' . uniqid(),
    'amount'           => 5000,        // minor units (5000 = €50.00)
    'currency'         => 'EUR',
    'order_info'       => 'GOD Club membership',
    'transaction_type' => 'purchase',  // or 'authorize'
]);

echo $payment->id;           // payment ID to pass to the frontend SDK
echo $payment->clientSecret; // client secret for frontend SDK
echo $payment->status;       // 'approved' | 'invalid-request' | 'error'
```

Optional params: `scenario`, `customer_uuid`, `supported_payment_methods`, `success_url_override`, `cancel_url_override`, `callback_url_override`.

### Update a payment (change amount before capture)

[](#update-a-payment-change-amount-before-capture)

```
$payment = $client->payments()->update('pay_123', ['amount' => 3000]);
```

### Check payment status

[](#check-payment-status)

```
$status = $client->payments()->status('pay_123');

echo $status->status;        // 'approved' | 'invalid-request' | 'error'
echo $status->paymentStatus; // e.g. 'completed'

if ($status->result !== null) {
    echo $status->result->amount;      // int, minor units
    echo $status->result->currency;    // 'EUR'
    echo $status->result->orderNumber;
}
```

Customers
---------

[](#customers)

### Create a customer

[](#create-a-customer)

```
$customer = $client->customers()->create([
    'merchant_customer_id' => 'user-42', // your internal user ID
    'email'  => 'fan@god.ba',
    'name'   => 'Adnan Fest',
    'phone'  => '+38761000000',
]);

echo $customer->uuid; // Monri's UUID for this customer
```

### Find a customer

[](#find-a-customer)

```
// By Monri UUID
$customer = $client->customers()->find('cust-uuid-123');

// By your own customer ID
$customer = $client->customers()->findByMerchantId('user-42');
```

### Update a customer

[](#update-a-customer)

```
$customer = $client->customers()->update('cust-uuid-123', [
    'email' => 'new@god.ba',
    'city'  => 'Sarajevo',
]);
```

### List customers

[](#list-customers)

```
$customers = $client->customers()->list(limit: 50, offset: 0);
```

### Delete a customer

[](#delete-a-customer)

```
$client->customers()->delete('cust-uuid-123');
```

### Saved payment methods

[](#saved-payment-methods)

```
$methods = $client->customers()->paymentMethods('cust-uuid-123');

foreach ($methods as $method) {
    echo $method->maskedPan;      // '411111******1111'
    echo $method->expirationDate; // '12/27'
    echo $method->token;          // pan_token for card-on-file payments
    echo $method->expired;        // bool
}
```

Card tokenization (frontend)
----------------------------

[](#card-tokenization-frontend)

Generate a temporary token to pass to the Monri frontend SDK:

```
$token = $client->tokens()->generate();

// Pass these to your frontend
echo $token->id;
echo $token->timestamp;
echo $token->digest;
```

Error handling
--------------

[](#error-handling)

```
use Kemo\Monri\Exception\ApiException;
use Kemo\Monri\Exception\MonriException;
use Kemo\Monri\Exception\NetworkException;

try {
    $payment = $client->payments()->create([...]);
} catch (ApiException $e) {
    // HTTP 4xx/5xx from Monri
    echo $e->statusCode;          // e.g. 422
    $data = $e->decodedBody();    // parsed response array
} catch (NetworkException $e) {
    // Connection failure, timeout
} catch (MonriException $e) {
    // Configuration error
}
```

Custom HTTP client
------------------

[](#custom-http-client)

The default transport uses cURL. To use a PSR-18 client (e.g. Guzzle):

```
use Kemo\Monri\Http\PsrHttpClient;

$http = new PsrHttpClient($guzzle, $requestFactory, $streamFactory);

$client = new MonriClient($config, $http);
```

Development
-----------

[](#development)

```
composer test        # PHPUnit
composer cs-check    # php-cs-fixer (dry-run)
composer cs-fix      # php-cs-fixer (apply)
composer phpcs       # PHP_CodeSniffer
composer phpcbf      # PHP_CodeSniffer (auto-fix)
composer phpstan     # PHPStan (level max)
```

Environments
------------

[](#environments)

ConstantBase URL`Environment::Test``https://ipgtest.monri.com``Environment::Production``https://ipg.monri.com`License
-------

[](#license)

MIT - see [LICENSE](LICENSE).

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance88

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity44

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

Every ~0 days

Total

2

Last Release

63d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7ca3781cebcc86df44893a47f55d55844817d997a5db0f476850d08826c7cefd?d=identicon)[kemo](/maintainers/kemo)

---

Top Contributors

[![kemo](https://avatars.githubusercontent.com/u/100160?v=4)](https://github.com/kemo "kemo (14 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/kemo-monri-client/health.svg)

```
[![Health](https://phpackages.com/badges/kemo-monri-client/health.svg)](https://phpackages.com/packages/kemo-monri-client)
```

###  Alternatives

[chargebee/chargebee-php

ChargeBee API client implementation for PHP

768.0M9](/packages/chargebee-chargebee-php)[superfaktura/apiclient

Api client for SuperFaktura | online invoicing tool

19133.3k](/packages/superfaktura-apiclient)

PHPackages © 2026

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