PHPackages                             nasimic/payriff - 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. nasimic/payriff

ActiveLibrary[Payment Processing](/categories/payments)

nasimic/payriff
===============

Payriff

v1.0.0(1y ago)822MITPHPPHP ^8.1|^8.2|^8.3CI passing

Since May 15Pushed 1y ago1 watchersCompare

[ Source](https://github.com/nasimic/payriff)[ Packagist](https://packagist.org/packages/nasimic/payriff)[ RSS](/packages/nasimic-payriff/feed)WikiDiscussions master Synced 1mo ago

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

Payriff package for Laravel apps
================================

[](#payriff-package-for-laravel-apps)

This repo can be used as to implement Payriff Payments (V3) to Laravel application. Supporting PHP 8.1+ versions.

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

[](#installation)

```
composer require nasimic/payriff
```

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

[](#configuration)

Normally config file will be published automatically. In case of manual publish:

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

Add your credentials to .env file

```
PAYRIFF_SECRET_KEY=your secret here
```

Usage
-----

[](#usage)

PayriffServiceProvider generates PayriffClient to inject directly to a constructor or to a method. And it is highly recommended to chose Dependency Injection over Facades.

With constructor:

```
use Nasimic\Payriff\PayriffClient;

public function __construct(
    private readonly PayriffClient $payriffClient,
) {
}
```

With method

```
use Nasimic\Payriff\PayriffClient;

public function pay(PayriffClient $payriffClient) {
...
}
```

Alternatively, you could get PayriffClient instance from container or bind with PayriffClientInterface on service provider.

Examples
--------

[](#examples)

Create order
------------

[](#create-order)

You will play with Data classes (DTO) to send and get populated data. Good for validation purposes and valid states.

```
use Nasimic\Payriff\PayriffClient;
use Nasimic\Payriff\Data\Request\CreateOrderRequest;

...

public function createPaymentUrl(Order $order) {
    $orderRequestDto = new CreateOrderRequest(
        amount: $order->price,
        callbackUrl: CUSTOM_CALLBACK_URL // optional
    );

    $orderResponseDto = $this->payriffClient->createOrder($orderRequestDto);

    // You will need orderId to retrieve order info later.
    // Save orderId. This represents payment of your order on Payriff.
    // Let's say save it on DB column.
    $order->update(['payriff_payment_id' => $orderResponseDto->orderId]);

    return $orderResponseDto->paymentUrl;
}
```

You will get [CreateOrderResponse](src/Data/Response/CreateOrderResponse.php) class with populated data. Save orderId and redirect user to the Payment URL.

If the callbackUrl are left blank, then user will be redirected to proper Payriff pages ([Success](https://payriff.com/success.html), [Cancel](https://payriff.com/cancel.html), [Decline](https://payriff.com/decline.html))

On successful transaction, Payriff will POST transaction data to callbackURL. However, it is recommended to handle payment callback with [Get Order](#get-order) (after Payriff redirecting to callbackUrl). Also consider updating statuses of abandoned Payments.

More opinionated Create order request:

```
$orderRequestDto = new CreateOrderRequest(
    amount: 75,
    callbackUrl: CUSTOM_CALLBACK_URL,
    currency: "USD", // default is AZN
    language: "RU", // default is AZ
    description: "Test order",
    cardSave: true,
    operation: "PRE_AUTH", // default is PURCHASE
    installment: [
        "type" => "TAMKART",
        "period" => "PERIOD_2"
    ]
);
}
```

Get Order
---------

[](#get-order)

You can retrieve order with multiple functions depending on purpose

```
public function handleCallback(Order $order) {

    // To get all information about order (returns OrderInformationResponse)
    $this->payriffClient->getOrderInformation($order->payriff_payment_id);

    // To get only payment status (returns string)
    $this->payriffClient->getOrderStatus($order->payriff_payment_id);

    // To check order is paid (returns bool)
    $this->payriffClient->isOrderPaid($order->payriff_payment_id);

    ...
}
```

OrderInformationResponse is Data object and has these properties populated:

```
string $orderId,
float $amount,
string $currencyType,
?string $merchantName,
string $operationType,
string $paymentStatus,
bool $auto,
string $createdDate,
string $description,
array $transactions,
```

Refund
------

[](#refund)

```
public function refund(Order $order) {

    $refundRequestDto = new RefundRequest(
        amount: $order->price,
        orderId: $order->payriff_payment_id
    );

    // Returns bool
    $this->payriffClient->refund($refundRequestDto);

    ...
}
```

**NOTE**: The refund request is used to cancel a payment for an order. This functionality is available within a limited period (specified by the bank) after a payment has been executed.

Exceptions
----------

[](#exceptions)

Consider catching exceptions and providing user-friendly errors

- [CurrencyNotAllowedException](src/Exceptions/CurrencyNotAllowedException.php)
- [LanguageNotAllowedException](src/Exceptions/LanguageNotAllowedException.php)
- [OperationNotAllowedException](src/Exceptions/OperationNotAllowedException.php)
- [OrderCreationException](src/Exceptions/OrderCreationException.php)
- [OrderInformationException](src/Exceptions/OrderInformationException.php)
- [OrderStatusException](src/Exceptions/OrderStatusException.php)
- [RefundException](src/Exceptions/RefundException.php)

like

```
use \Nasimic\Payriff\Exceptions\OrderCreationException;

try {
    $orderResponseDto = $this->payriffClient->createOrder($orderRequestDto);
} catch (OrderCreationException $exception) {
    // log error $exception->getMessage()
    // print user-friendly message
}
```

Documentation
-------------

[](#documentation)

For more detailed information please check [Payriff Documentation](https://docs.payriff.com) page.

What is next?
-------------

[](#what-is-next)

These functions on TODO list. Will be added soon

- AutoPay

Credits
-------

[](#credits)

- [Nasimi Mammadov](https://github.com/nasimic)

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance49

Moderate activity, may be stable

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity52

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

368d ago

### Community

Maintainers

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

---

Top Contributors

[![nasimic](https://avatars.githubusercontent.com/u/55084308?v=4)](https://github.com/nasimic "nasimic (13 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/nasimic-payriff/health.svg)

```
[![Health](https://phpackages.com/badges/nasimic-payriff/health.svg)](https://phpackages.com/packages/nasimic-payriff)
```

###  Alternatives

[laraveldaily/laravel-invoices

Missing invoices for Laravel

1.5k1.3M4](/packages/laraveldaily-laravel-invoices)[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)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[asciisd/knet

Knet package is provides an expressive, fluent interface to KNet's payment services.

141.1k](/packages/asciisd-knet)

PHPackages © 2026

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