bazegel/laravel-monobank
Composer 安装命令:
composer require bazegel/laravel-monobank
包简介
Laravel package for Monobank
README 文档
README
English | Українська
Laravel Monobank Acquiring API
A package for integrating with the Monobank Acquiring API in Laravel applications.
Installation
You can install the package via composer:
composer require bazegel/laravel-monobank
Configuration
-
Publish the configuration file:
php artisan vendor:publish --provider="Bazegel\Monobank\Providers\MonobankServiceProvider" --tag="config"
This command will create a
config/monobank.phpfile. -
Add your acquiring token to the
.envfile:MONOBANK_TOKEN=your_secret_token
Usage
The package provides a convenient Monobank facade for interacting with the API.
Creating an Invoice
To create an invoice and redirect the user to the payment page:
use Bazegel\Monobank\Facades\Monobank; use Illuminate\Http\Request; class PaymentController extends Controller { public function createPayment(Request $request) { $invoiceData = [ 'amount' => 1000, // Amount in the smallest currency units (e.g., kopecks) 'ccy' => 980, // ISO 4217 currency code (980 = UAH) 'redirectUrl' => route('payment.success'), 'webHookUrl' => route('monobank.webhook'), 'merchantPaymInfo' => [ 'destination' => 'Payment for order #12345', 'basketOrder' => [ [ 'name' => 'Product 1', 'qty' => 1, 'sum' => 1000, 'unit' => 'pcs.' ] ] ], ]; try { $response = Monobank::createInvoice($invoiceData); // Get the payment URL $paymentUrl = $response->getData('pageUrl'); // Redirect the user to the payment page return redirect()->away($paymentUrl); } catch (\Exception $e) { // Error handling return back()->withErrors('Payment creation error: ' . $e->getMessage()); } } }
Checking Invoice Status
You can check the status of a previously created invoice by its invoiceId.
use Bazegel\Monobank\Facades\Monobank; $invoiceId = '240228A9aB1cD23d4E5f'; // Invoice ID received upon creation try { $response = Monobank::getInvoiceStatus($invoiceId); // 'created', 'processing', 'hold', 'success', 'failure', 'expired' $status = $response->getData('status'); if ($status === 'success') { // Payment is successful } } catch (\Exception $e) { // Error handling }
Handling Webhooks
Create a route and a controller to handle incoming notifications from Monobank.
Route (routes/web.php):
Route::post('/monobank/webhook', [MonobankWebhookController::class, 'handle'])->name('monobank.webhook');
Controller:
use Bazegel\Monobank\Facades\Monobank; use Illuminate\Http\Request; class MonobankWebhookController extends Controller { public function handle(Request $request) { // 1. Signature validation (IMPORTANT!) // You need to implement the validation of the X-Sign header. // $publicKey = Monobank::getKeyForVerification()->getData('key'); // ... signature validation logic ... // 2. Parsing the data $invoice = Monobank::parseCallbackData($request); $status = $invoice->getStatus(); // 'success', 'failure', etc. $invoiceId = $invoice->getInvoiceId(); $amount = $invoice->getAmount(); // Your logic for handling the payment status goes here // For example, updating the order status in the database return response('OK', 200); } }
Important: Before processing a webhook, you must verify the
X-Signdigital signature in the request headers to ensure that the request actually came from Monobank. To do this, get the public key usingMonobank::getKeyForVerification().
License
The MIT License (MIT). Please see License File for more information.
bazegel/laravel-monobank 适用场景与选型建议
bazegel/laravel-monobank 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 09 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 bazegel/laravel-monobank 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bazegel/laravel-monobank 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-09-09