├── .github ├── FUNDING.yml └── workflows │ ├── php-cs-fixer.yml │ ├── run-tests.yml │ └── update-changelog.yml ├── .php_cs.dist.php ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── UPGRADING.md ├── composer.json ├── config └── stripe-webhooks.php └── src ├── Exceptions └── WebhookFailed.php ├── ProcessStripeWebhookJob.php ├── StripeSignatureValidator.php ├── StripeWebhookProfile.php ├── StripeWebhooksController.php └── StripeWebhooksServiceProvider.php /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | custom: https://spatie.be/open-source/support-us 2 | -------------------------------------------------------------------------------- /.github/workflows/php-cs-fixer.yml: -------------------------------------------------------------------------------- 1 | name: Check & fix styling 2 | 3 | on: [push] 4 | 5 | jobs: 6 | php-cs-fixer: 7 | runs-on: ubuntu-latest 8 | 9 | steps: 10 | - name: Checkout code 11 | uses: actions/checkout@v2 12 | with: 13 | ref: ${{ github.head_ref }} 14 | 15 | - name: Run PHP CS Fixer 16 | uses: docker://oskarstark/php-cs-fixer-ga 17 | with: 18 | args: --config=.php_cs.dist.php --allow-risky=yes 19 | 20 | - name: Commit changes 21 | uses: stefanzweifel/git-auto-commit-action@v4 22 | with: 23 | commit_message: Fix styling 24 | -------------------------------------------------------------------------------- /.github/workflows/run-tests.yml: -------------------------------------------------------------------------------- 1 | name: run-tests 2 | 3 | on: 4 | - push 5 | - pull_request 6 | 7 | jobs: 8 | test: 9 | runs-on: ${{ matrix.os }} 10 | 11 | strategy: 12 | fail-fast: true 13 | matrix: 14 | os: [ubuntu-latest] 15 | php: [8.3, 8.2, 8.1, 8.0] 16 | laravel: ['8.*', '9.*', '10.*', '11.*', '12.*'] 17 | dependency-version: [prefer-stable] 18 | include: 19 | - laravel: 11.* 20 | testbench: 9.* 21 | - laravel: 10.* 22 | testbench: 8.* 23 | - laravel: 9.* 24 | testbench: 7.* 25 | - laravel: 8.* 26 | testbench: ^6.27 27 | - laravel: 12.* 28 | testbench: 10.* 29 | exclude: 30 | - laravel: 10.* 31 | php: 8.0 32 | - laravel: 11.* 33 | php: 8.1 34 | - laravel: 11.* 35 | php: 8.0 36 | - laravel: 12.* 37 | php: 8.1 38 | - laravel: 12.* 39 | php: 8.0 40 | 41 | name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} - ${{ matrix.os }} 42 | 43 | steps: 44 | - name: Checkout code 45 | uses: actions/checkout@v2 46 | 47 | - name: Setup PHP 48 | uses: shivammathur/setup-php@v2 49 | with: 50 | php-version: ${{ matrix.php }} 51 | extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick 52 | coverage: none 53 | 54 | - name: Install dependencies 55 | run: | 56 | composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update 57 | composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction 58 | 59 | - name: Execute tests 60 | run: vendor/bin/phpunit 61 | -------------------------------------------------------------------------------- /.github/workflows/update-changelog.yml: -------------------------------------------------------------------------------- 1 | name: "Update Changelog" 2 | 3 | on: 4 | release: 5 | types: [released] 6 | 7 | jobs: 8 | update: 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - name: Checkout code 13 | uses: actions/checkout@v2 14 | with: 15 | ref: main 16 | 17 | - name: Update Changelog 18 | uses: stefanzweifel/changelog-updater-action@v1 19 | with: 20 | latest-version: ${{ github.event.release.name }} 21 | release-notes: ${{ github.event.release.body }} 22 | 23 | - name: Commit updated CHANGELOG 24 | uses: stefanzweifel/git-auto-commit-action@v4 25 | with: 26 | branch: main 27 | commit_message: Update CHANGELOG 28 | file_pattern: CHANGELOG.md 29 | 30 | -------------------------------------------------------------------------------- /.php_cs.dist.php: -------------------------------------------------------------------------------- 1 | in([ 5 | __DIR__ . '/src', 6 | __DIR__ . '/tests', 7 | ]) 8 | ->name('*.php') 9 | ->notName('*.blade.php') 10 | ->ignoreDotFiles(true) 11 | ->ignoreVCS(true); 12 | 13 | return (new PhpCsFixer\Config()) 14 | ->setRules([ 15 | '@PSR2' => true, 16 | 'array_syntax' => ['syntax' => 'short'], 17 | 'ordered_imports' => ['sort_algorithm' => 'alpha'], 18 | 'no_unused_imports' => true, 19 | 'not_operator_with_successor_space' => true, 20 | 'trailing_comma_in_multiline' => true, 21 | 'phpdoc_scalar' => true, 22 | 'unary_operator_spaces' => true, 23 | 'binary_operator_spaces' => true, 24 | 'blank_line_before_statement' => [ 25 | 'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'], 26 | ], 27 | 'phpdoc_single_line_var_spacing' => true, 28 | 'phpdoc_var_without_name' => true, 29 | 'class_attributes_separation' => [ 30 | 'elements' => [ 31 | 'method' => 'one', 32 | ], 33 | ], 34 | 'method_argument_space' => [ 35 | 'on_multiline' => 'ensure_fully_multiline', 36 | 'keep_multiple_spaces_after_comma' => true, 37 | ], 38 | 'single_trait_insert_per_statement' => true, 39 | ]) 40 | ->setFinder($finder); 41 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to `laravel-stripe-webhooks` will be documented in this file 4 | 5 | ## [Unreleased](https://github.com/spatie/laravel-stripe-webhooks/compare/3.10.3...HEAD) 6 | 7 | ## [3.10.3](https://github.com/spatie/laravel-stripe-webhooks/compare/3.10.2...3.10.3) - 2025-04-04 8 | 9 | ### What's Changed 10 | 11 | * stripe v17 compatibility by @tgabi333 in https://github.com/spatie/laravel-stripe-webhooks/pull/186 12 | 13 | ### New Contributors 14 | 15 | * @tgabi333 made their first contribution in https://github.com/spatie/laravel-stripe-webhooks/pull/186 16 | 17 | **Full Changelog**: https://github.com/spatie/laravel-stripe-webhooks/compare/3.10.2...3.10.3 18 | 19 | ## [3.10.2](https://github.com/spatie/laravel-stripe-webhooks/compare/3.10.1...3.10.2) - 2025-02-21 20 | 21 | ### What's Changed 22 | 23 | * Laravel 12.x Compatibility by @laravel-shift in https://github.com/spatie/laravel-stripe-webhooks/pull/185 24 | 25 | **Full Changelog**: https://github.com/spatie/laravel-stripe-webhooks/compare/3.10.1...3.10.2 26 | 27 | ## [3.10.1](https://github.com/spatie/laravel-stripe-webhooks/compare/3.10.0...3.10.1) - 2024-12-30 28 | 29 | ### What's Changed 30 | 31 | * Add null union type to fix php 8.4 deprecation message by @billypoke in https://github.com/spatie/laravel-stripe-webhooks/pull/183 32 | 33 | ### New Contributors 34 | 35 | * @billypoke made their first contribution in https://github.com/spatie/laravel-stripe-webhooks/pull/183 36 | 37 | **Full Changelog**: https://github.com/spatie/laravel-stripe-webhooks/compare/3.10.0...3.10.1 38 | 39 | ## [3.10.0](https://github.com/spatie/laravel-stripe-webhooks/compare/3.9.0...3.10.0) - 2024-10-07 40 | 41 | ### What's Changed 42 | 43 | * Stripe 16 by @CNSam in https://github.com/spatie/laravel-stripe-webhooks/pull/180 44 | 45 | ### New Contributors 46 | 47 | * @CNSam made their first contribution in https://github.com/spatie/laravel-stripe-webhooks/pull/180 48 | 49 | **Full Changelog**: https://github.com/spatie/laravel-stripe-webhooks/compare/3.9.0...3.10.0 50 | 51 | ## [3.9.0](https://github.com/spatie/laravel-stripe-webhooks/compare/3.8.0...3.9.0) - 2024-07-22 52 | 53 | ### What's Changed 54 | 55 | * Allow stripe/stripe-php:^15.0 by @pb30 in https://github.com/spatie/laravel-stripe-webhooks/pull/179 56 | 57 | **Full Changelog**: https://github.com/spatie/laravel-stripe-webhooks/compare/3.8.0...3.9.0 58 | 59 | ## [3.8.0](https://github.com/spatie/laravel-stripe-webhooks/compare/3.7.0...3.8.0) - 2024-05-02 60 | 61 | ### What's Changed 62 | 63 | * Allow stripe/stripe-php:^14.0 by @pb30 in https://github.com/spatie/laravel-stripe-webhooks/pull/176 64 | 65 | ### New Contributors 66 | 67 | * @pb30 made their first contribution in https://github.com/spatie/laravel-stripe-webhooks/pull/176 68 | 69 | **Full Changelog**: https://github.com/spatie/laravel-stripe-webhooks/compare/3.7.0...3.8.0 70 | 71 | ## [3.7.0](https://github.com/spatie/laravel-stripe-webhooks/compare/3.6.0...3.7.0) - 2024-03-02 72 | 73 | ### What's Changed 74 | 75 | * Laravel 11.x Compatibility by @laravel-shift in https://github.com/spatie/laravel-stripe-webhooks/pull/172 76 | 77 | **Full Changelog**: https://github.com/spatie/laravel-stripe-webhooks/compare/3.6.0...3.7.0 78 | 79 | ## [3.6.0](https://github.com/spatie/laravel-stripe-webhooks/compare/3.5.0...3.6.0) - 2023-10-18 80 | 81 | ### What's Changed 82 | 83 | - allow stripe-php v13.x by @ankurk91 in https://github.com/spatie/laravel-stripe-webhooks/pull/167 84 | 85 | **Full Changelog**: https://github.com/spatie/laravel-stripe-webhooks/compare/3.5.0...3.6.0 86 | 87 | ## [3.5.0](https://github.com/spatie/laravel-stripe-webhooks/compare/3.4.0...3.5.0) - 2023-08-21 88 | 89 | ### What's Changed 90 | 91 | - Allow Stripe php 12 by @ankurk91 in https://github.com/spatie/laravel-stripe-webhooks/pull/166 92 | 93 | **Full Changelog**: https://github.com/spatie/laravel-stripe-webhooks/compare/3.4.0...3.5.0 94 | 95 | ## [3.4.0](https://github.com/spatie/laravel-stripe-webhooks/compare/3.3.0...3.4.0) - 2023-08-18 96 | 97 | ### What's Changed 98 | 99 | - Update README.md by @Khuthaily in https://github.com/spatie/laravel-stripe-webhooks/pull/163 100 | - Allow stripe-php v11 by @ankurk91 in https://github.com/spatie/laravel-stripe-webhooks/pull/165 101 | 102 | ### New Contributors 103 | 104 | - @Khuthaily made their first contribution in https://github.com/spatie/laravel-stripe-webhooks/pull/163 105 | 106 | **Full Changelog**: https://github.com/spatie/laravel-stripe-webhooks/compare/3.3.0...3.4.0 107 | 108 | ## [3.3.0](https://github.com/spatie/laravel-stripe-webhooks/compare/3.2.3...3.3.0) - 2023-06-06 109 | 110 | ### What's Changed 111 | 112 | - Configurable connection and queue by @diogogomeswww in https://github.com/spatie/laravel-stripe-webhooks/pull/159 113 | 114 | ### New Contributors 115 | 116 | - @diogogomeswww made their first contribution in https://github.com/spatie/laravel-stripe-webhooks/pull/159 117 | 118 | **Full Changelog**: https://github.com/spatie/laravel-stripe-webhooks/compare/3.2.3...3.3.0 119 | 120 | ## [3.2.3](https://github.com/spatie/laravel-stripe-webhooks/compare/3.2.2...3.2.3) - 2023-01-25 121 | 122 | ### What's Changed 123 | 124 | - Add PHP 8.2 Support by @patinthehat in https://github.com/spatie/laravel-stripe-webhooks/pull/144 125 | - Laravel 10.x Compatibility by @laravel-shift in https://github.com/spatie/laravel-stripe-webhooks/pull/151 126 | 127 | ### New Contributors 128 | 129 | - @patinthehat made their first contribution in https://github.com/spatie/laravel-stripe-webhooks/pull/144 130 | 131 | **Full Changelog**: https://github.com/spatie/laravel-stripe-webhooks/compare/3.2.2...3.2.3 132 | 133 | ## [3.2.2](https://github.com/spatie/laravel-stripe-webhooks/compare/3.2.1...3.2.2) - 2022-12-02 134 | 135 | ### What's Changed 136 | 137 | - allow stripe sdk v10 by @maximepvrt in https://github.com/spatie/laravel-stripe-webhooks/pull/141 138 | 139 | ### New Contributors 140 | 141 | - @maximepvrt made their first contribution in https://github.com/spatie/laravel-stripe-webhooks/pull/141 142 | 143 | **Full Changelog**: https://github.com/spatie/laravel-stripe-webhooks/compare/3.2.1...3.2.2 144 | 145 | ## [3.2.1](https://github.com/spatie/laravel-stripe-webhooks/compare/3.2.0...3.2.1) - 2022-08-03 146 | 147 | ### What's Changed 148 | 149 | - Add docs for transforming `WebhookCall` payload into Stripe object by @stevebauman in https://github.com/spatie/laravel-stripe-webhooks/pull/129 150 | - allow stripe sdk v9 by @ankurk91 in https://github.com/spatie/laravel-stripe-webhooks/pull/130 151 | 152 | ### New Contributors 153 | 154 | - @stevebauman made their first contribution in https://github.com/spatie/laravel-stripe-webhooks/pull/129 155 | 156 | **Full Changelog**: https://github.com/spatie/laravel-stripe-webhooks/compare/3.2.0...3.2.1 157 | 158 | ## [3.2.0](https://github.com/spatie/laravel-stripe-webhooks/compare/3.1.3...3.2.0) - 2022-06-07 159 | 160 | ### What's Changed 161 | 162 | - Update UPGRADING.md by @mstaack in https://github.com/spatie/laravel-stripe-webhooks/pull/125 163 | - let user able to define a default job as a catchall event handler by @wanghanlin in https://github.com/spatie/laravel-stripe-webhooks/pull/128 164 | 165 | ### New Contributors 166 | 167 | - @mstaack made their first contribution in https://github.com/spatie/laravel-stripe-webhooks/pull/125 168 | - @wanghanlin made their first contribution in https://github.com/spatie/laravel-stripe-webhooks/pull/128 169 | 170 | **Full Changelog**: https://github.com/spatie/laravel-stripe-webhooks/compare/3.1.3...3.2.0 171 | 172 | ## [3.1.3](https://github.com/spatie/laravel-stripe-webhooks/compare/3.1.2...3.1.3) - 2022-05-18 173 | 174 | ## What's Changed 175 | 176 | - Update UPGRADING.md by @flatcapco in https://github.com/spatie/laravel-stripe-webhooks/pull/116 177 | - Update README.md by @flatcapco in https://github.com/spatie/laravel-stripe-webhooks/pull/117 178 | - UPGRADING.md v3: Add payload column type change by @andzandz in https://github.com/spatie/laravel-stripe-webhooks/pull/122 179 | - Allow stripe sdk v8 by @ankurk91 in https://github.com/spatie/laravel-stripe-webhooks/pull/123 180 | 181 | ## New Contributors 182 | 183 | - @flatcapco made their first contribution in https://github.com/spatie/laravel-stripe-webhooks/pull/116 184 | - @andzandz made their first contribution in https://github.com/spatie/laravel-stripe-webhooks/pull/122 185 | 186 | **Full Changelog**: https://github.com/spatie/laravel-stripe-webhooks/compare/3.1.2...3.1.3 187 | 188 | ## [3.1.2](https://github.com/spatie/laravel-stripe-webhooks/compare/3.1.1...3.1.2) - 2022-03-07 189 | 190 | ## What's Changed 191 | 192 | - fix: only check for stripe webhooks by @ankurk91 in https://github.com/spatie/laravel-stripe-webhooks/pull/110 193 | 194 | **Full Changelog**: https://github.com/spatie/laravel-stripe-webhooks/compare/3.1.1...3.1.2 195 | 196 | ## [3.1.1](https://github.com/spatie/laravel-stripe-webhooks/compare/3.1.0...3.1.1) - 2022-02-05 197 | 198 | ## What's Changed 199 | 200 | - feat: process webhook once by @ankurk91 in https://github.com/spatie/laravel-stripe-webhooks/pull/107 201 | 202 | **Full Changelog**: https://github.com/spatie/laravel-stripe-webhooks/compare/3.1.0...3.1.1 203 | 204 | ## [3.1.0](https://github.com/spatie/laravel-stripe-webhooks/compare/3.0.2...3.1.0) - 2022-01-14 205 | 206 | - allow Laravel 9 207 | 208 | ## [3.0.2](https://github.com/spatie/laravel-stripe-webhooks/compare/3.0.1...3.0.2) - 2021-11-24 209 | 210 | ## What's Changed 211 | 212 | - Add Unreleased Heading to Changelog by @stefanzweifel in https://github.com/spatie/laravel-stripe-webhooks/pull/101 213 | - docs: fix upgrade guide by @ankurk91 in https://github.com/spatie/laravel-stripe-webhooks/pull/102 214 | - Corrected potential WebhookConfig issues. by @accu-clw in https://github.com/spatie/laravel-stripe-webhooks/pull/104 215 | 216 | ## New Contributors 217 | 218 | - @stefanzweifel made their first contribution in https://github.com/spatie/laravel-stripe-webhooks/pull/101 219 | - @accu-clw made their first contribution in https://github.com/spatie/laravel-stripe-webhooks/pull/104 220 | 221 | **Full Changelog**: https://github.com/spatie/laravel-stripe-webhooks/compare/3.0.1...3.0.2 222 | 223 | ## [3.0.1](https://github.com/spatie/laravel-stripe-webhooks/compare/3.0.0...3.0.1) - 2021-11-05 224 | 225 | ## What's Changed 226 | 227 | - Update README.md by @Faks in https://github.com/spatie/laravel-stripe-webhooks/pull/98 228 | - Fix publish commands by @ryanito in https://github.com/spatie/laravel-stripe-webhooks/pull/99 229 | - Fix routing by @ankurk91 in https://github.com/spatie/laravel-stripe-webhooks/pull/100 230 | 231 | ## New Contributors 232 | 233 | - @Faks made their first contribution in https://github.com/spatie/laravel-stripe-webhooks/pull/98 234 | - @ryanito made their first contribution in https://github.com/spatie/laravel-stripe-webhooks/pull/99 235 | 236 | **Full Changelog**: https://github.com/spatie/laravel-stripe-webhooks/compare/3.0.0...3.0.1 237 | 238 | ## 3.0.0 - 2021-10-25 239 | 240 | - use spatie/laravel-webhook-client v3 241 | - require PHP 8 242 | - require Laravel 8 243 | 244 | No changes to the API have been made, so it should be an easy upgrade 245 | 246 | ## 2.6.2 - 2021-10-04 247 | 248 | - Fix model from config not being used 249 | 250 | ## 2.6.1 - 2021-06-28 251 | 252 | - Process everything by default (#89) 253 | - restore Postgres compat 254 | 255 | ## 2.6.0 - 2021-06-18 256 | 257 | - process Stripe calls only once 258 | 259 | ## 2.5.0 - 2020-01-12 260 | 261 | - add `verify_signature` config option 262 | 263 | ## 2.4.0 - 2020-12-07 264 | 265 | - add support for PHP 8 266 | 267 | ## 2.3.1 - 2020-09-09 268 | 269 | - Add Laravel 8 support 270 | 271 | ## 2.3.0 - 2020-03-03 272 | 273 | - Add Laravel 7 support 274 | 275 | ## 2.2.1 - 2019-09-04 276 | 277 | - Allow Stripe 7.x 278 | 279 | ## 2.2.0 - 2019-09-04 280 | 281 | - Add Laravel 6 support 282 | 283 | ## 2.1.0 - 2019-07-08 284 | 285 | - upgrade spatie/laravel-webhook-client from v1 to v2 286 | 287 | ## 2.0.0 - 2019-06-24 288 | 289 | - this package now makes use of spatie/laravel-webhook-client 290 | 291 | ## 1.2.0 - 2018-02-27 292 | 293 | - drop support for Laravel 5.7 and below 294 | - drop support for PHP 7.1 and below 295 | 296 | ## 1.1.4 - 2018-02-27 297 | 298 | - add support for Laravel 5.8 299 | 300 | ## 1.1.3 - 2018-11-03 301 | 302 | - use `STRIPE_WEBHOOK_SECRET` env variable 303 | 304 | ## 1.1.2 - 2018-08-29 305 | 306 | - send a response in the controller 307 | 308 | ## 1.1.1 - 2018-08-29 309 | 310 | - add support for Laravel 5.7 311 | 312 | ## 1.1.0 - 2018-07-23 313 | 314 | - add support for Stripe Connect 315 | 316 | ## 1.0.3 - 2018-02-17 317 | 318 | - add support for stripe api v6 319 | 320 | ## 1.0.2 - 2018-02-08 321 | 322 | - add support for L5.6 323 | 324 | ## 1.0.1 - 2017-10-12 325 | 326 | - added missing parameter to `jobClassDoesNotExist` method 327 | 328 | ## 1.0.0 - 2017-10-09 329 | 330 | - initial release 331 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) Spatie bvba 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Handle Stripe Webhooks in a Laravel application 2 | 3 | [![Latest Version on Packagist](https://img.shields.io/packagist/v/spatie/laravel-stripe-webhooks.svg?style=flat-square)](https://packagist.org/packages/spatie/laravel-stripe-webhooks) 4 | ![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/spatie/laravel-stripe-webhooks/run-tests.yml?label=tests&branch=main) 5 | ![Check & fix styling](https://github.com/spatie/laravel-stripe-webhooks/workflows/Check%20&%20fix%20styling/badge.svg) 6 | [![Total Downloads](https://img.shields.io/packagist/dt/spatie/laravel-stripe-webhooks.svg?style=flat-square)](https://packagist.org/packages/spatie/laravel-stripe-webhooks) 7 | 8 | [Stripe](https://stripe.com) can notify your application of events using webhooks. This package can help you handle those webhooks. Out of the box it will verify the Stripe signature of all incoming requests. All valid calls will be logged to the database. You can easily define jobs or events that should be dispatched when specific events hit your app. 9 | 10 | This package will not handle what should be done after the webhook request has been validated and the right job or event is called. You should still code up any work (eg. regarding payments) yourself. 11 | 12 | Before using this package we highly recommend reading [the entire documentation on webhooks over at Stripe](https://stripe.com/docs/webhooks). 13 | 14 | ## Support us 15 | 16 | [](https://spatie.be/github-ad-click/laravel-stripe-webhooks) 17 | 18 | We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us). 19 | 20 | We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards). 21 | 22 | ### Upgrading 23 | 24 | Please see [UPGRADING](UPGRADING.md) for details. 25 | 26 | ## Installation 27 | 28 | You can install the package via composer: 29 | 30 | ```bash 31 | composer require spatie/laravel-stripe-webhooks 32 | ``` 33 | 34 | The service provider will automatically register itself. 35 | 36 | You must publish the config file with: 37 | ```bash 38 | php artisan vendor:publish --provider="Spatie\StripeWebhooks\StripeWebhooksServiceProvider" 39 | ``` 40 | 41 | This is the contents of the config file that will be published at `config/stripe-webhooks.php`: 42 | 43 | ```php 44 | return [ 45 | /* 46 | * Stripe will sign each webhook using a secret. You can find the used secret at the 47 | * webhook configuration settings: https://dashboard.stripe.com/account/webhooks. 48 | */ 49 | 'signing_secret' => env('STRIPE_WEBHOOK_SECRET'), 50 | 51 | /* 52 | * You can define a default job that should be run for all other Stripe event type 53 | * without a job defined in next configuration. 54 | * You may leave it empty to store the job in database but without processing it. 55 | */ 56 | 'default_job' => '', 57 | 58 | /* 59 | * You can define the job that should be run when a certain webhook hits your application 60 | * here. The key is the name of the Stripe event type with the `.` replaced by a `_`. 61 | * 62 | * You can find a list of Stripe webhook types here: 63 | * https://stripe.com/docs/api#event_types. 64 | */ 65 | 'jobs' => [ 66 | // 'source_chargeable' => \App\Jobs\StripeWebhooks\HandleChargeableSource::class, 67 | // 'charge_failed' => \App\Jobs\StripeWebhooks\HandleFailedCharge::class, 68 | ], 69 | 70 | /* 71 | * The classname of the model to be used. The class should equal or extend 72 | * Spatie\WebhookClient\Models\WebhookCall. 73 | */ 74 | 'model' => \Spatie\WebhookClient\Models\WebhookCall::class, 75 | 76 | /** 77 | * This class determines if the webhook call should be stored and processed. 78 | */ 79 | 'profile' => \Spatie\StripeWebhooks\StripeWebhookProfile::class, 80 | 81 | /* 82 | * Specify a connection and or a queue to process the webhooks 83 | */ 84 | 'connection' => env('STRIPE_WEBHOOK_CONNECTION'), 85 | 'queue' => env('STRIPE_WEBHOOK_QUEUE'), 86 | 87 | /* 88 | * When disabled, the package will not verify if the signature is valid. 89 | * This can be handy in local environments. 90 | */ 91 | 'verify_signature' => env('STRIPE_SIGNATURE_VERIFY', true), 92 | ]; 93 | ``` 94 | 95 | In the `signing_secret` key of the config file you should add a valid webhook secret. You can find the secret used at [the webhook configuration settings on the Stripe dashboard](https://dashboard.stripe.com/account/webhooks). 96 | 97 | Next, you must publish the migration with: 98 | ```bash 99 | php artisan vendor:publish --provider="Spatie\WebhookClient\WebhookClientServiceProvider" --tag="webhook-client-migrations" 100 | ``` 101 | 102 | After the migration has been published you can create the `webhook_calls` table by running the migrations: 103 | 104 | ```bash 105 | php artisan migrate 106 | ``` 107 | 108 | Finally, take care of the routing: At [the Stripe dashboard](https://dashboard.stripe.com/account/webhooks) you must configure at what url Stripe webhooks should hit your app. In the routes file of your app you must pass that route to `Route::stripeWebhooks`: 109 | 110 | ```php 111 | Route::stripeWebhooks('webhook-route-configured-at-the-stripe-dashboard'); 112 | ``` 113 | 114 | Behind the scenes this will register a `POST` route to a controller provided by this package. Because Stripe has no way of getting a csrf-token, you must add that route to the `except` array of the `VerifyCsrfToken` middleware: 115 | 116 | ```php 117 | protected $except = [ 118 | 'webhook-route-configured-at-the-stripe-dashboard', 119 | ]; 120 | ``` 121 | 122 | ## Usage 123 | 124 | Stripe will send out webhooks for several event types. You can find the [full list of events types](https://stripe.com/docs/api#event_types) in the Stripe documentation. 125 | 126 | Stripe will sign all requests hitting the webhook url of your app. This package will automatically verify if the signature is valid. If it is not, the request was probably not sent by Stripe. 127 | 128 | Unless something goes terribly wrong, this package will always respond with a `200` to webhook requests. Sending a `200` will prevent Stripe from resending the same event over and over again. 129 | Stripe might occasionally send a duplicate webhook request [more than once](https://stripe.com/docs/webhooks/best-practices#duplicate-events). This package makes sure that each request will only be processed once. 130 | All webhook requests with a valid signature will be logged in the `webhook_calls` table. The table has a `payload` column where the entire payload of the incoming webhook is saved. 131 | 132 | If the signature is not valid, the request will not be logged in the `webhook_calls` table but a `Spatie\StripeWebhooks\WebhookFailed` exception will be thrown. 133 | If something goes wrong during the webhook request the thrown exception will be saved in the `exception` column. In that case the controller will send a `500` instead of `200`. 134 | 135 | There are two ways this package enables you to handle webhook requests: you can opt to queue a job or listen to the events the package will fire. 136 | 137 | ### Handling webhook requests using jobs 138 | If you want to do something when a specific event type comes in you can define a job that does the work. Here's an example of such a job: 139 | 140 | ```php 141 | webhookCall = $webhookCall; 161 | } 162 | 163 | public function handle() 164 | { 165 | // do your work here 166 | 167 | // you can access the payload of the webhook call with `$this->webhookCall->payload` 168 | } 169 | } 170 | ``` 171 | 172 | We highly recommend that you make this job queueable, because this will minimize the response time of the webhook requests. This allows you to handle more stripe webhook requests and avoid timeouts. 173 | 174 | After having created your job you must register it at the `jobs` array in the `stripe-webhooks.php` config file. The key should be the name of [the stripe event type](https://stripe.com/docs/api#event_types) where but with the `.` replaced by `_`. The value should be the fully qualified classname. 175 | 176 | ```php 177 | // config/stripe-webhooks.php 178 | 179 | 'jobs' => [ 180 | 'source_chargeable' => \App\Jobs\StripeWebhooks\HandleChargeableSource::class, 181 | ], 182 | ``` 183 | 184 | In case you want to configure one job as default to process all undefined event, you may set the job at `default_job` in 185 | the `stripe-webhooks.php` config file. The value should be the fully qualified classname. 186 | 187 | By default, the configuration is an empty string `''`, which will only store the event in database but without handling. 188 | 189 | ```php 190 | // config/stripe-webhooks.php 191 | 'default_job' => \App\Jobs\StripeWebhooks\HandleOtherEvent::class, 192 | ``` 193 | 194 | ### Handling webhook requests using events 195 | 196 | Instead of queueing jobs to perform some work when a webhook request comes in, you can opt to listen to the events this package will fire. Whenever a valid request hits your app, the package will fire a `stripe-webhooks::` event. 197 | 198 | The payload of the events will be the instance of `WebhookCall` that was created for the incoming request. 199 | 200 | Let's take a look at how you can listen for such an event. In the `EventServiceProvider` you can register listeners. 201 | 202 | ```php 203 | /** 204 | * The event listener mappings for the application. 205 | * 206 | * @var array 207 | */ 208 | protected $listen = [ 209 | 'stripe-webhooks::source.chargeable' => [ 210 | App\Listeners\ChargeSource::class, 211 | ], 212 | ]; 213 | ``` 214 | 215 | Here's an example of such a listener: 216 | 217 | ```php 218 | payload` 232 | } 233 | } 234 | ``` 235 | 236 | We highly recommend that you make the event listener queueable, as this will minimize the response time of the webhook requests. This allows you to handle more Stripe webhook requests and avoid timeouts. 237 | 238 | The above example is only one way to handle events in Laravel. To learn the other options, read [the Laravel documentation on handling events](https://laravel.com/docs/5.5/events). 239 | 240 | ## Advanced usage 241 | 242 | ### Retry handling a webhook 243 | 244 | All incoming webhook requests are written to the database. This is incredibly valuable when something goes wrong while handling a webhook call. You can easily retry processing the webhook call, after you've investigated and fixed the cause of failure, like this: 245 | 246 | ```php 247 | use Spatie\WebhookClient\Models\WebhookCall; 248 | use Spatie\StripeWebhooks\ProcessStripeWebhookJob; 249 | 250 | dispatch(new ProcessStripeWebhookJob(WebhookCall::find($id))); 251 | ``` 252 | 253 | ### Performing custom logic 254 | 255 | You can add some custom logic that should be executed before and/or after the scheduling of the queued job by using your own model. You can do this by specifying your own model in the `model` key of the `stripe-webhooks` config file. The class should extend `Spatie\StripeWebhooks\ProcessStripeWebhookJob`. 256 | 257 | Here's an example: 258 | 259 | ```php 260 | use Spatie\StripeWebhooks\ProcessStripeWebhookJob; 261 | 262 | class MyCustomStripeWebhookJob extends ProcessStripeWebhookJob 263 | { 264 | public function handle() 265 | { 266 | // do some custom stuff beforehand 267 | 268 | parent::handle(); 269 | 270 | // do some custom stuff afterwards 271 | } 272 | } 273 | ``` 274 | 275 | ### Determine if a request should be processed 276 | 277 | You may use your own logic to determine if a request should be processed or not. You can do this by specifying your own profile in the `profile` key of the `stripe-webhooks` config file. The class should implement `Spatie\WebhookClient\WebhookProfile\WebhookProfile`. 278 | 279 | In this example we will make sure to only process a request if it wasn't processed before. 280 | 281 | ```php 282 | use Illuminate\Http\Request; 283 | use Spatie\WebhookClient\Models\WebhookCall; 284 | use Spatie\WebhookClient\WebhookProfile\WebhookProfile; 285 | 286 | class StripeWebhookProfile implements WebhookProfile 287 | { 288 | public function shouldProcess(Request $request): bool 289 | { 290 | return ! WebhookCall::where('payload->id', $request->get('id'))->exists(); 291 | } 292 | } 293 | ``` 294 | 295 | ### Handling multiple signing secrets 296 | 297 | When using [Stripe Connect](https://stripe.com/connect) you might want to the package to handle multiple endpoints and secrets. Here's how to configurate that behaviour. 298 | 299 | If you are using the `Route::stripeWebhooks` macro, you can append the `configKey` as follows: 300 | 301 | ```php 302 | Route::stripeWebhooks('webhook-url/{configKey}'); 303 | ``` 304 | 305 | Alternatively, if you are manually defining the route, you can add `configKey` like so: 306 | 307 | ```php 308 | Route::post('webhook-url/{configKey}', '\Spatie\StripeWebhooks\StripeWebhooksController'); 309 | ``` 310 | 311 | If this route parameter is present the verify middleware will look for the secret using a different config key, by appending the given the parameter value to the default config key. E.g. If Stripe posts to `webhook-url/my-named-secret` you'd add a new config named `signing_secret_my-named-secret`. 312 | 313 | Example config for Connect might look like: 314 | 315 | ```php 316 | // secret for when Stripe posts to webhook-url/account 317 | 'signing_secret_account' => 'whsec_abc', 318 | // secret for when Stripe posts to webhook-url/connect 319 | 'signing_secret_connect' => 'whsec_123', 320 | ``` 321 | 322 | ### Transforming the Webhook payload into a Stripe Object 323 | 324 | You can transform the Webhook payload into a Stripe object to assist in accessing its various methods and properties. 325 | 326 | To do this, use the `Stripe\Event::constructFrom($payload)` method with the `WebhookCall`'s payload: 327 | 328 | ```php 329 | use Stripe\Event; 330 | 331 | // ... 332 | 333 | public function handle(WebhookCall $webhookCall) 334 | { 335 | /** @var \Stripe\StripeObject|null */ 336 | $stripeObject = Event::constructFrom($webhookCall->payload)->data?->object; 337 | } 338 | ``` 339 | 340 | For example, if you have setup a Stripe webhook for the `invoice.created` event, you can transform the payload into a `StripeInvoice` object: 341 | 342 | ```php 343 | /** @var \Stripe\StripeInvoice|null */ 344 | $stripeInvoice = Event::constructFrom($webhookCall->payload)->data?->object; 345 | 346 | // $stripeInvoice->status 347 | // $stripeInvoice->amount_due 348 | // $stripeInvoice->amount_paid 349 | // $stripeInvoice->amount_remaining 350 | 351 | foreach ($stripeInvoice->lines as $invoiceLine) { 352 | // ... 353 | } 354 | ``` 355 | 356 | ### About Cashier 357 | 358 | [Laravel Cashier](https://laravel.com/docs/5.5/billing#handling-stripe-webhooks) allows you to easily handle Stripe subscriptions. You may install it in the same application together with `laravel-stripe-webhooks`. There are no known conflicts. 359 | 360 | ## Changelog 361 | 362 | Please see [CHANGELOG](CHANGELOG.md) for more information about what has changed recently. 363 | 364 | ## Testing 365 | 366 | ```bash 367 | composer test 368 | ``` 369 | 370 | ## Contributing 371 | 372 | Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details. 373 | 374 | ## Security 375 | 376 | If you've found a bug regarding security please mail [security@spatie.be](mailto:security@spatie.be) instead of using the issue tracker. 377 | 378 | ## Credits 379 | 380 | - [Freek Van der Herten](https://github.com/freekmurze) 381 | - [All Contributors](../../contributors) 382 | 383 | A big thank you to [Sebastiaan Luca](https://twitter.com/sebastiaanluca) who generously shared his Stripe webhook solution that inspired this package. 384 | 385 | ## License 386 | 387 | The MIT License (MIT). Please see [License File](LICENSE.md) for more information. 388 | -------------------------------------------------------------------------------- /UPGRADING.md: -------------------------------------------------------------------------------- 1 | 2 | ### From v1 to v2 3 | 4 | Version 2 was created because to use our `laravel-webhooks-client` package under the hood, you'll have to make a few changes to make this work. 5 | 6 | Publish the new migration with `php artisan vendor:publish --provider="Spatie\WebhookClient\WebhookClientServiceProvider" --tag="migrations"`. You can keep the old `stripe_webhook_calls` table if you want, all new calls will be stored in the new `webhook_calls` table. 7 | 8 | Change the `model` key in the `stripe-webhooks.php` config file to `'model' => \Spatie\StripeWebhooks\ProcessStripeWebhookJob::class` or if you have a custom model, make sure it extends the new `ProcessStripeWebhookJob` class and update your implementation accordingly. 9 | 10 | Change your webhook handlers/listeners to accept the new `\Spatie\WebhookClient\Models\WebhookCall` model instead of the `\Spatie\StripeWebhooks\StripeWebhookCall` model. 11 | 12 | Retrying a webhook call has changed, this is now done by dispatching the new job: `dispatch(new ProcessStripeWebhookJob(WebhookCall::find($id)));` 13 | 14 | 15 | ### From v2 to v3 16 | #### Create Migration 17 | ```bash 18 | php artisan make:migration add_columns_to_webhook_calls 19 | ``` 20 | 21 | ### Here's an example how your migration should look. 22 | ```php 23 | string('url')->nullable(); 42 | $table->json('headers')->nullable(); 43 | $table->json('payload')->change(); 44 | }); 45 | } 46 | 47 | /** 48 | * Reverse the migrations. 49 | * 50 | * @return void 51 | */ 52 | public function down(): void 53 | { 54 | Schema::table('webhook_calls', function (Blueprint $table) { 55 | $table->dropColumn('url'); 56 | $table->dropColumn('headers'); 57 | $table->text('payload')->change(); 58 | }); 59 | } 60 | } 61 | ``` 62 | 63 | 64 | ### Config file changes 65 | 66 | If you have published a config file previously please follow these steps: 67 | 68 | 1, Update "model" to point to the following WebhookCall class: 69 | 70 | ```php 71 | /* 72 | * The classname of the model to be used. The class should equal or extend 73 | * Spatie\WebhookClient\Models\WebhookCall. 74 | */ 75 | 'model' => \Spatie\WebhookClient\Models\WebhookCall::class, 76 | ``` 77 | 78 | 2, Add two new references for profile and verify_signature: 79 | 80 | ```php 81 | /* 82 | * This class determines if the webhook call should be stored and processed. 83 | */ 84 | 'profile' => \Spatie\StripeWebhooks\StripeWebhookProfile::class, 85 | 86 | /* 87 | * When disabled, the package will not verify if the signature is valid. 88 | * This can be handy in local environments. 89 | */ 90 | 'verify_signature' => env('STRIPE_SIGNATURE_VERIFY', true), 91 | 92 | ``` 93 | 94 | Please see the readme for more information on verify_signature and how its used. 95 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "spatie/laravel-stripe-webhooks", 3 | "description": "Handle stripe webhooks in a Laravel application", 4 | "keywords": [ 5 | "spatie", 6 | "laravel-stripe-webhooks" 7 | ], 8 | "homepage": "https://github.com/spatie/laravel-stripe-webhooks", 9 | "license": "MIT", 10 | "authors": [ 11 | { 12 | "name": "Freek Van der Herten", 13 | "email": "freek@spatie.be", 14 | "homepage": "https://spatie.be", 15 | "role": "Developer" 16 | } 17 | ], 18 | "minimum-stability": "dev", 19 | "prefer-stable": true, 20 | "require": { 21 | "php": "^8.0", 22 | "illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0", 23 | "spatie/laravel-webhook-client": "^3.0", 24 | "stripe/stripe-php": "^7.51|^8.0|^9.0|^10.0|^11.0|^12.0|^13.0|^14.0|^15.0|^16.0|^17.0" 25 | }, 26 | "require-dev": { 27 | "orchestra/testbench": "^6.0|^7.0|^8.0|^9.0|^10.0", 28 | "phpunit/phpunit": "^9.4|^10.5|^11.5.3" 29 | }, 30 | "autoload": { 31 | "psr-4": { 32 | "Spatie\\StripeWebhooks\\": "src" 33 | } 34 | }, 35 | "autoload-dev": { 36 | "psr-4": { 37 | "Spatie\\StripeWebhooks\\Tests\\": "tests" 38 | } 39 | }, 40 | "scripts": { 41 | "test": "vendor/bin/phpunit" 42 | }, 43 | "config": { 44 | "sort-packages": true 45 | }, 46 | "extra": { 47 | "laravel": { 48 | "providers": [ 49 | "Spatie\\StripeWebhooks\\StripeWebhooksServiceProvider" 50 | ] 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /config/stripe-webhooks.php: -------------------------------------------------------------------------------- 1 | env('STRIPE_WEBHOOK_SECRET'), 9 | 10 | /* 11 | * You can define a default job that should be run for all other Stripe event type 12 | * without a job defined in next configuration. 13 | * You may leave it empty to store the job in database but without processing it. 14 | */ 15 | 'default_job' => '', 16 | 17 | /* 18 | * You can define the job that should be run when a certain webhook hits your application 19 | * here. The key is the name of the Stripe event type with the `.` replaced by a `_`. 20 | * 21 | * You can find a list of Stripe webhook types here: 22 | * https://stripe.com/docs/api#event_types. 23 | */ 24 | 'jobs' => [ 25 | // 'source_chargeable' => \App\Jobs\StripeWebhooks\HandleChargeableSource::class, 26 | // 'charge_failed' => \App\Jobs\StripeWebhooks\HandleFailedCharge::class, 27 | ], 28 | 29 | /* 30 | * The classname of the model to be used. The class should equal or extend 31 | * Spatie\WebhookClient\Models\WebhookCall. 32 | */ 33 | 'model' => \Spatie\WebhookClient\Models\WebhookCall::class, 34 | 35 | /** 36 | * This class determines if the webhook call should be stored and processed. 37 | */ 38 | 'profile' => \Spatie\StripeWebhooks\StripeWebhookProfile::class, 39 | 40 | /* 41 | * Specify a connection and or a queue to process the webhooks 42 | */ 43 | 'connection' => env('STRIPE_WEBHOOK_CONNECTION'), 44 | 'queue' => env('STRIPE_WEBHOOK_QUEUE'), 45 | 46 | /* 47 | * When disabled, the package will not verify if the signature is valid. 48 | * This can be handy in local environments. 49 | */ 50 | 'verify_signature' => env('STRIPE_SIGNATURE_VERIFY', true), 51 | ]; 52 | -------------------------------------------------------------------------------- /src/Exceptions/WebhookFailed.php: -------------------------------------------------------------------------------- 1 | id}` of type `{$webhookCall->type} because the configured jobclass `$jobClass` does not exist."); 13 | } 14 | 15 | public static function missingType(WebhookCall $webhookCall): self 16 | { 17 | return new static("Webhook call id `{$webhookCall->id}` did not contain a type. Valid Stripe webhook calls should always contain a type."); 18 | } 19 | 20 | public function render($request) 21 | { 22 | return response(['error' => $this->getMessage()], 400); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/ProcessStripeWebhookJob.php: -------------------------------------------------------------------------------- 1 | onConnection(config('stripe-webhooks.connection')); 15 | $this->onQueue(config('stripe-webhooks.queue')); 16 | } 17 | 18 | public function handle() 19 | { 20 | if (! isset($this->webhookCall->payload['type']) || $this->webhookCall->payload['type'] === '') { 21 | throw WebhookFailed::missingType($this->webhookCall); 22 | } 23 | 24 | event("stripe-webhooks::{$this->webhookCall->payload['type']}", $this->webhookCall); 25 | 26 | $jobClass = $this->determineJobClass($this->webhookCall->payload['type']); 27 | 28 | if ($jobClass === '') { 29 | return; 30 | } 31 | 32 | if (! class_exists($jobClass)) { 33 | throw WebhookFailed::jobClassDoesNotExist($jobClass, $this->webhookCall); 34 | } 35 | 36 | dispatch(new $jobClass($this->webhookCall)); 37 | } 38 | 39 | protected function determineJobClass(string $eventType): string 40 | { 41 | $jobConfigKey = str_replace('.', '_', $eventType); 42 | 43 | $defaultJob = config('stripe-webhooks.default_job', ''); 44 | 45 | return config("stripe-webhooks.jobs.{$jobConfigKey}", $defaultJob); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/StripeSignatureValidator.php: -------------------------------------------------------------------------------- 1 | header('Stripe-Signature'); 20 | $secret = $config->signingSecret; 21 | 22 | try { 23 | Webhook::constructEvent($request->getContent(), $signature, $secret); 24 | } catch (Exception) { 25 | return false; 26 | } 27 | 28 | return true; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/StripeWebhookProfile.php: -------------------------------------------------------------------------------- 1 | where('payload->id', $request->get('id'))->exists(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/StripeWebhooksController.php: -------------------------------------------------------------------------------- 1 | 'stripe', 15 | 'signing_secret' => ($configKey) ? 16 | config('stripe-webhooks.signing_secret_'.$configKey) : 17 | config('stripe-webhooks.signing_secret'), 18 | 'signature_header_name' => 'Stripe-Signature', 19 | 'signature_validator' => StripeSignatureValidator::class, 20 | 'webhook_profile' => config('stripe-webhooks.profile'), 21 | 'webhook_model' => config('stripe-webhooks.model'), 22 | 'process_webhook_job' => ProcessStripeWebhookJob::class, 23 | ]); 24 | 25 | return (new WebhookProcessor($request, $webhookConfig))->process(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/StripeWebhooksServiceProvider.php: -------------------------------------------------------------------------------- 1 | name('laravel-stripe-webhooks') 15 | ->hasConfigFile(); 16 | 17 | Route::macro('stripeWebhooks', function ($url) { 18 | return Route::post($url, '\Spatie\StripeWebhooks\StripeWebhooksController'); 19 | }); 20 | } 21 | } 22 | --------------------------------------------------------------------------------