PHP code example of conedevelopment / bazar-stripe
1. Go to this page and download the library: Download conedevelopment/bazar-stripe library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
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]);
}
}
sh
php artisan make:listener StripeWebhookHandler
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.