1. Go to this page and download the library: Download rhaima/laravel-flouci 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/ */
use Flouci\Laravel\Enums\PaymentStatus;
$verification = Flouci::verifyPayment($request->query('payment_id'));
$status = PaymentStatus::fromVerification($verification);
if ($status?->isPaid()) {
// mark the order as paid
}
Route::flouciWebhook(); // GET|POST /flouci/webhook, named flouci.webhook
Route::flouciWebhook('payments/flouci/hook'); // custom URI
Route::flouciWebhook()->middleware('throttle:60,1');
use Flouci\Laravel\Events\PaymentSucceeded;
Event::listen(function (PaymentSucceeded $event) {
$order = Order::where('reference', $event->trackingId())->firstOrFail();
if ($order->amount_millimes !== $event->amount()) {
return; // unexpected amount: do not mark the order as paid
}
$order->markAsPaid($event->paymentId);
});
$refund = Flouci::refund($paymentId); // full refund