1. Go to this page and download the library: Download gonon/laravel-tripay 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/ */
gonon / laravel-tripay example snippets
use Gonon\Tripay\Laravel\Facades\Tripay;
use Gonon\Tripay\DTO\CreateTransactionRequest;
// Get all available payment channels
$channels = Tripay::paymentChannels()->list();
foreach ($channels as $channel) {
echo $channel->code; // e.g., 'BRIVA', 'OVO'
echo $channel->name;
echo $channel->isActive ? 'Active' : 'Inactive';
}
use Gonon\Tripay\DTO\FeeCalculationRequest;
$fees = Tripay::calculator()->calculate(
new FeeCalculationRequest(amount: 150000, code: 'BRIVA')
);
echo $fees->totalFee;
echo $fees->feeMerchant;
echo $fees->feeCustomer;
use Illuminate\Http\Request;
public function handleWebhook(Request $request)
{
$signature = $request->header('X-Callback-Signature');
$payload = $request->getContent();
// The webhook handler automatically uses your configured private key
$isValid = Tripay::webhook()->verifySignature($signature, $payload);
if (! $isValid) {
abort(403, 'Invalid signature');
}
$event = json_decode($payload);
if ($event->status === 'PAID') {
// Update order status in your database
}
return response()->json(['success' => true]);
}
use Gonon\Tripay\Client\TripayClient;
class CheckoutController
{
public function __construct(
private readonly TripayClient $tripay
) {}
public function process()
{
$channels = $this->tripay->paymentChannels()->all();
}
}
$tripay = app(\Gonon\Tripay\Client\TripayClient::class);
// or via the bound alias
$tripay = app('tripay');