PHP code example of ayoolatj / paystack-php
1. Go to this page and download the library: Download ayoolatj/paystack-php 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/ */
ayoolatj / paystack-php example snippets
$paystack = new \Ayoolatj\Paystack\Paystack(PAYSTACK_SECRET_KEY);
try {
$charge = $paystack->charge->charge([
'email' => '[email protected] ',
'amount' => '1000000',
'bank' => ['code' => '057', 'account_number' => '0000000000'],
'birthday' => '1994-07-04',
]);
} catch (\Ayoolatj\Paystack\Exceptions\ApiException $e) {
print_r($e->getResponse());
}
// process Charge resource
$plan = $paystack->plans->create([
'name' => 'New Plan',
'amount' => '1000000',
'interval' => 'biannually'
]);
print_r($plan->toArray());
$charge = $paystack->charge->charge([
'email' => '[email protected] ',
'amount' => '1000000',
'bank' => ['code' => '057', 'account_number' => '0000000000'],
'birthday' => '1994-07-04',
]);
echo $charge->getLastResponse()->headers['Date'];
$plans = $paystack->plans->all([
'perPage' => 20,
'page' => 2,
]);
$plans = $paystack->plans->all([
'perPage' => 20,
'page' => 2,
]);
foreach ($plans->autoPagingIterator() as $plan) {
// Do something with $plan
}
$input = @file_get_contents('php://input');
$paystack_signature = $_SERVER['HTTP_X_PAYSTACK_SIGNATURE'];
try {
\Ayoolatj\Paystack\Webhook::verifyEvent($input, $paystack_signature, PAYSTACK_SECRET_KEY);
} catch (\Ayoolatj\Paystack\Exceptions\SignatureVerificationException $e) {
$input = $e->getHttpBody();
$header = $e->getSigHeader();
exit();
}
bash
composer