1. Go to this page and download the library: Download jiannius/senangpay 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\Http\Controllers;
class SenangpayController extends Controller
{
public function redirect()
{
$sp = app('senangpay');
if (! $sp->validatePayload()) {
abort(403);
}
return match ($sp->getStatus()) {
'success' => view('checkout.success'),
'failed' => view('checkout.failed'),
default => view('checkout.pending'),
};
}
public function webhook()
{
$sp = app('senangpay');
if (! $sp->validatePayload()) {
abort(403);
}
// Update your order here. MUST be idempotent — SenangPay calls this
// webhook multiple times for the same transaction (see "Host-app
// contracts" below).
return 'OK'; // Literal string "OK". No HTML, no JSON, no redirect.
}
public function recurring()
{
$sp = app('senangpay');
if (! $sp->validateRecurringPayload()) {
abort(403);
}
$action = request()->input('action');
// 'new_schedule' | 'remove_schedule' | 'terminate'
}
}