PHP code example of rhaima / laravel-flouci

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/ */

    

rhaima / laravel-flouci example snippets


use Flouci\Laravel\Facades\Flouci;

$payment = Flouci::generatePayment([
    'amount' => 10000,                  // in millimes: 10000 = 10 TND
    'developer_tracking_id' => 'order_1001',
]);

return redirect()->away($payment['result']['link']);

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

$history = Flouci::transactionHistory([
    'start_date' => '2026-09-01T00:00:00Z', // ISO-8601 strings
    'end_date' => '2026-09-30T23:59:59Z',
    'type' => 'online',                     // or pos
]);

use Flouci\Laravel\Exceptions\FlouciException;

try {
    $payment = Flouci::generatePayment(['amount' => 10000]);
} catch (FlouciException $e) {
    $e->getCode();                         // HTTP status, 0 on network errors
    $e->response?->json('result.message'); // Flouci response body
}

Http::fake([
    'developers.flouci.com/api/v2/generate_payment' => Http::response([
        'result' => ['success' => true, 'payment_id' => 'abc', 'link' => 'https://checkout.flouci.com/abc'],
    ]),
]);
bash
php artisan vendor:publish --tag=flouci-config