digikraaft/laravel-paystack-webhooks 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

digikraaft/laravel-paystack-webhooks

Composer 安装命令:

composer require digikraaft/laravel-paystack-webhooks

包简介

Handle Paystack webhooks in a Laravel application

README 文档

README

tests Build Status Scrutinizer Code Quality Code Intelligence Status License: MIT

Paystack can notify your application about various events via webhooks. This package can help you handle those webhooks. It will automatically verify all incoming requests and ensure they are coming from Paystack. By default, a route that points to this package's webhook controller is configured through the service provider.

Please note that this package will NOT handle what should be done after the request has been validated. You should still write the code for that.

Find out more details about Paystack's Event here

Installation

You can install the package via composer:

composer require digikraaft/laravel-paystack-webhooks

Configuration File

The Laravel Paystack Webhooks package comes with a configuration file, here is the content of the file:

return [

    /*
    |--------------------------------------------------------------------------
    | Paystack Keys
    |--------------------------------------------------------------------------
    |
    | The Paystack publishable key and secret key. You can get these from your Paystack dashboard.
    |
    */

    'public_key' => env('PAYSTACK_PUBLIC_KEY'),

    'secret' => env('PAYSTACK_SECRET'),

    /*
   |--------------------------------------------------------------------------
   | Webhooks Path
   |--------------------------------------------------------------------------
   |
   | This is the base URI path where webhooks will be handled from.
   |
   | This should correspond to the webhooks URL set in your Paystack dashboard:
   | https://dashboard.paystack.com/#/settings/developer.
   |
   | If your webhook URL is https://domain.com/paystack/webhook/ then you should simply enter paystack here.
   |
   | Remember to also add this as an exception in your VerifyCsrfToken middleware.
   |
   | See the demo application linked on github to help you get started.
   |
   */
    'webhook_path' => env('PAYSTACK_WEBHOOK_PATH', 'paystack'),

];

You can publish this config file with the following commands:

php artisan vendor:publish --provider="Digikraaft\PaystackWebhooks\PaystackWebhooksServiceProvider" --tag="config"

API Keys

You should configure your Paystack keys in your .env file. You can get your Paystack API keys from the Paystack dashboard.

PAYSTACK_PUBLIC_KEY=your-paystack-public-key
PAYSTACK_SECRET=your-paystack-secret

Handling Paystack Webhooks

Paystack can notify your application about various events via webhooks. This package can help you handle those webhooks. It will automatically verify all incoming requests and ensure they are coming from Paystack. By default, a route that points to this package's webhook controller is configured through the service provider.

Please note that this package will NOT handle what should be done after the request has been validated. You should still write the code for that. All you need do is to extend the controller in order to handle any webhook event you like. For example, if you wish to handle the charge.success event, you should add a handleChargeSuccess method to the controller:

<?php

namespace App\Http\Controllers;

use Digikraaft\PaystackWebhooks\Http\Controllers\WebhooksController as PaystackWebhooksController;

class WebhookController extends PaystackWebhooksController
{
    /**
     * Handle charge success.
     *
     * @param  array  $payload
     * @return \Symfony\Component\HttpFoundation\Response
     */
    public function handleChargeSuccess($payload)
    {
        // Handle The Event
    }
}

To ensure your application can handle Paystack webhooks, be sure to configure the webhook URL in the Paystack dashboard. By default, this package's webhook controller listens to the /paystack/webhook.

Next, define a route to your controller within your routes/web.php file.

Route::post(
    'paystack/webhook',
    '\App\Http\Controllers\WebhookController@handleWebhook'
);

Webhooks & CSRF Protection

Since Paystack webhooks need to bypass Laravel's CSRF protection, be sure to list the URI as an exception in your VerifyCsrfToken middleware or list the route outside of the web middleware group:

protected $except = [
    'paystack/*',
];

This package emits a Digikraaft\PaystackWebhooks\Events\WebhookReceived event when a webhook is received, and a Digikraaft\PaystackWebhooks\Events\WebhookHandled event when a webhook was handled by you. Both events contain the full payload of the Paystack webhook.

You can find details about Paystack events here

Verifying Webhook Signatures

For convenience, this package automatically includes a middleware which validates that the incoming Paystack webhook request is valid.

Testing

Use the command below to run your tests:

composer test

More Good Stuff

Check here for more awesome free stuff!

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email dev@digitalkraaft.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

digikraaft/laravel-paystack-webhooks 适用场景与选型建议

digikraaft/laravel-paystack-webhooks 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7.77k 次下载、GitHub Stars 达 17, 最近一次更新时间为 2020 年 07 月 16 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 7.77k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 17
  • 点击次数: 18
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 17
  • Watchers: 2
  • Forks: 9
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-07-16