承接 binkode/laravel-mono 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

binkode/laravel-mono

Composer 安装命令:

composer require binkode/laravel-mono

包简介

A description for laravel-mono.

关键字:

README 文档

README

Use Mono Apis in your laravel project.

Software License Travis Total Downloads

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

  • verifyWebHook

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.

  • Create an event listener class

php artisan make:listener MonoWebHookListener --event=Myckhel\Mono\Events\Hook
  • Handle mono webhook events

<?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"
              }
            }
          }
        */
    }
}
  • Register MonoWebHookListener

<?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.

binkode/laravel-mono 适用场景与选型建议

binkode/laravel-mono 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4 次下载、GitHub Stars 达 3, 最近一次更新时间为 2023 年 11 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 binkode/laravel-mono 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 binkode/laravel-mono 我们能提供哪些服务?
定制开发 / 二次开发

基于 binkode/laravel-mono 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 25
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-11-19