{"id":19153657,"url":"https://github.com/404labfr/laravel-stripe-server","last_synced_at":"2025-05-07T06:27:24.466Z","repository":{"id":57010474,"uuid":"192762587","full_name":"404labfr/laravel-stripe-server","owner":"404labfr","description":"Laravel Stripe Server is a library to handle Stripe SCA checkout.","archived":false,"fork":false,"pushed_at":"2020-07-14T17:04:05.000Z","size":46,"stargazers_count":15,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-19T19:05:32.465Z","etag":null,"topics":["checkout","laravel","laravel-package","stripe"],"latest_commit_sha":null,"homepage":"https://www.404lab.fr","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/404labfr.png","metadata":{"files":{"readme":"readme.md","changelog":"changelog.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-06-19T15:50:24.000Z","updated_at":"2022-05-13T04:26:42.000Z","dependencies_parsed_at":"2022-08-21T13:10:18.578Z","dependency_job_id":null,"html_url":"https://github.com/404labfr/laravel-stripe-server","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/404labfr%2Flaravel-stripe-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/404labfr%2Flaravel-stripe-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/404labfr%2Flaravel-stripe-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/404labfr%2Flaravel-stripe-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/404labfr","download_url":"https://codeload.github.com/404labfr/laravel-stripe-server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252826213,"owners_count":21810080,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["checkout","laravel","laravel-package","stripe"],"created_at":"2024-11-09T08:23:45.544Z","updated_at":"2025-05-07T06:27:24.447Z","avatar_url":"https://github.com/404labfr.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Stripe Server\n\nLaravel Stripe Server is a library to handle Stripe SCA checkout for your models.\n\n- [Requirements](#requirements)\n- [Intended workflow](#intended-workflow)\n- [Installation](#installation)\n- [Going deeper](#going-deeper)\n- [Nova](#nova)\n- [Ideas](#ideas)\n- [Tests](#tests)\n- [Contribute](#contribute)\n- [Licence](#licence)\n \n## Requirements\n\n- Laravel 6.x or 7.x\n- PHP \u003e= 7.2\n\n### Laravel support\n\n| Version       | Release       |\n|:-------------:|:-------------:|\n| 6.x, 7.x      | 1.1           |\n| 6.x           | 1.0           |\n| 5.8           | 0.3           |\n\n## Intended workflow\n\n- You have an `Order` model with a stripe checkout. You create the order in your controller.\n\nExample model:\n```php\nuse App\\Models\\Order;\nuse Lab404\\StripeServer\\Facades\\Stripe;\nuse Illuminate\\Http\\Request;\n\nclass OrderController\n{\n    public function store(Request $request)\n    {\n        // Create your order\n        $order = new Order($request-\u003evalidated());\n        $order-\u003esave();\n        \n        // Create your checkout session\n        $session = Stripe::requestCreateSession()\n                    -\u003esetCustomerEmail($request-\u003euser()-\u003eemail)\n                    -\u003esetReturnUrls($confirm_url, $cancel_url)\n                    -\u003esetProduct('T-shirt', 5000, 'EUR', 1, $picture_url)\n                    -\u003ecall();\n        \n        // Create your checkout model\n        $checkout = Stripe::registerCheckout($session, $order);\n        \n        return Stripe::redirectSession($response-\u003eid);\n    }\n}\n```\n\n- Your user is redirected to stripe, he fills his informations and he's redirected to your success URL. The order is not paid yet.\nAsynchronously, the plugin will try to get new events from Stripe and will dispatch the `CheckoutSessionCompleted` event:\n\nExample listener:\n```php\nuse Lab404\\StripeServer\\Events\\CheckoutSessionCompleted;\nuse Lab404\\StripeServer\\Models\\StripeCheckout;\n\nclass CheckoutListener\n{\n    public function handle(CheckoutSessionCompleted $event): void\n    {\n        /** @var StripeCheckout $checkout */\n        $checkout = $event-\u003echeckout;\n        /** Your charged model */\n        $chargeable = $checkout-\u003echargeable;\n        /** The PaymentIntent returned by Stripe */\n        $payment = $event-\u003epaymentIntent;\n      \n        /** Important! Mark the checkout as paid */\n        $checkout-\u003emarkAsPaid();\n    }\n}\n```\n\n- You can use your model like this:\n```php\n$order = Order::with('checkout')-\u003efirst();\nif ($order-\u003echeckout-\u003eis_paid) {\n    echo 'Order is paid';\n} else {\n    echo 'Order is not paid';\n}\n```\n\n## Installation\n\n1. Require it with Composer:\n```bash\ncomposer require lab404/laravel-stripe-server\n```\n\n2. Configure your Stripe keys in `config/services.php`.\n\n3. Publish `migrations` and `views` with `php artisan vendor:publish --tag=stripe-server`.\n\n4. Migrate `2019_06_19_101000_create_stripe_checkouts_table.php`.\n\n5. Schedule the command in `app\\Console\\Kernel.php`:\n```php\nprotected function schedule(Schedule $schedule)\n{\n    $schedule-\u003ecommand('stripe:checkout-session-completed')-\u003eeveryMinute();\n}\n```\n\n6. Add the `Lab404\\StripeServer\\Models\\HasStripeCheckout` or `HasStripeCheckouts` (if a model can have multiple checkouts) to your chargeable models. \n\n## Going deeper\n\n### Stripe documentation\n\n- [Checkout Server Quickstart](https://stripe.com/docs/payments/checkout/server)\n- [Checkout Purchase Fulfillment](https://stripe.com/docs/payments/checkout/fulfillment)\n- [Going Live with Checkout](https://stripe.com/docs/payments/checkout/live)\n- [Strong Customer Authentication](https://stripe.com/docs/strong-customer-authentication)\n\n### Access the Stripe Manager\n\nWith facade:\n```php\nStripe::method();\n```\n\nWith DI:\n```\npublic function index(Lab404\\StripeServer\\Stripe $stripe)\n{\n    $stripe-\u003emethod();\n}\n```\n\nWith container:\n```\napp('stripe')-\u003emethod();\n```\n\n### Available methods\n\n- `redirectSession(string $session_id): Illuminate\\Contracts\\View\\View`\n- `registerCheckout(\\Stripe\\Checkout\\Session $session, Model $model): Illuminate\\Database\\Eloquent\\Model`\n- `requestCreateCharge(): StripeServer\\Requests\\CreateCharge`\n- `requestCreateSession(): StripeServer\\Requests\\CreateSession`\n- `requestPaymentIntent(string $id): StripeServer\\Requests\\PaymentIntent`\n- `requestEvents(string $type, int $hours = 24): StripeServer\\Requests\\Events`\n- `requestSessionCheckoutCompletedEvents(int $hours = 24): StripeServer\\Requests\\Events`\n\n### Working with your models\n\n#### Model with many checkouts\n\nWhen a model has the `Lab404\\StripeServer\\Models\\HasStripeCheckouts` you have access to the following methods and scopes:\n```php\n// Scopes\nModel::hasCheckouts()-\u003eget();\nModel::hasPaidCheckouts()-\u003eget();\nModel::hasUnpaidCheckouts()-\u003eget();\n\n// Methods\n$models-\u003echeckouts(); // returns all checkout for the model\n\n// Eager loading\n$models = Model::with('checkouts')-\u003eget(); \n```\n\n#### Model with one checkout\n\nWhen a model has the `Lab404\\StripeServer\\Models\\HasStripeCheckout` you have access to the following methods and scopes:\n```php\n// Scopes\nModel::hasCheckout()-\u003eget();\nModel::hasPaidCheckout()-\u003eget();\nModel::hasUnpaidCheckout()-\u003eget();\n\n// Methods\n$models-\u003echeckout(); // returns the checkout for the model\n\n// Eager loading\n$models = Model::with('checkout')-\u003eget(); \n```\n\n### Customize the `StripeCheckout` model\n\nConfigure `model` in `config/stripe-server.php`. Your custom model should extend the default one.\n\n### Customize the redirector\n\nWhen you use the `redirectSession()` method, an instance of `Illuminate\\View\\View` is returned. You can do:\n\n```php\nreturn Stripe::redirectSession('...')-\u003ewith([\n    'title' =\u003e 'My custom title',\n    'message' =\u003e 'My customer redirect message'\n]);\n```\n\n### Artisan commands\n\n#### `stripe:checkout-session-completed`\n\nGet all `checkout.session.completed` Stripe events and dispatch the event `CheckoutSessionCompleted` for each with the `succeeded` status.\n\n#### `stripe:events`\n\nGet all Stripe events and dispatch `StripeEvent` for each one.\n\n#### `stripe:purge`\n\nDelete 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:\n\n```\n$schedule-\u003ecommand('stripe:purge')-\u003edailyAt('12:00');\n```\n\n## Nova\n\nIf you're using [Laravel Nova](https://nova.laravel.com) you can add the `Lab404\\StripeServer\\Nova\\StripeCheckout` resource:\n\n```\nLaravel\\Nova\\Nova::resources([\n    Lab404\\StripeServer\\Nova\\StripeCheckout::class,\n]);\n```\n\nThis 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.\n\n## TODOs and ideas\n\n[x] Purge unpaid stripe checkouts  \n[ ] Refund    \n[ ] Nova actions  \n\n## Tests\n\nTODO\n\n## Contribute\n\nThis package is still in development, feel free to contribute!\n\n### Contributors\n\n- [MarceauKa](https://github.com/MarceauKa)\n- and all others [contributors](https://github.com/404labfr/laravel-impersonate/graphs/contributors)\n\n## Licence\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F404labfr%2Flaravel-stripe-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F404labfr%2Flaravel-stripe-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F404labfr%2Flaravel-stripe-server/lists"}