freelancernishad / laravel-stripe
Stripe Payment Gateway integration for Laravel
Package info
github.com/freelancernishad/laravel-stripe
pkg:composer/freelancernishad/laravel-stripe
v1.0.1
2026-05-06 10:58 UTC
Requires
- php: ^8.2
- illuminate/support: ^11.0|^12.0
- stripe/stripe-php: ^10.0|^13.0|^17.0
Requires (Dev)
- orchestra/testbench: ^9.0|^10.0
- phpunit/phpunit: ^10.0|^11.0
README
A reusable and extensible Laravel package for integrating Stripe Payment Gateway. Supports Checkout Sessions, Payment Intents, and Subscriptions.
Features
- Flexible Models: Link payments to any project entity using polymorphic relations.
- Configurable: Easily swap log models and table names.
- Robust Webhooks: Pre-configured webhook handlers for common Stripe events.
- Metadata Support: Store arbitrary JSON data with every transaction.
Installation
- Install the package via composer:
composer require freelancernishad/laravel-stripe
- Publish the config and migrations:
php artisan vendor:publish --tag=stripe-config php artisan vendor:publish --tag=stripe-migrations
- Run the migrations:
php artisan migrate
Configuration
Add your Stripe credentials to your .env file:
STRIPE_KEY=pk_test_... STRIPE_SECRET=sk_test_... STRIPE_WEBHOOK_SECRET=whsec_...
Basic Usage
Checkout Session Example
use FreelancerNishad\Stripe\Services\StripeService; public function checkout(StripeService $stripe) { $session = $stripe->createCheckoutSession(auth()->user(), [ [ 'price_data' => [ 'currency' => 'usd', 'product_data' => ['name' => 'T-shirt'], 'unit_amount' => 2000, ], 'quantity' => 1, ] ], url('/success'), url('/cancel')); return redirect()->to($session->url); }
Customization
Adding Extra Fields
Use the meta_data parameter to store additional info:
$stripe->createCheckoutSession($user, $items, $successUrl, $cancelUrl, false, [ 'order_id' => 123, 'referral' => 'friend' ]);
Overriding the Log Model
- Extend
FreelancerNishad\Stripe\Models\StripeLog. - Map your model in
config/stripe.php:
'models' => [ 'log' => \App\Models\MyStripeLog::class, ],
Webhooks
The package includes a default webhook handler. Point your Stripe Webhook URL to:
https://your-domain.com/v1/payments/stripe/webhook
License
The MIT License (MIT).