larasell-dev / stripe
Stripe payments for Larasell
Requires
- php: ^8.2
- larasell-dev/larasell: ^1.2
- stripe/stripe-php: ^21.3
Requires (Dev)
- laravel/pint: ^1.30
- orchestra/testbench: ^11.0
- pestphp/pest: ^5.1
This package is not auto-updated.
Last update: 2026-08-29 12:44:42 UTC
README
Stripe Checkout payments for Larasell.
Installation
composer require larasell-dev/stripe
Add the Stripe credentials to the application environment:
STRIPE_KEY=pk_test_... STRIPE_SECRET=sk_test_... STRIPE_WEBHOOK_SECRET=whsec_...
Register the payment method in config/larasell.php:
use Larasell\Stripe\StripePaymentProvider; 'payments' => [ 'default' => 'stripe', 'methods' => [ 'stripe' => [ 'driver' => 'stripe', 'provider' => StripePaymentProvider::class, ], ], ],
Checkout
The storefront supplies its success and cancellation URLs:
$result = $checkout->create( cart: $cart, data: $customerData, paymentMethod: 'stripe', paymentOptions: [ 'success_url' => route('checkout.success', absolute: true), 'cancel_url' => route('checkout.cancel', absolute: true), ], ); return $result->requiresRedirect() ? $result->redirect() : redirect()->route('orders.show', $result->order);
Additional Stripe Checkout Session options can be supplied under
session_options. Larasell-controlled amount, customer, URL, and metadata
fields cannot be overridden.
paymentOptions: [
'success_url' => route('checkout.success', absolute: true),
'cancel_url' => route('checkout.cancel', absolute: true),
'session_options' => [
'locale' => 'de',
'allow_promotion_codes' => true,
],
],
Webhooks
The package registers:
POST /larasell/stripe/webhook
Configure Stripe to deliver these events:
checkout.session.completedcheckout.session.async_payment_succeededcheckout.session.async_payment_failedcheckout.session.expired
Webhook signatures are verified and Stripe event IDs are stored to prevent duplicate processing. Browser redirects never mark an order as paid.
Also configure Stripe to deliver the refund lifecycle events:
refund.createdrefund.updatedrefund.failed
Refunds
Create full or partial refunds from a successful Stripe payment:
$refund = $payment->refund(); $refund = $payment->refund(Price::of(2500));
Amounts use the same integer minor units as Larasell prices. Stripe refund options such as a reason can be passed separately:
$refund = $payment->refund(Price::of(2500), [ 'refund_options' => [ 'reason' => 'requested_by_customer', ], ]);
The initial Stripe response sets the local refund status. Pending refunds are subsequently finalized by signed webhooks. Refunding never cancels an order; an unfulfilled, fully refunded order can be cancelled explicitly.
To register the webhook route yourself, call this before package providers boot:
use Larasell\Stripe\Stripe; Stripe::ignoreRoutes();
Publish the configuration or migrations when customization is required:
php artisan vendor:publish --tag=larasell-stripe-config php artisan vendor:publish --tag=larasell-stripe-migrations