myckhel/laravel-mono
Composer 安装命令:
composer require myckhel/laravel-mono
包简介
A description for laravel-mono.
关键字:
README 文档
README
Use Mono Apis in your laravel project.
Mono Doc Link
Install
composer require myckhel/laravel-mono
Setup
The package will automatically register a service provider.
You need to publish the configuration file:
php artisan vendor:publish --provider="Myckhel\Mono\MonoServiceProvider"
Publish config
This is the default content of the config file mono.php:
<?php return [ "secret_key" => env("MONO_SECRET_KEY"), "url" => env("MONO_URL", 'https://api.withmono.com'), "version" => 1, "route" => [ "middleware" => ['api'], // For injecting middleware to the package's routes "prefix" => 'api', // For injecting middleware to the package's routes ], ];
Update env
Update Your Projects .env with their credentials:
MONO_SECRET_KEY=XXXXXXXXXXXXXXXXXXXX MONO_PUBLIC_KEY=XXXXXXXXXXXXXXXXXXXX MONO_WEBHOOK_SECRET_KEY=XXXXXXXXXXXX
Usage
Account
use Myckhel\Mono\Support\Account; Account::auth($code, $params); Account::info($id, $params); Account::statement($id, $params); Account::pollpdf($id, $params); Account::transactions($id, $params); Account::income($id, $params); Account::identity($id, $params); Account::sync($id, $params); Account::reauthorise($id, $params); Account::unlink($id, $params); Account::coverage($params);
Cac
use Myckhel\Mono\Support\Cac; Cac::lookup($params); Cac::company($id, $params);
Payment
use Myckhel\Mono\Support\Payment; Payment::initiate($params); Payment::verify($params); Payment::oneTimePayment($params); Payment::createPlan($params); Payment::listPlans($params); Payment::updatePlan($params); Payment::deletePlan($params);
Wallet
use Myckhel\Mono\Support\Wallet; Payment::balance($params);
Mono
Method to verify incoming webhook secret
use Mono; Mono::verifyWebHook($request->header('mono-webhook-secret'));
Using WebHook route
Laravel mono provides you a predefined endpoint that listens to and validates incoming mono's webhook events.
It emits Myckhel\Mono\Events\Hook on every incoming hooks which could be listened to.
Setup Mono Webhook
Check official page for instructions setting up mono webhook
laravel-mono exposes hooks api endpoint
use the enddpoints url to for the mono webhook url during the setup.
| POST | /hooks | | Myckhel\Mono\Http\Controllers\HookController@hook | api |
Listening to laravel-mono Hook event
You may start listening to incoming mono webhooks after setup by registering the event in your laravel project's EventServiceProvider file.
php artisan make:listener MonoWebHookListener --event=Myckhel\Mono\Events\Hook
<?php namespace App\Listeners; use Myckhel\Mono\Events\Hook; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Support\Facades\Log; class MonoWebHookListener { /** * Handle the event. * * @param Myckhel\Mono\Events\Hook $event * @return void */ public function handle(Hook $event) { Log::debug($event->event); /* { "event": "direct_debit.payment_successful", "data": { "type": "onetime-debit", "object": { "id": "txd_9AhCg0PNkwHiq6RqLLdiqKDf", "status": "successful", "amount": 30000, "description": "free shirt", "fee": 300, "currency": "NGN", "account": "611d575feef5d3371ca9d0d8", "customer": "611adcd9a5fda23baf58140d", "reference": "djdjj3939394949944", "liveMode": true, "created_at": "2021-08-18T18:54:23.491Z", "updated_at": "2021-08-18T18:55:16.055Z" } } } */ } }
<?php namespace App\Providers; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; use Illuminate\Support\Facades\Event; use Myckhel\Mono\Events\Hook; use App\Listeners\MonoWebHookListener; class EventServiceProvider extends ServiceProvider { /** * The event listener mappings for the application. * * @var array */ protected $listen = [ ... Hook::class => [ MonoWebHookListener::class, ], ];
Using built in routes
+--------+-----------+---------------------------------------------+---------------+----------------------------------------------------------------+----------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+-----------+---------------------------------------------+---------------+----------------------------------------------------------------+----------------+
| | GET|HEAD | / | | Closure | web |
| | POST | api/v1/account/auth | | Myckhel\Mono\Http\Controllers\AccountController@auth | api |
| | | | | | api.version:v1 |
| | GET|HEAD | api/v1/accounts/{id} | | Myckhel\Mono\Http\Controllers\AccountController@info | api |
| | | | | | api.version:v1 |
| | GET|HEAD | api/v1/accounts/{id}/identity | | Myckhel\Mono\Http\Controllers\AccountController@identity | api |
| | | | | | api.version:v1 |
| | GET|HEAD | api/v1/accounts/{id}/income | | Myckhel\Mono\Http\Controllers\AccountController@income | api |
| | | | | | api.version:v1 |
| | POST | api/v1/accounts/{id}/reauthorise | | Myckhel\Mono\Http\Controllers\AccountController@reauthorise | api |
| | | | | | api.version:v1 |
| | GET|HEAD | api/v1/accounts/{id}/statement | | Myckhel\Mono\Http\Controllers\AccountController@statement | api |
| | | | | | api.version:v1 |
| | GET|HEAD | api/v1/accounts/{id}/statement/jobs/{jobId} | | Myckhel\Mono\Http\Controllers\AccountController@pollPdf | api |
| | | | | | api.version:v1 |
| | POST | api/v1/accounts/{id}/sync | | Myckhel\Mono\Http\Controllers\AccountController@sync | api |
| | | | | | api.version:v1 |
| | GET|HEAD | api/v1/accounts/{id}/transactions | | Myckhel\Mono\Http\Controllers\AccountController@transactions | api |
| | | | | | api.version:v1 |
| | POST | api/v1/accounts/{id}/unlink | | Myckhel\Mono\Http\Controllers\AccountController@unlink | api |
| | | | | | api.version:v1 |
| | GET|HEAD | api/v1/cac/company/{id} | | Myckhel\Mono\Http\Controllers\CacController@company | api |
| | | | | | api.version:v1 |
| | GET|HEAD | api/v1/cac/lookup | | Myckhel\Mono\Http\Controllers\CacController@lookup | api |
| | | | | | api.version:v1 |
| | GET|HEAD | api/v1/coverage | | Myckhel\Mono\Http\Controllers\AccountController@coverage | api |
| | | | | | api.version:v1 |
| | POST | api/v1/payments/initiate | | Myckhel\Mono\Http\Controllers\PaymentController@initiate | api |
| | | | | | api.version:v1 |
| | GET|HEAD | api/v1/payments/one-time-payment | | Myckhel\Mono\Http\Controllers\PaymentController@oneTimePayment | api |
| | | | | | api.version:v1 |
| | POST | api/v1/payments/plans | | Myckhel\Mono\Http\Controllers\PaymentController@createPlan | api |
| | | | | | api.version:v1 |
| | GET|HEAD | api/v1/payments/plans | | Myckhel\Mono\Http\Controllers\PaymentController@listPlans | api |
| | | | | | api.version:v1 |
| | PUT | api/v1/payments/plans/{planId} | | Myckhel\Mono\Http\Controllers\PaymentController@updatePlan | api |
| | | | | | api.version:v1 |
| | DELETE | api/v1/payments/plans/{{planId}} | | Myckhel\Mono\Http\Controllers\PaymentController@deletePlan | api |
| | | | | | api.version:v1 |
| | POST | api/v1/payments/verify | | Myckhel\Mono\Http\Controllers\PaymentController@verify | api |
| | | | | | api.version:v1 |
| | POST | api/v1/hooks | | Myckhel\Mono\Http\Controllers\HookController@hook | api |
| | | | | | api.version:v1 |
+--------+-----------+---------------------------------------------+---------------+----------------------------------------------------------------+----------------+
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Credits
Security
If you discover any security-related issues, please email myckhel1@hotmail.com instead of using the issue tracker.
License
The MIT License (MIT). Please see License File for more information.
myckhel/laravel-mono 适用场景与选型建议
myckhel/laravel-mono 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 19 次下载、GitHub Stars 达 3, 最近一次更新时间为 2021 年 08 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 myckhel/laravel-mono 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 myckhel/laravel-mono 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 myckhel/laravel-mono 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Alfabank REST API integration
Laravel package for Accurate Online API integration.
Shared RCX Laravel DataTables UI and configuration helpers.
Boot a Laravel project on any machine with one command: app:serve installs missing tools (PHP, Node, Composer, Herd, Docker), creates .env, sets up the database, runs migrations, builds assets, starts a queue worker and serves via Herd, Sail or artisan serve; app:down cleanly stops everything it sta
Branded, diagnostic error pages (500, 403, 404, 419, 503) for Filament — native Filament UI, dark mode and translations out of the box.
Turn any PDF into a Pingen-ready A4 letter (generated address cover page + A4 normalisation + safe margins) and send it through the Pingen print & mail API. Laravel-first.
统计信息
- 总下载量: 19
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-08-17