PHPackages                             jonhwu/laravel-unitpay - 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. jonhwu/laravel-unitpay

ActiveLibrary[Payment Processing](/categories/payments)

jonhwu/laravel-unitpay
======================

UnitPay payments for Laravel

v4.0.0(5y ago)011MITPHPPHP ^7.3|^8.0

Since Jan 15Pushed 4y agoCompare

[ Source](https://github.com/jonhwu/laravel-unitpay)[ Packagist](https://packagist.org/packages/jonhwu/laravel-unitpay)[ RSS](/packages/jonhwu-laravel-unitpay/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (4)Versions (14)Used By (0)

Laravel payment processor package for UnitPay gateway
=====================================================

[](#laravel-payment-processor-package-for-unitpay-gateway)

[![Latest Stable Version](https://camo.githubusercontent.com/54dc76701681612f8c8a32ae5124118c45184c06faa6fc3b78c460e0841c75d4/68747470733a2f2f706f7365722e707567782e6f72672f6a6f6e6877752f6c61726176656c2d756e69747061792f762f737461626c65)](https://packagist.org/packages/jonhwu/laravel-unitpay)[![Build Status](https://camo.githubusercontent.com/204f7578c25620b580b803d15a44a45a903bfa953f041cd4e1ab506710b3f896/68747470733a2f2f7472617669732d63692e6f72672f6a6f6e6877752f6c61726176656c2d756e69747061792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/jonhwu/laravel-unitpay)[![StyleCI](https://camo.githubusercontent.com/d7668402b62ede7e1ce774af8ce3068b5ed947a5f9f11d562638937bf6c639bf/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3136353834313630312f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/165841601)[![CodeFactor](https://camo.githubusercontent.com/3c75fd8004a202b1365be28d1404c30fd7604816e4f523e135d4f0fe385dc032/68747470733a2f2f7777772e636f6465666163746f722e696f2f7265706f7369746f72792f6769746875622f6a6f6e6877752f6c61726176656c2d756e69747061792f6261646765)](https://www.codefactor.io/repository/github/jonhwu/laravel-unitpay)[![Total Downloads](https://camo.githubusercontent.com/603c69e563a5b048015bff6d90fd734fdf90258f3984bce66f74638bd764058f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a6f6e6877752f6c61726176656c2d756e69747061792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jonhwu/laravel-unitpay)[![License](https://camo.githubusercontent.com/2cf01f499f5ca1f87d8aaa36bb0438cf7393743b189c5737a8393ace7ba553a4/68747470733a2f2f706f7365722e707567782e6f72672f6a6f6e6877752f6c61726176656c2d756e69747061792f6c6963656e7365)](https://packagist.org/packages/jonhwu/laravel-unitpay)

Accept payments via UnitPay ([unitpay.ru](https://unitpay.ru/)) using this Laravel framework package ([Laravel](https://laravel.com)).

- receive payments, adding just the two callbacks

#### Laravel &gt;= 8.\*, PHP &gt;= 7.3

[](#laravel--8-php--73)

> To use the package for Laravel 7.\* use the [3.x](https://github.com/jonhwu/laravel-unitpay/tree/3.x) branch

> To use the package for Laravel 6.\* use the [2.x](https://github.com/jonhwu/laravel-unitpay/tree/2.x) branch

> To use the package for Laravel 5.\* use the [1.x](https://github.com/jonhwu/laravel-unitpay/tree/1.x) branch

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

[](#installation)

Require this package with composer.

```
composer require "jonhwu/laravel-unitpay"
```

If you don't use auto-discovery, add the ServiceProvider to the providers array in `config/app.php`

```
JonhWu\UnitPay\UnitPayServiceProvider::class,
```

Add the `UnitPay` facade to your facades array:

```
'UnitPay' => JonhWu\UnitPay\Facades\UnitPay::class,
```

Copy the package config to your local config with the publish command:

```
php artisan vendor:publish --provider="JonhWu\UnitPay\UnitPayServiceProvider"
```

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

[](#configuration)

Once you have published the configuration files, please edit the config file in `config/unitpay.php`.

- Create an account on [unitpay.ru](http://unitpay.ru)
- Add your project, copy the `public_key`, `secret_key` params and paste into `config/unitpay.php`
- After the configuration has been published, edit `config/unitpay.php`
- Set the callback static function for `searchOrder` and `paidOrder`
- Create route to your controller, and call `UnitPay::handle` method

Usage
-----

[](#usage)

1. Generate a payment url or get redirect:

```
$amount = 100; // Payment`s amount

$email = "example@gmail.com"; // Your customer`s email

$description = "Test payment";

//

$url = UnitPay::getPayUrl($amount, $order_id, $email, $description, $currency);

$redirect = UnitPay::redirectToPayUrl($amount, $order_id, $email, $description, $currency);
```

2. Process the request from UnitPay:

```
UnitPay::handle(Request $request)
```

Important
---------

[](#important)

You must define callbacks in `config/unitpay.php` to search the order and save the paid order.

```
'searchOrder' => null  // UnitPayController@searchOrder(Request $request)
```

```
'paidOrder' => null  // UnitPayController@paidOrder(Request $request, $order)
```

Example
-------

[](#example)

The process scheme:

1. The request comes from `unitpay.ru` `GET` `http://yourproject.com/unitpay/result` (with params).
2. The function`UnitPayController@handlePayment` runs the validation process (auto-validation request params).
3. The method `searchOrder` will be called (see `config/unitpay.php` `searchOrder`) to search the order by the unique id.
4. If the current order status is NOT `paid` in your database, the method `paidOrder` will be called (see `config/unitpay.php` `paidOrder`).

Add the route to `routes/web.php`:

```
 Route::get('/unitpay/result', 'UnitPayController@handlePayment');
```

> **Note:**don't forget to save your full route url (e.g.  ) for your project on [unitpay.ru](unitpay.ru).

Create the following controller: `/app/Http/Controllers/UnitPayController.php`:

```
class UnitPayController extends Controller
{
    /**
     * Search the order in your database and return that order
     * to paidOrder, if status of your order is 'paid'
     *
     * @param Request $request
     * @param $order_id
     * @return bool|mixed
     */
    public function searchOrder(Request $request, $order_id)
    {
        $order = Order::where('id', $order_id)->first();

        if($order) {
            $order['_orderSum'] = $order->sum;

            // If your field can be `paid` you can set them like string
            $order['_orderStatus'] = $order['status'];

            // Else your field doesn` has value like 'paid', you can change this value
            $order['_orderStatus'] = ('1' == $order['status']) ? 'paid' : false;

            return $order;
        }

        return false;
    }

    /**
     * When paymnet is check, you can paid your order
     *
     * @param Request $request
     * @param $order
     * @return bool
     */
    public function paidOrder(Request $request, $order)
    {
        $order->status = 'paid';
        $order->save();

        //

        return true;
    }

    /**
     * Start handle process from route
     *
     * @param Request $request
     * @return mixed
     */
    public function handlePayment(Request $request)
    {
        return UnitPay::handle($request);
    }
}
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please send me an email at  instead of using the issue tracker.

Credits
-------

[](#credits)

- [JonhWu](https://github.com/jonhwu)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 93.8% 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 ~101 days

Recently: every ~81 days

Total

9

Last Release

1868d ago

Major Versions

1.x-dev → 2.x-dev2020-05-13

v2.0.0 → v3.0.02020-05-13

v3.0.0 → v4.0.02021-04-02

PHP version history (5 changes)v1.0.0PHP &gt;=5.6.4

v1.0.2PHP &gt;=7.1

2.x-devPHP &gt;=7.2

v3.0.0PHP &gt;=7.2.5

v4.0.0PHP ^7.3|^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/73402092?v=4)[jonhwu](/maintainers/jonhwu)[@jonhwu](https://github.com/jonhwu)

---

Top Contributors

[![maksa988](https://avatars.githubusercontent.com/u/5982466?v=4)](https://github.com/maksa988 "maksa988 (30 commits)")[![jasonstealer](https://avatars.githubusercontent.com/u/87783247?v=4)](https://github.com/jasonstealer "jasonstealer (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jonhwu-laravel-unitpay/health.svg)

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

###  Alternatives

[lemonsqueezy/laravel

A package to easily integrate your Laravel application with Lemon Squeezy.

58596.1k](/packages/lemonsqueezy-laravel)[evryn/laravel-toman

A simple stable Laravel package to handle popular payment gateways in Iran including ZarinPal and IDPay.

1079.9k](/packages/evryn-laravel-toman)[buckaroo/sdk

Buckaroo payment SDK

12189.1k9](/packages/buckaroo-sdk)[tsaiyihua/laravel-linepay

linepay library for laravel

102.9k](/packages/tsaiyihua-laravel-linepay)[digikraaft/laravel-paystack-webhooks

Handle Paystack webhooks in a Laravel application

177.5k1](/packages/digikraaft-laravel-paystack-webhooks)[wandesnet/mercadopago-laravel

PHP SDK for integration with Mercado Pago

252.4k](/packages/wandesnet-mercadopago-laravel)

PHPackages © 2026

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