PHP code example of binkode / laravel-paystack
1. Go to this page and download the library: Download binkode/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/ */
binkode / laravel-paystack example snippets
return [
"public_key" => env("PAYSTACK_PUBLIC_KEY"),
"secret_key" => env("PAYSTACK_SECRET_KEY"),
"url" => env("PAYSTACK_URL", "https://api.paystack.co"),
"merchant_email" => env("PAYSTACK_MERCHANT_EMAIL"),
"route" => [
"middleware" => ["paystack_route_disabled", "api"],
"prefix" => "api",
"hook_middleware" => ["validate_paystack_hook", "api"],
],
];
use Binkode\Paystack\Support\Transaction;
use Binkode\Paystack\Support\Customer;
$init = Transaction::initialize([
"email" => "[email protected] ",
"amount" => 500000, // amount in kobo
]);
$verify = Transaction::verify("reference_here");
$customer = Customer::create([
"email" => "[email protected] ",
"first_name" => "Jane",
"last_name" => "Doe",
]);
use Binkode\Paystack\Events\Hook;
use Illuminate\Support\Facades\Log;
class PaystackWebhookListener
{
public function handle(Hook $event): void
{
Log::info("Paystack webhook received", [
"event" => $event->event["event"] ?? null,
"payload" => $event->event,
]);
}
}
bash
php artisan vendor:publish --provider="Binkode\Paystack\PaystackServiceProvider"
bash
php artisan make:listener PaystackWebhookListener --event=Binkode\\Paystack\\Events\\Hook