Laravel Stripe Server is a library to handle Stripe SCA checkout.

1.2.0 2020-07-14 17:03 UTC

This package is auto-updated.

Last update: 2020-10-14 17:28:34 UTC


Laravel Stripe Server is a library to handle Stripe SCA checkout for your models.


  • Laravel 6.x or 7.x
  • PHP >= 7.2

Laravel support

Version Release
6.x, 7.x 1.1
6.x 1.0
5.8 0.3

Intended workflow

  • You have an Order model with a stripe checkout. You create the order in your controller.

Example model:

use App\Models\Order;
use Lab404\StripeServer\Facades\Stripe;
use Illuminate\Http\Request;

class OrderController
    public function store(Request $request)
        // Create your order
        $order = new Order($request->validated());
        // Create your checkout session
        $session = Stripe::requestCreateSession()
                    ->setReturnUrls($confirm_url, $cancel_url)
                    ->setProduct('T-shirt', 5000, 'EUR', 1, $picture_url)
        // Create your checkout model
        $checkout = Stripe::registerCheckout($session, $order);
        return Stripe::redirectSession($response->id);
  • Your user is redirected to stripe, he fills his informations and he's redirected to your success URL. The order is not paid yet. Asynchronously, the plugin will try to get new events from Stripe and will dispatch the CheckoutSessionCompleted event:

Example listener:

use Lab404\StripeServer\Events\CheckoutSessionCompleted;
use Lab404\StripeServer\Models\StripeCheckout;

class CheckoutListener
    public function handle(CheckoutSessionCompleted $event): void
        /** @var StripeCheckout $checkout */
        $checkout = $event->checkout;
        /** Your charged model */
        $chargeable = $checkout->chargeable;
        /** The PaymentIntent returned by Stripe */
        $payment = $event->paymentIntent;
        /** Important! Mark the checkout as paid */
  • You can use your model like this:
$order = Order::with('checkout')->first();
if ($order->checkout->is_paid) {
    echo 'Order is paid';
} else {
    echo 'Order is not paid';


  1. Require it with Composer:
composer require lab404/laravel-stripe-server
  1. Configure your Stripe keys in config/services.php.

  2. Publish migrations and views with php artisan vendor:publish --tag=stripe-server.

  3. Migrate 2019_06_19_101000_create_stripe_checkouts_table.php.

  4. Schedule the command in app\Console\Kernel.php:

protected function schedule(Schedule $schedule)
  1. Add the Lab404\StripeServer\Models\HasStripeCheckout or HasStripeCheckouts (if a model can have multiple checkouts) to your chargeable models.

Going deeper

Stripe documentation

Access the Stripe Manager

With facade:


With DI:

public function index(Lab404\StripeServer\Stripe $stripe)

With container:


Available methods

  • redirectSession(string $session_id): Illuminate\Contracts\View\View
  • registerCheckout(\Stripe\Checkout\Session $session, Model $model): Illuminate\Database\Eloquent\Model
  • requestCreateCharge(): StripeServer\Requests\CreateCharge
  • requestCreateSession(): StripeServer\Requests\CreateSession
  • requestPaymentIntent(string $id): StripeServer\Requests\PaymentIntent
  • requestEvents(string $type, int $hours = 24): StripeServer\Requests\Events
  • requestSessionCheckoutCompletedEvents(int $hours = 24): StripeServer\Requests\Events

Working with your models

Model with many checkouts

When a model has the Lab404\StripeServer\Models\HasStripeCheckouts you have access to the following methods and scopes:

// Scopes

// Methods
$models->checkouts(); // returns all checkout for the model

// Eager loading
$models = Model::with('checkouts')->get(); 

Model with one checkout

When a model has the Lab404\StripeServer\Models\HasStripeCheckout you have access to the following methods and scopes:

// Scopes

// Methods
$models->checkout(); // returns the checkout for the model

// Eager loading
$models = Model::with('checkout')->get(); 

Customize the StripeCheckout model

Configure model in config/stripe-server.php. Your custom model should extend the default one.

Customize the redirector

When you use the redirectSession() method, an instance of Illuminate\View\View is returned. You can do:

return Stripe::redirectSession('...')->with([
    'title' => 'My custom title',
    'message' => 'My customer redirect message'

Artisan commands


Get all checkout.session.completed Stripe events and dispatch the event CheckoutSessionCompleted for each with the succeeded status.


Get all Stripe events and dispatch StripeEvent for each one.


Delete all unpaid StripeCheckout older than the given days. Customize with the --days option, defaults to 7. It's convenient to call it in a scheduler:



If you're using Laravel Nova you can add the Lab404\StripeServer\Nova\StripeCheckout resource:


This resource is not dynamically registered because it's quite simple and you may want to override it. More Nova features like Refund Action or Cards are coming.

TODOs and ideas

[x] Purge unpaid stripe checkouts
[ ] Refund
[ ] Nova actions




This package is still in development, feel free to contribute!