PaystackLite: Getting Started With Paystack Fluent APIs In Your Laravel Application
Published November 25, 2019 • 2 mins read
Earlier this week, I wrote an article on how to setup Paystack checkout form. Yeah I did but that's not all PaystackLite can offer.
In this article I will be walking you through how you can hit Paystack endpoints using PaystackLite. Let's get started.
Installing PaystackLite
Install the package with composer.
composer require stephenjude/paystack-lite
If you are using Laravel less than 5.4, add the line below to the providers array in your config/app.php file.
Stephenjude\PaystackLite\PaystackLiteServiceProvider::class,
Update your .env file and add your public key, secret key, customer default email and payment url.
PAYSTACK_PUBLIC_KEY=xxxxxxxxxxxxx
PAYSTACK_SECRET_KEY=xxxxxxxxxxxxx
PAYSTACK_PAYMENT_URL=https://api.paystack.co
PAYSTACK_CUSTOMER_DEFAULT_EMAIL=general@email.com
Paystack Fluent APIs
PaystackLite is wrapped around Xeviant Paystack package. So you can use all paystack fluent APIs provided in the package. There are three different ways to make use of this package.
Instantiate PaystackLite Class
<?php
use Stephenjude\PaystackLite\PaystackLite
$paystack = new PaystackLite;
// Returns a list of your customers
$data = $paystack->api()->customers()->list();
This is basically accessing the fluent APIs through an instance of PaystackLite class.
PaystackLite Facade
<?php
use Stephenjude\PaystackLite\Facades\PaystackLite;
// Returns a list of your transactions
$data = PaystackLite::api()->transactions()->list();
This is Laravel Facades doing the magic for us.
App Service Container
This is my most preferred method of using Paystack fluent APIs provided in this package. You

With this method you don't need to import or instantiate any class to make use of the PaystackLite class. You only need to call app('paystack') helper function followed by fluent methods as show above.
Here is an example on how to get a list of all the plans in your Paystack account.
<?php
// returns a list of your paystack plans
app('paystack')->api()->plans()->list();
Supported APIs
Here is a list of endpoints supported in this package
- transactions()
- customers()
- plans()
- subscriptions()
- subAccounts()
- pages()
- invoices()
- transfers()
- transferRecipients()
- settlements()
All supported endpoints are covered here in details.
Conclusion
I believe you now have an understanding of how PaystackLite works. You can go through the documentation for more details and don't forget to star PaystackLite on Github. If you have any question drop it in the comment section below.
Join my weekly newsletter and never miss out on new tutorials, tips, and more.
You can also follow me on twitter @stephenjudeso

Litehost is my side project which is a shared hosting platform with PHP & Laravel developers in mind. It has Composer, Git & PHP CLI pre-installed on its servers. SSH access is also granted on request. Litehost is pretty affordable. Try it today.