PaystackLite: Fastest Way To Setup Paystack Checkout Form In Your Laravel Application

Published November 20, 2019 • 4 mins read


Paystack is the modern online and offline payment for Africa. One thing that excites me about Paystack is that you don't need to be a registered company to make use of their payment gateway. Anybody can use it to start accepting payments.


Setting up Paystack checkout form is pretty simple and easy but copying & pasting code over and over again in different client's and company's projects is quite irritating. So I decided to bundle those code into a Laravel package. That's how PaystackLite came about.

PaystackLite make use of blade directives to abstract away all Javascript configurations for setting up Paystack checkout forms. This is the easiest way to integrate Paystack checkout form in Laravel applications.

Lets get our hand dirty with few lines of code. I will assume you already have your Laravel application "up and running".

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.


Update your .env file and add your public key, secret key, customer default email and payment url.


Setting up Paystack Checkout Form

PaystackLite makes use of @paystack blade directive. The @paystack blade directive creates a JavaScript helper method payWithPaystack which takes five parameters.

  1. The amount to be paid.
  2. The customer's email.
  3. Meta data.
  4. Callback function when payment is complete.
  5. Callback function when checkout form is closed.

So whenever we want to display Paystack payment form we just call the payWithPaystack method.

document.getElementById('paymentBtn').onclick = function () {
  payWithPaystack(amount, email, meta, onPaymentCompleted, onPaymentCancelled);

So our blade file will look like this:

<!DOCTYPE html>
<html lang="en">

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">


    <button id="paymentBtn">Make Payment</button>

    <!-- Include paystack blade directive -->

        document.getElementById('paymentBtn').onclick = function () {

            var amount = 1000;
            var email = '';
            var meta = {
                custom_fields: [
                        value"My Customer"

            //display checkout form
            payWithPaystack(amount, email, meta, onPaymentCompleted, onPaymentCancelled);

        // Callback when payment is complete.
        function onPaymentCompleted(response{
            alert('payment completed!');
            // do what you like here with the response data returned

        // Callback when checkout form is closed.
        function onPaymentCancelled() {
            alert('payment cancelled!');



Yeah that's it. Now we have Paystack checkout form displayed whenever the Make Payment button is clicked. You can find the source code for this tutorial on Github.


PaystackLite isn't just only about payment checkout form, it's also a Paystack API wrapper for Paystack endpoints. Check out the documentation for more details. Don't forget to star PaystackLite on Github.

Join my weekly newsletter and never miss out on new, tutorials, tips, and more.

You can also follow me on twitter @stephenjudeso

Hey, have you tried Litehost lately?

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.