1. Go to this page and download the library: Download preverus/preverus-laravel 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/ */
preverus / preverus-laravel example snippets
use Illuminate\Http\Request;
use Preverus\Laravel\Facades\Preverus;
public function register(Request $request)
{
$decision = Preverus::evaluate($request, [
'event_type' => 'signup',
'user_id' => $request->input('user_id'),
'metadata' => [
'email' => $request->input('email'),
],
]);
if ($decision->isBlock()) {
abort(403, 'Unable to create account.');
}
if ($decision->isReview()) {
return redirect()->route('verify');
}
// Continue registration.
}
use Illuminate\Http\Request;
use Preverus\Laravel\Facades\Preverus;
Route::post('/preverus/webhook', function (Request $request) {
if (!Preverus::verifyWebhook($request, config('services.preverus.webhook_secret'))) {
abort(400, 'Invalid webhook signature');
}
$payload = $request->json()->all();
// Store $payload['id'] or X-Fraud-Webhook-Id for idempotency.
return response()->noContent();
});
Route::post('/preverus/webhook', function (Request $request) {
Preverus::handleWebhook(
$request,
config('services.preverus.webhook_secret'),
[
'decision.high_risk' => function ($event) {
// Open a case, notify ops, or hold the account action.
},
'*' => function ($event) {
// Optional catch-all handler.
},
],
function ($event) {
return DB::table('processed_webhooks')->where('id', $event->id())->exists();
},
);
return response()->noContent();
});