Installation and setup | laravel-stripe-webhooks-rust | Spatie       

 SPATIE  

laravel-stripe-webhooks-rust
============================

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Laravel-stripe-webhooks-rust](https://spatie.be/docs/laravel-stripe-webhooks-rust/v1)  Installation and setup

 Version   v1      

 Other versions for crawler [v1](https://spatie.be/docs/laravel-stripe-webhooks-rust/v1) 

  Installation and setup    
- [ Introduction ](https://spatie.be/docs/laravel-stripe-webhooks-rust/v1/introduction)
- [ Support us ](https://spatie.be/docs/laravel-stripe-webhooks-rust/v1/support-us)
- [ Installation and setup ](https://spatie.be/docs/laravel-stripe-webhooks-rust/v1/installation-and-setup)
- [ Usage ](https://spatie.be/docs/laravel-stripe-webhooks-rust/v1/usage)
- [ Advanced usage ](https://spatie.be/docs/laravel-stripe-webhooks-rust/v1/advanced-usage)
- [ Testing ](https://spatie.be/docs/laravel-stripe-webhooks-rust/v1/testing)
- [ Changelog ](https://spatie.be/docs/laravel-stripe-webhooks-rust/v1/changelog)

 Installation and setup
======================

###  On this page 

1. [ Signing secret ](#content-signing-secret)
2. [ Storage and routing ](#content-storage-and-routing)

Install the package with Cargo:

```
cargo add spatie-laravel-stripe-webhooks
```

Use Rust 1.99 or newer and `laravel-rust` 0.1.0. The package builds on `spatie-laravel-webhook-client` 0.1.0 and registers its defaults through `spatie-laravel-package-tools`.

SQLite support is enabled by default. For MySQL or PostgreSQL, disable default features and enable `database-mysql` or `database-postgres`, matching your application's Laravel database driver. At least one database driver feature is required by the framework.

Signing secret
--------------------------------------------------------------------------------------------------

Create an endpoint in [Stripe Workbench](https://dashboard.stripe.com/webhooks) and copy its signing secret into your application's environment. A webhook signing secret starts with `whsec_`; it is not your Stripe API key. Keep it out of source control and logs.

The Stripe CLI uses a different signing secret from your Dashboard endpoint. Use the CLI's secret for forwarded local events and the Dashboard secret for events sent directly to your deployed endpoint.

Storage and routing
-----------------------------------------------------------------------------------------------------------------

Register both providers and a stateless route:

```
use laravel::Application;
use spatie_laravel_stripe_webhooks::{service_provider, stripe_webhooks, webhook_client};

let app = Application::configure()
    .with_providers(|providers| {
        providers.add(webhook_client::service_provider());
        providers.add(service_provider());
    })
    .with_routing(|routing, _| {
        routing.routes(|route| {
            route.post("/stripe-webhooks", stripe_webhooks);
        });
    })
    .create();
```

Package Tools registers the client's migration but does not run it. Configure a persistent database connection, then run your application's `migrate` command to create `webhook_calls`. The client provider also registers its pruning command. Do not register a second copy of its migration in the Stripe provider.

Keep the endpoint reachable by Stripe, with HTTPS in production. `routing.routes` does not attach the web middleware group, so this route has no web CSRF check. If your application adds global CSRF middleware, exclude only this endpoint rather than disabling protection for the application.

The provider reads `STRIPE_WEBHOOK_SECRET` through Laravel's environment configuration. Application overrides run after package defaults:

```
use laravel::{Application, config::Env};
use spatie_laravel_stripe_webhooks::{Config, service_provider};

let app = Application::configure()
    .replace_env(Env::default())
    .with_providers(|providers| { providers.add(service_provider()); })
    .with_config(|config, _| {
        config.set(Config::new("whsec_from_your_secret_store"));
    })
    .create();
```

The literal secret above is an example, not a usable Stripe credential. Production applications should load it from their secret store.

Pass the original request body to the handler. Parsing and re-encoding JSON before verification changes the signed bytes and invalidates the signature.

Configure Stripe to send only the event types your application needs. Run a queue worker for asynchronous jobs and monitor failed jobs. See [usage](usage) for dispatch behavior and [advanced usage](advanced-usage) for multiple endpoint secrets.

 A good
match?
-------------

### What we do best

- All things Laravel
- Custom frontend components
- Building APIs
- AI-powered features
- Simplifying things
- Clean solutions
- Integrating services

### Not our cup of tea

- WordPress themes
- Cutting corners
- Free mockups to win a job
- "Just execute the briefing"

 In short: we'd like to be a **substantial part** of your project.

 [ Get in touch via email ](mailto:info@spatie.be?subject=A%20good%20match%21&body=Tell%20us%20as%20much%20as%20you%20can%20about%0A-%20your%20online%20project%0A-%20your%20planning%0A-%20your%20budget%0A-%20%E2%80%A6%0A%0AAnything%20that%20helps%20us%20to%20start%20straightforward%21)
