A PHP library for communicating with Paystack API
- PHP >= 5.4
composer require amirsanni/paystack-lib
require 'vendor/autoload.php';
use amirsanni\paystacklib\Paystack;
$paystack = new Paystack([
'secret_key'=>'YOUR_PAYSTACK_SECRET_KEY'
]);
$paystack->transaction->make([
'ref'=>md5('dsef'),
'amount_in_kobo'=>20000,
'email'=>'amirsanni@gmail.com',
'metadata'=>[
'name'=>"Amir Olalekan",
'ID'=>"AMS10",
"Phone"=>"07045567890"
],
'callback_url'=>'http://localhost/paystack-lib/examples/callback.php'
]);
$paystack->transaction->verify(TRANSACTION_REFERENCE);
$single = $paystack->transaction->getOne(TRANSACTION_ID);
$paystack->transaction->per_page = 25;//set number of items to return
$paystack->transaction->page_number = 3;//set page number
$multiple = $paystack->transaction->getMany();
$paystack->transaction->per_page = 20;//set number of items to return
$paystack->transaction->page_number = 1;//set page number
$by_status = $paystack->transaction->whereStatus('success');
$between_dates = $paystack->transaction->betweenDates($from_date, $to_date);
$cust_trans = $paystack->transaction->whereCustomer(CUSTOMER_ID);
$trans_timeline = $paystack->transaction->timeline(TRANSACTION_ID_OR_REFERENCE);
$all_time = $paystack->transaction->allTime();
$total_between_dates = $paystack->transaction->totalBetweenDates(FROM_DATE, TO_DATE);
$paystack->transaction->export();//file will be downloaded in csv format
$paystack->transaction->chargeReturningCustomer($auth_code, $amount_in_kobo, $email, $transaction_ref, $metadata_array);
$created = $paystack->customer->create('foo@bar.com', 'Foo', 'Bar', '0703xxxxxxx', [
'company'=>"Foo Bar"
]);
$one = $paystack->customer->getOne(96992);
$many = $paystack->customer->getMany();