定制 siewwp/laravel-service-consumer 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

siewwp/laravel-service-consumer

Composer 安装命令:

composer require siewwp/laravel-service-consumer

包简介

laravel server-to-server service consumer with HMAC authentication

README 文档

README

Server-to-server service consuming with hmac authentication.

Installation

composer require siewwp/laravel-service-consumer:dev-master

Usage

Binding your key

Your should bind your app id and secret at your ServiceProvider.

Refer to Hmac http client for more information.

Refer to Laravel Container for more information.

Handling webhook notification

If the service host is notifying event using webhook, you may define your webhook handler in your controller and extend to the webhook controller like so:

<?php

namespace App\Http\Controllers;

use Siewwp\LaravelServiceConsumer\Http\Controllers\Webhook;
use App\Http\Controllers\Controller;

class InvoiceController extends Controller
{
    public function handleInvoicePaid($payload) {
        // ...
    }
}

Or you can use the Siewwp\LaravelServiceConsumer\HandleWebhook trait in your controller

<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use Siewwp\LaravelServiceConsumer\HandleWebhook;

class InvoiceController extends Controller
{
    use HandleWebhook;

    public function handleInvoicePaid($payload) {
        // ...
    }
}

The name of the webhook method should be 'handle' + 'CamelCase' of the type of event notification. In the example above, is to handle InvoicePaid type event.

Refer to laravel-service-host for more information.

After that, you may register the webhook controller it on RouteServiceProvider.php file.

<?php
    // ...
    public function boot()
    {
        // ...
        Route::post(
            'tenant/webhook',
            '\App\Http\Controllers\InvoiceController@handleWebhook'
        );
    }
    ...

You can also register it on your web routes but you may need to exclude CSRF middleware

TO DO

TESTING

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-06-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固