1. Go to this page and download the library: Download opsofts/laravel-paystack 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/ */
opsofts / laravel-paystack example snippets
use Opsofts\LaravelPaystack\Facades\Paystack;
// Initialize a transaction
$data = Paystack::initializeTransaction([
'email' => $customer->email,
'amount' => $amountInKobo, // smallest currency unit, not decimal Naira
'reference' => $orderReference,
'callback_url' => route('payment.callback'),
]);
// redirect the payer to $data['authorization_url']
// Verify after redirect and/or from a webhook handler
$data = Paystack::verifyTransaction($reference);
if ($data['status'] === 'success') {
// mark the order/payment as paid
}
// Refund (full or partial)
Paystack::refund($transactionReference, amount: $partialAmountInKobo);
// Webhook signature verification -- do this before trusting ANY webhook payload
$isValid = Paystack::verifyWebhookSignature(
rawPayload: $request->getContent(),
signatureHeader: $request->header('x-paystack-signature'),
);
if (! $isValid) {
abort(401);
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.