conedevelopment / bazar-stripe
Stripe payment integration for Bazar.
Installs: 3 190
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 4
Forks: 0
Open Issues: 1
Type:project
Requires
- php: ^8.2 || ^8.3
- conedevelopment/bazar: dev-master || ^1.1.2
- stripe/stripe-php: ^16.3
Requires (Dev)
- fakerphp/faker: ^1.9.1
- laravel/laravel: ^11.0
- laravel/pint: ^1.6
- mockery/mockery: ^1.4.4
- nunomaduro/larastan: ^2.1.6
- phpunit/phpunit: ^10.2.5
This package is auto-updated.
Last update: 2024-11-21 09:40:35 UTC
README
Installation
composer require conedevelopment/bazar-stripe
Configuration
.env
STRIPE_TEST_MODE= STRIPE_API_KEY= STRIPE_SECRET=
Bazar Config
// config/bazar.php 'gateway' => [ 'drivers' => [ // ... 'stripe' => [ 'test_mode' => env('STRIPE_TEST_MODE', false), 'api_key' => env('STRIPE_API_KEY'), 'secret' => env('STRIPE_SECRET'), ], ], ], // ...
Webhook Events
php artisan make:listener StripeWebhookHandler
namespace App\Listeners; use Cone\Bazar\Stripe\WebhookInvoked; use Stripe\Event; class StripeWebhookHandler { public function handle(WebhookInvoked $event): void { // https://stripe.com/docs/api/events/types $callback = match ($event->event->type) { 'payment_intent.payment_failed' => function (Event $event): void { // mark transaction as failed }, 'payment_intent.succeeded' => function (Event $event): void { // mark transaction as completed and order as paid }, default => function (): void { // }, }; call_user_func_array($callback, [$event->event]); } }
Tip
If Event Discovery is disabled, make sure the listener is bound to the WebhookInvoked
event in your EventServiceProvider
.