1. Go to this page and download the library: Download zevpay/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/ */
use ZevPay\ZevPay;
class PaymentController extends Controller
{
public function checkout(ZevPay $zevpay)
{
$session = $zevpay->checkout->initialize([
'amount' => 500000,
'email' => '[email protected]',
]);
return redirect($session['checkout_url']);
}
}
use ZevPay\Laravel\Events\ChargeSuccess;
use ZevPay\Laravel\Events\TransferSuccess;
use ZevPay\Laravel\Events\WebhookReceived;
// Listen to a specific event
class HandleChargeSuccess
{
public function handle(ChargeSuccess $event): void
{
$reference = $event->payload['data']['reference'];
$amount = $event->payload['data']['amount'];
// Update your order, send receipt, etc.
}
}
// Or listen to all webhook events
class LogAllWebhooks
{
public function handle(WebhookReceived $event): void
{
logger()->info("ZevPay webhook: {$event->eventType}", $event->payload);
}
}