PHPackages                             digikraaft/laravel-paystack-webhooks - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. digikraaft/laravel-paystack-webhooks

ActiveLibrary[Payment Processing](/categories/payments)

digikraaft/laravel-paystack-webhooks
====================================

Handle Paystack webhooks in a Laravel application

v3.0.1(1y ago)177.5k↑100%91MITPHPPHP ^8.2CI failing

Since Jul 16Pushed 1y ago2 watchersCompare

[ Source](https://github.com/digikraaft/laravel-paystack-webhooks)[ Packagist](https://packagist.org/packages/digikraaft/laravel-paystack-webhooks)[ Docs](https://github.com/digikraaft/laravel-paystack-webhooks)[ RSS](/packages/digikraaft-laravel-paystack-webhooks/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (5)Versions (10)Used By (1)

Handle Paystack Webhooks in a Laravel application
=================================================

[](#handle-paystack-webhooks-in-a-laravel-application)

[![tests](https://github.com/digikraaft/laravel-paystack-webhooks/workflows/tests/badge.svg)](https://github.com/digikraaft/laravel-paystack-webhooks/workflows/tests/badge.svg)[![Build Status](https://camo.githubusercontent.com/0709bfa47ab5368cb8851542e7aa345218618ccf34f36c7cacdf71b10ff847e5/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f646967696b72616166742f6c61726176656c2d706179737461636b2d776562686f6f6b732f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/digikraaft/laravel-paystack-webhooks/build-status/master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/8d5d1be42a059a20853b18355ee221a2249beaca1e900f418ea361884aa46901/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f646967696b72616166742f6c61726176656c2d706179737461636b2d776562686f6f6b732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/digikraaft/laravel-paystack-webhooks/?branch=master)[![Code Intelligence Status](https://camo.githubusercontent.com/1d0a54bb23a091662a4ffce8797b0dc9657089642b0a2e96f596fa201a0dbf38/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f646967696b72616166742f6c61726176656c2d706179737461636b2d776562686f6f6b732f6261646765732f636f64652d696e74656c6c6967656e63652e7376673f623d6d6173746572)](https://scrutinizer-ci.com/code-intelligence)[![License: MIT](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)](https://opensource.org/licenses/MIT)

[Paystack](https://paystack.com/) 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](https://paystack.com/docs/payments/webhooks/#supported-events)

Installation
============

[](#installation)

You can install the package via composer:

```
composer require digikraaft/laravel-paystack-webhooks
```

#### Configuration File

[](#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

[](#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
==========================

[](#handling-paystack-webhooks)

[Paystack](https://paystack.com/) 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:

```
