PHPackages                             kahil-raghed/masarat-ly-php-sdk - 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. kahil-raghed/masarat-ly-php-sdk

ActiveLibrary[Payment Processing](/categories/payments)

kahil-raghed/masarat-ly-php-sdk
===============================

Package to process payments throught https://masarat.ly payment gateway

v1.2.0(2mo ago)112[1 PRs](https://github.com/kahil-raghed/masarat-ly-php-sdk/pulls)MITPHPPHP ^7.4||^8.0

Since Feb 4Pushed 2mo agoCompare

[ Source](https://github.com/kahil-raghed/masarat-ly-php-sdk)[ Packagist](https://packagist.org/packages/kahil-raghed/masarat-ly-php-sdk)[ Docs](https://github.com/kahil-raghed/masarat-ly-php-sdk)[ RSS](/packages/kahil-raghed-masarat-ly-php-sdk/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (2)Versions (7)Used By (0)

Masarat.ly PHP SDK
==================

[](#masaratly-php-sdk)

A simple PHP SDK for integrating with the Masarat.ly payment gateway.

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

[](#installation)

```
composer require kahil-raghed/masarat-ly-php-sdk
```

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

[](#requirements)

- PHP &gt;= 7.4
- GuzzleHTTP &gt;= 6.5

Usage
-----

[](#usage)

### Basic Payment

[](#basic-payment)

```
use KahilRaghed\MasaratLy\MasaratLy;
use KahilRaghed\MasaratLy\ApiResponse;

$masarat = new MasaratLy('https://api.masarat.ly');

// Sign in
$response = $masarat->signIn(
    userId: 'your_user_id',
    pin: 'your_pin',
    providerId: 'your_provider_id',
    authUserType: 'merchant'
);

if ($response->success()) {
    // Cache token and expiry
    $tokenValidTo = $response->content['validTo'];
    $token = $response->content['value'];
    $masarat->setToken($token);
} else {
    echo "Sign in failed: " . $response->message;
    return;
}

// Open payment session
$sessionResponse = $masarat->openSession(
    amount: 100.00,
    identityCard: '123456789',
    transactionId: 'ORDER-12345',
    onlineOperation: 1 // 1 = Sell, 2 = Refund
);

if ($sessionResponse->success()) {
    // Session token and expiry
    $sessionTokenValidTo = $sessionResponse->content['validTo'];
    $sessionToken = $sessionResponse->content['value'];
} else {
    echo "Session failed: " . $sessionResponse->message;
    return;
}

// Complete transaction with OTP
$result = $masarat->completeSession(
    sessionToken: $sessionToken,
    otp: '123456'
);

if ($result->success()) {
    echo "Payment successful!";
} else {
    echo "Payment failed: " . $result->message;
}
```

API Methods
-----------

[](#api-methods)

### `signIn($userId, $pin, $providerId, $authUserType): ApiResponse`

[](#signinuserid-pin-providerid-authusertype-apiresponse)

Authenticate and obtain a token. Returns an `ApiResponse` object.

### `openSession($amount, $identityCard, $transactionId, $onlineOperation): ApiResponse`

[](#opensessionamount-identitycard-transactionid-onlineoperation-apiresponse)

Open a payment session. Returns an `ApiResponse` object with session data including `value` (session token).

**Parameters:**

- `$amount` - Transaction amount
- `$identityCard` - Customer card ID (9-10 digits)
- `$transactionId` - Unique transaction ID
- `$onlineOperation` - 1 for Sell, 2 for Refund

### `completeSession($sessionToken, $otp): ApiResponse`

[](#completesessionsessiontoken-otp-apiresponse)

Complete the transaction with OTP verification. Returns an `ApiResponse` object.

### `getToken()` / `setToken($token)`

[](#gettoken--settokentoken)

Get or set the authentication token.

License
-------

[](#license)

MIT

Author
------

[](#author)

Raghed Kahil -

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance86

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

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 ~6 days

Total

5

Last Release

73d ago

Major Versions

v0.1.0-rc1 → v1.0.02026-02-08

PHP version history (2 changes)v0.1.0-rc1PHP &gt;=7.4

v1.0.0PHP ^7.4||^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/99bd5025e4a50917fa23ab19d1fee23d40a395529897b9ac3c73fbba278c827b?d=identicon)[kahil-raghed](/maintainers/kahil-raghed)

---

Top Contributors

[![kahil-raghed](https://avatars.githubusercontent.com/u/188712413?v=4)](https://github.com/kahil-raghed "kahil-raghed (9 commits)")

---

Tags

phpsdkpaymentmasarat

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/kahil-raghed-masarat-ly-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/kahil-raghed-masarat-ly-php-sdk/health.svg)](https://phpackages.com/packages/kahil-raghed-masarat-ly-php-sdk)
```

###  Alternatives

[yandex-money/yandex-money-sdk-php

Yandex.Money API SDK for PHP

105167.4k2](/packages/yandex-money-yandex-money-sdk-php)[cryptonator/merchant-php-sdk

Cryptonator.com Merchant API SDK for PHP

2713.7k](/packages/cryptonator-merchant-php-sdk)

PHPackages © 2026

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