Download the PHP package lab404/laravel-stripe-server without Composer
On this page you can find all versions of the php package lab404/laravel-stripe-server. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-stripe-server
Laravel Stripe Server
Laravel Stripe Server is a library to handle Stripe SCA checkout for your models.
- Requirements
- Intended workflow
- Installation
- Going deeper
- Nova
- Ideas
- Tests
- Contribute
- Licence
Requirements
- 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
Ordermodel with a stripe checkout. You create the order in your controller.
Example model:
- 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
CheckoutSessionCompletedevent:
Example listener:
- You can use your model like this:
Installation
-
Require it with Composer:
-
Configure your Stripe keys in
config/services.php. -
Publish
migrationsandviewswithphp artisan vendor:publish --tag=stripe-server. -
Migrate
2019_06_19_101000_create_stripe_checkouts_table.php. -
Schedule the command in
app\Console\Kernel.php: - Add the
Lab404\StripeServer\Models\HasStripeCheckoutorHasStripeCheckouts(if a model can have multiple checkouts) to your chargeable models.
Going deeper
Stripe documentation
- Checkout Server Quickstart
- Checkout Purchase Fulfillment
- Going Live with Checkout
- Strong Customer Authentication
Access the Stripe Manager
With facade:
With DI:
With container:
Available methods
redirectSession(string $session_id): Illuminate\Contracts\View\ViewregisterCheckout(\Stripe\Checkout\Session $session, Model $model): Illuminate\Database\Eloquent\ModelrequestCreateCharge(): StripeServer\Requests\CreateChargerequestCreateSession(): StripeServer\Requests\CreateSessionrequestPaymentIntent(string $id): StripeServer\Requests\PaymentIntentrequestEvents(string $type, int $hours = 24): StripeServer\Requests\EventsrequestSessionCheckoutCompletedEvents(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:
Model with one checkout
When a model has the Lab404\StripeServer\Models\HasStripeCheckout you have access to the following methods and scopes:
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:
Artisan commands
stripe:checkout-session-completed
Get all checkout.session.completed Stripe events and dispatch the event CheckoutSessionCompleted for each with the succeeded status.
stripe:events
Get all Stripe events and dispatch StripeEvent for each one.
stripe:purge
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:
Nova
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
Tests
TODO
Contribute
This package is still in development, feel free to contribute!
Contributors
- MarceauKa
- and all others contributors
Licence
MIT