Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Stripe Php Laravel Package

stripe/stripe-php

Official Stripe PHP SDK for accessing the Stripe API. Provides resource classes that map to API objects, auto-initialize from responses, and support many API versions. Install via Composer and use with PHP 7.2+.

View on GitHub
Deep Wiki
Context7

PHP library for the Stripe API.

Frequently asked questions about Stripe Php
How do I install the Stripe PHP SDK in a Laravel project?
Run `composer require stripe/stripe-php` to install via Composer. Laravel’s autoloader will handle the rest—no manual includes are needed. For non-Composer setups, download the SDK and include `init.php` manually.
What Laravel versions does the Stripe PHP SDK support?
The SDK works with Laravel 5.5+ (PHP 7.2+ required). While PHP 7.2/7.3 are technically supported, Stripe recommends upgrading to PHP 8.x for security and performance. Laravel 8/9/10 are fully compatible.
How do I securely store Stripe API keys in Laravel?
Use Laravel’s `.env` file to store keys (e.g., `STRIPE_KEY=sk_test_...`). Bind the `StripeClient` in a service provider to inject the key dynamically. Avoid hardcoding keys in config files or code.
Can I use the SDK with Laravel’s service container?
Yes. Bind the `StripeClient` as a singleton in a service provider (e.g., `AppServiceProvider`) to reuse the client across requests. For multi-tenancy, bind it contextually (e.g., per-request) using Laravel’s container.
How do I handle Stripe webhooks in Laravel?
Use Laravel’s middleware (`VerifyWebhookSignature`) to validate signatures. Route webhooks to a controller or queue job (e.g., `Route::post('/stripe/webhook', [StripeWebhookController::class, 'handle'])`). For async processing, dispatch jobs to Laravel’s queue.
What’s the best way to test Stripe integrations in Laravel?
Mock Stripe responses with Laravel’s `Http::fake()` or `stripe-mock` for unit tests. For webhook tests, verify signatures using `VerifyWebhookSignature` middleware. Avoid hitting Stripe’s live API during CI/CD.
How do I optimize performance for high-traffic Laravel apps?
Disable telemetry with `Stripe::setEnableTelemetry(false)` if unused. Cache Laravel’s config (`php artisan config:cache`) to reduce API key lookups. For batch operations, use Stripe’s batch endpoints or Laravel’s queue workers.
Are there Laravel-specific abstractions for the Stripe SDK?
Yes. Create a facade (e.g., `PaymentFacade`) or service class to wrap SDK calls (e.g., `PaymentService::createCustomer()`). This improves testability and decouples your app from the SDK’s internals.
How do I handle Stripe errors in Laravel?
Extend Laravel’s `HttpException` or create a custom `StripeException` class to map Stripe errors (e.g., `invalid_request_error`) to Laravel’s exception hierarchy. Use try-catch blocks around SDK calls for graceful error handling.
What are the alternatives to the Stripe PHP SDK for Laravel?
For lightweight needs, consider `spatie/laravel-stripe` (a Laravel wrapper). For custom HTTP clients, use Guzzle or Symfony’s HTTP client with the SDK’s raw API calls. However, the official SDK is the most maintained and feature-complete option.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai