{"id":20496663,"url":"https://github.com/maksa988/laravel-unitpay","last_synced_at":"2025-04-13T18:21:47.460Z","repository":{"id":53175481,"uuid":"165841601","full_name":"maksa988/laravel-unitpay","owner":"maksa988","description":"Laravel payments for Laravel","archived":false,"fork":false,"pushed_at":"2021-04-02T17:20:44.000Z","size":39,"stargazers_count":13,"open_issues_count":0,"forks_count":13,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T01:17:18.354Z","etag":null,"topics":["accept-payments","laravel","laravel-5-package","laravel-payments","laravel-unitpay","unitpay"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maksa988.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-15T11:46:34.000Z","updated_at":"2024-01-27T13:22:05.000Z","dependencies_parsed_at":"2022-09-14T09:51:33.395Z","dependency_job_id":null,"html_url":"https://github.com/maksa988/laravel-unitpay","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maksa988%2Flaravel-unitpay","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maksa988%2Flaravel-unitpay/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maksa988%2Flaravel-unitpay/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maksa988%2Flaravel-unitpay/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maksa988","download_url":"https://codeload.github.com/maksa988/laravel-unitpay/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248759133,"owners_count":21157094,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["accept-payments","laravel","laravel-5-package","laravel-payments","laravel-unitpay","unitpay"],"created_at":"2024-11-15T18:08:17.198Z","updated_at":"2025-04-13T18:21:47.440Z","avatar_url":"https://github.com/maksa988.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel payment processor package for UnitPay gateway\n\n[![Latest Stable Version](https://poser.pugx.org/maksa988/laravel-unitpay/v/stable)](https://packagist.org/packages/maksa988/laravel-unitpay)\n[![Build Status](https://travis-ci.org/maksa988/laravel-unitpay.svg?branch=master)](https://travis-ci.org/maksa988/laravel-unitpay)\n[![StyleCI](https://github.styleci.io/repos/165841601/shield?branch=master)](https://github.styleci.io/repos/165841601)\n[![CodeFactor](https://www.codefactor.io/repository/github/maksa988/laravel-unitpay/badge)](https://www.codefactor.io/repository/github/maksa988/laravel-unitpay)\n[![Total Downloads](https://img.shields.io/packagist/dt/maksa988/laravel-unitpay.svg?style=flat-square)](https://packagist.org/packages/maksa988/laravel-unitpay)\n[![License](https://poser.pugx.org/maksa988/laravel-unitpay/license)](https://packagist.org/packages/maksa988/laravel-unitpay)\n\nAccept payments via UnitPay ([unitpay.ru](https://unitpay.ru/)) using this Laravel framework package ([Laravel](https://laravel.com)).\n\n- receive payments, adding just the two callbacks\n\n#### Laravel \u003e= 8.*, PHP \u003e= 7.3\n\n\u003e To use the package for Laravel 7.* use the [3.x](https://github.com/maksa988/laravel-unitpay/tree/3.x) branch\n\n\u003e To use the package for Laravel 6.* use the [2.x](https://github.com/maksa988/laravel-unitpay/tree/2.x) branch\n\n\u003e To use the package for Laravel 5.* use the [1.x](https://github.com/maksa988/laravel-unitpay/tree/1.x) branch\n\n## Installation\n\nRequire this package with composer.\n\n``` bash\ncomposer require \"maksa988/laravel-unitpay\"\n```\n\nIf you don't use auto-discovery, add the ServiceProvider to the providers array in `config/app.php`\n\n```php\nMaksa988\\UnitPay\\UnitPayServiceProvider::class,\n```\n\nAdd the `UnitPay` facade to your facades array:\n\n```php\n'UnitPay' =\u003e Maksa988\\UnitPay\\Facades\\UnitPay::class,\n```\n\nCopy the package config to your local config with the publish command:\n``` bash\nphp artisan vendor:publish --provider=\"Maksa988\\UnitPay\\UnitPayServiceProvider\"\n```\n\n## Configuration\n\nOnce you have published the configuration files, please edit the config file in `config/unitpay.php`.\n\n- Create an account on [unitpay.ru](http://unitpay.ru)\n- Add your project, copy the `public_key`, `secret_key` params and paste into `config/unitpay.php`\n- After the configuration has been published, edit `config/unitpay.php`\n- Set the callback static function for `searchOrder` and `paidOrder`\n- Create route to your controller, and call `UnitPay::handle` method\n \n## Usage\n\n1) Generate a payment url or get redirect:\n\n```php\n$amount = 100; // Payment`s amount\n\n$email = \"example@gmail.com\"; // Your customer`s email\n\n$description = \"Test payment\";\n\n//\n\n$url = UnitPay::getPayUrl($amount, $order_id, $email, $description, $currency);\n\n$redirect = UnitPay::redirectToPayUrl($amount, $order_id, $email, $description, $currency);\n```\n\n2) Process the request from UnitPay:\n``` php\nUnitPay::handle(Request $request)\n```\n\n## Important\n\nYou must define callbacks in `config/unitpay.php` to search the order and save the paid order.\n\n\n``` php\n'searchOrder' =\u003e null  // UnitPayController@searchOrder(Request $request)\n```\n\n``` php\n'paidOrder' =\u003e null  // UnitPayController@paidOrder(Request $request, $order)\n```\n\n## Example\n\nThe process scheme:\n\n1. The request comes from `unitpay.ru` `GET` `http://yourproject.com/unitpay/result` (with params).\n2. The function`UnitPayController@handlePayment` runs the validation process (auto-validation request params).\n3. The method `searchOrder` will be called (see `config/unitpay.php` `searchOrder`) to search the order by the unique id.\n4. If the current order status is NOT `paid` in your database, the method `paidOrder` will be called (see `config/unitpay.php` `paidOrder`).\n\nAdd the route to `routes/web.php`:\n``` php\n Route::get('/unitpay/result', 'UnitPayController@handlePayment');\n```\n\n\u003e **Note:**\ndon't forget to save your full route url (e.g. http://example.com/unitpay/result ) for your project on [unitpay.ru](unitpay.ru).\n\nCreate the following controller: `/app/Http/Controllers/UnitPayController.php`:\n\n``` php\nclass UnitPayController extends Controller\n{\n    /**\n     * Search the order in your database and return that order\n     * to paidOrder, if status of your order is 'paid'\n     *\n     * @param Request $request\n     * @param $order_id\n     * @return bool|mixed\n     */\n    public function searchOrder(Request $request, $order_id)\n    {\n        $order = Order::where('id', $order_id)-\u003efirst();\n\n        if($order) {\n            $order['_orderSum'] = $order-\u003esum;\n\n            // If your field can be `paid` you can set them like string\n            $order['_orderStatus'] = $order['status'];\n\n            // Else your field doesn` has value like 'paid', you can change this value\n            $order['_orderStatus'] = ('1' == $order['status']) ? 'paid' : false;\n\n            return $order;\n        }\n\n        return false;\n    }\n\n    /**\n     * When paymnet is check, you can paid your order\n     *\n     * @param Request $request\n     * @param $order\n     * @return bool\n     */\n    public function paidOrder(Request $request, $order)\n    {\n        $order-\u003estatus = 'paid';\n        $order-\u003esave();\n\n        //\n\n        return true;\n    }\n\n    /**\n     * Start handle process from route\n     *\n     * @param Request $request\n     * @return mixed\n     */\n    public function handlePayment(Request $request)\n    {\n        return UnitPay::handle($request);\n    }\n}\n```\n\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Security\n\nIf you discover any security related issues, please send me an email at maksa988ua@gmail.com instead of using the issue tracker.\n\n## Credits\n\n- [Maksa988](https://github.com/maksa988)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaksa988%2Flaravel-unitpay","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaksa988%2Flaravel-unitpay","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaksa988%2Flaravel-unitpay/lists"}