PHPackages                             elegantly/laravel-stripe - 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. elegantly/laravel-stripe

ActiveLibrary[Payment Processing](/categories/payments)

elegantly/laravel-stripe
========================

Stripe and Stripe Connect for your Laravel App

v2.2.5(4mo ago)23.3k↓30%[1 PRs](https://github.com/ElegantEngineeringTech/laravel-stripe/pulls)MITPHPPHP ^8.1CI passing

Since Mar 19Pushed 2mo agoCompare

[ Source](https://github.com/ElegantEngineeringTech/laravel-stripe)[ Packagist](https://packagist.org/packages/elegantly/laravel-stripe)[ Docs](https://github.com/ElegantEngineeringTech/laravel-stripe)[ GitHub Sponsors](https://github.com/ElegantEngineeringTech)[ RSS](/packages/elegantly-laravel-stripe/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (14)Versions (21)Used By (0)

Stripe and Stripe Connect Integration for Your Laravel Application
==================================================================

[](#stripe-and-stripe-connect-integration-for-your-laravel-application)

[![Latest Version on Packagist](https://camo.githubusercontent.com/7f67a6523b8fc4c2e5a71942b612475a50baae1c2b846410be68059103ceb7aa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f656c6567616e746c792f6c61726176656c2d7374726970652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/elegantly/laravel-stripe)[![GitHub Tests Action Status](https://camo.githubusercontent.com/798a16ac0631c2ddd33235a4ea758f1a6a06dc1465b9078c71c17a8f6eb69e7d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f456c6567616e74456e67696e656572696e67546563682f6c61726176656c2d7374726970652f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/ElegantEngineeringTech/laravel-stripe/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/314edf5ba85345f97f2e86881c6594881084014b76f549abd6dd5ab97b4aaa50/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f456c6567616e74456e67696e656572696e67546563682f6c61726176656c2d7374726970652f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/ElegantEngineeringTech/laravel-stripe/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/830414c84e3004cc27693c3654226dba1492787e824e5e8debc9c14d2efdc21a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f656c6567616e746c792f6c61726176656c2d7374726970652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/elegantly/laravel-stripe)

A simple way to attach Stripe Customer and Account to your Model in Laravel.

- Stripe webhooks ready to use out of the box
- Access Stripe PHP SDK easily

Installation Guide
------------------

[](#installation-guide)

You can install the package via Composer:

```
composer require elegantly/laravel-stripe
```

You can publish the configuration file with:

```
php artisan vendor:publish --tag="stripe-config"
```

This is the content of the published configuration file:

```
use Elegantly\Stripe\Commands\CreateStripeWebhooksCommand;
use Elegantly\Stripe\ModelRepository;

return [

    'models' => [
        'accounts' => [
            \App\Models\User::class,
        ],
        'customers' => [
            \App\Models\User::class,
        ],
        'repository' => ModelRepository::class,
    ],

    'cache' => [
        'accounts' => true,
        'customers' => false,
    ],

    'key' => env('STRIPE_KEY'),

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

    'version' => env('STRIPE_VERSION'),

    /**
     * This is only used for the CreateStripeWebhooksCommand.
     * You can add more webhooks directly from your Stripe Dashboard.
     */
    'webhooks' => [
        [
            'url' => '/webhooks/stripe',
            'connect' => false,
            'enabled_events' => [
                ...CreateStripeWebhooksCommand::DEFAULT_WEBHOOKS_EVENTS,
            ],
        ],
    ],

];
```

Usage Examples
--------------

[](#usage-examples)

Creating and retrieving a Stripe Account:

```
$user->createStripeAccount();
$user->getStripeAccount();
```

Creating and retrieving a Stripe Customer:

```
$user->createStripeCustomer();
$user->getStripeCustomer();
```

Model Preparation
-----------------

[](#model-preparation)

### Database Setup

[](#database-setup)

This package relies on columns you need to add to any Model that has a Stripe customer or account. To do so, we provide a migration that will automatically add the required columns to your models. To configure which models are related to Stripe, you must edit the configuration file.

### Adding the Necessary Trait

[](#adding-the-necessary-trait)

Add the `HasStripeCustomer` trait to your Model:

```
class Organization extends Model
{
    use HasStripeCustomer;
    // ...
}
```

### Configuring Models

[](#configuring-models)

By default, the package assumes that your Stripe objects are attached to your User model. If this is not the case, you will need to edit the configuration file like this:

```
'models' => [
    'accounts' => [
        \App\Models\User::class,
    ],
    'customers' => [
        \App\Models\Organization::class,
    ],
    'repository' => ModelRepository::class,
],
```

### Running Migrations

[](#running-migrations)

```
php artisan vendor:publish --tag="stripe-migrations"
php artisan vendor:publish --provider="Spatie\WebhookClient\WebhookClientServiceProvider" --tag="webhook-client-migrations"
php artisan migrate
```

Webhook Configuration
---------------------

[](#webhook-configuration)

This package comes with the command `stripe:create-webhooks`, which will create and configure webhooks on the Stripe dashboard for you. All you need to do is edit the webhooks and the endpoints you want to enable in the configuration file.

### Editing Configuration

[](#editing-configuration)

For example, you could configure two different webhooks with different routes and endpoints like so:

```
return [

    // Other configurations...

    /**
     * This is only used for the CreateStripeWebhooksCommand.
     * You can add more webhooks directly from your Stripe Dashboard.
     */
    'webhooks' => [
        [
            'url' => '/stripe/webhook/account',
            'connect' => false,
            'enabled_events' => [
                ...CreateStripeWebhooksCommand::DEFAULT_WEBHOOKS_EVENTS,
                'checkout.session.expired',
                'checkout.session.completed',
                'checkout.session.async_payment_succeeded',
                'checkout.session.async_payment_failed',
            ],
        ],
        [
            'url' => '/stripe/webhook/connect',
            'connect' => true,
            'enabled_events' => [
                ...CreateStripeWebhooksCommand::DEFAULT_WEBHOOKS_EVENTS,
            ],
        ],
    ],

];
```

### Running the Command

[](#running-the-command)

Once you are satisfied with the configurations, you just need to run:

```
php artisan stripe:create-webhooks
```

### Activating Webhooks on Stripe

[](#activating-webhooks-on-stripe)

All the webhooks configured by this command are disabled by default to prevent unexpected behavior. When you are ready, activate them from your Stripe Dashboard.

### Listening to Stripe Events in Your Application

[](#listening-to-stripe-events-in-your-application)

Now that Stripe sends webhooks to your app, you can listen to them from `EventServiceProvider`.

This package relies on the great `spatie/laravel-stripe-webhooks` package. You must [follow their documentation](https://github.com/spatie/laravel-stripe-webhooks) to set up your listeners.

### Upgrading Stripe's Webhook version

[](#upgrading-stripes-webhook-version)

Running Tests
-------------

[](#running-tests)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Quentin Gabriele](https://github.com/QuentinGab)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance83

Actively maintained with recent releases

Popularity24

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 76.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~37 days

Recently: every ~72 days

Total

19

Last Release

124d ago

Major Versions

v0.0.4 → v1.0.02024-03-20

v1.1.0 → v2.0.02024-05-26

PHP version history (2 changes)v0.0.1PHP ^8.2

v0.0.2PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/d769563728757858e249f266ac2555f28db5640124df92821ed17d93ee76fc7b?d=identicon)[QuentinGab](/maintainers/QuentinGab)

---

Top Contributors

[![QuentinGab](https://avatars.githubusercontent.com/u/40128136?v=4)](https://github.com/QuentinGab "QuentinGab (63 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (13 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (6 commits)")

---

Tags

laravelphpstripelaravelElegantlyLaravel-Stripe

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/elegantly-laravel-stripe/health.svg)

```
[![Health](https://phpackages.com/badges/elegantly-laravel-stripe/health.svg)](https://phpackages.com/packages/elegantly-laravel-stripe)
```

###  Alternatives

[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[elegantly/laravel-invoices

Store invoices safely in your Laravel application

23131.8k](/packages/elegantly-laravel-invoices)[danestves/laravel-polar

A package to easily integrate your Laravel application with Polar.sh

7812.3k](/packages/danestves-laravel-polar)[elegantly/laravel-money

Use Brick/Money in your Laravel app

1946.9k4](/packages/elegantly-laravel-money)[musahmusah/laravel-multipayment-gateways

A Laravel Package that makes implementation of multiple payment Gateways endpoints and webhooks seamless

852.2k1](/packages/musahmusah-laravel-multipayment-gateways)[elegantly/laravel-translator

All on one translations management for Laravel

6216.9k](/packages/elegantly-laravel-translator)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
