PHP code example of intune / laravel-paystack
1. Go to this page and download the library: Download intune/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/ */
intune / laravel-paystack example snippets
return [
'secret' => env('PAYSTACK_SECRET_KEY'),
'plan_code' => env('PAYSTACK_PLAN_CODE'),
'redirect_url' => env('PAYSTACK_REDIRECT_URL'),
'white_list' => env('PAYSTACK_WHITE_LIST'),
];
use Intune\LaravelPaystack\Dtos\UserDto;
use Intune\LaravelPaystack\PaystackService;
$paystackService = app(PaystackService::class);
$userDto = UserDto::create([
'email' => '[email protected] ',
'first_name' => 'John',
'last_name' => 'Doe',
'phone_number' => '1234567890', // Optional
]);
$customer = $paystackService->createCustomer($userDto);
$email = '[email protected] ';
$amount = 1000; // Amount in kobo (1000 kobo = 10 NGN)
$dto = TransactionInitPayloadDto::create([
'email' => $email,
'amount' => $amount,
// other transaction details
]);
$transaction = $paystackService->initializePurchaseTransaction($dto);
$customer_id = 'customer_id_from_paystack';
$subscription = $paystackService->createSubscription($customer_id);
$subscription_id = 'subscription_id';
$manageLink = $paystackService->manageSubscription($subscription_id);
$payload = request()->getContent();
$signature = request()->header('x-paystack-signature');
if ($paystackService->isValidPaystackWebhook($payload, $signature)) {
// Valid webhook
}
bash
php artisan vendor:publish --provider="Intune/laravel-paystack\PaystackServiceProvider"