- Install PaystackLite with composer
composer require stephenjude/paystack-lite
-
if you are using Laravel less than 5.4 Add
Stephenjude\PaystackLite\PaystackLiteServiceProvider::class
to theproviders
array in yourconfig/app.php
. -
Open your .env file and add your public key, secret key, customer default email and payment url like so:
PAYSTACK_PUBLIC_KEY=xxxxxxxxxxxxx
PAYSTACK_SECRET_KEY=xxxxxxxxxxxxx
Paystack-lite make use of blade directive to abstract away all javascript configurations for setting up paystack checkout forms.
Include the Blade Directive (@paystack
) somewhere in your template before your main application JavaScript is loaded.
The @paystack
blade directive creates payWithPaystack(amount, email, meta, onPaymentCompleted, onPaymentCancelled)
JavaScript helper which takes five parameters. the amount, customer email, meta data, callback for payment completed and callback when checkout form is closed.
var amount = 1000;
var email = 'customer@email.com';
var meta = { /* optional meta data array */ };
document.getElementById('paymentBtn').onclick = function() {
//display checkout form
payWithPaystack(amount, email, meta, onPaymentCompleted, onPaymentCancelled);
};
function onPaymentCompleted(response) {
alert('payment completed!');
console.log(resposne);
}
function onPaymentCancelled() {
alert('payment cancelled!');
}
Include the paystack embeded blade directive inside of your html container
<div>
@paystackEmbeded(1000, 'onPaymentCompleted', 'customer@email.com')
</div>
Add your javascript callback function
function onPaymentCompleted(response) {
alert('payment completed!');
console.log(resposne);
}
This package makes use of bosunski/lpaystack package. So you can use all paystack fluent APIs provided in the package.
use Stephenjude\PaystackLite\Facades\PaystackLite;
/**
* This gets all your transactions
*/
PaystackLite::api()->transactions()->list();
/**
* This verifies a transaction with transaction reference passed as parameter
*/
PaystackLite::api()->transactions()->verify($ref);
/**
* This gets all your paystack customers.
*/
PaystackLite::api()->customers()->list();
/**
* This gets all the plans that you have registered on Paystack
*/
PaystackLite::api()->plans()->list();
See the supported Paystack APIs here.
Please see CHANGELOG for more information what has changed recently.
If you discover any security related issues, please email stephen@ahoba.org.ng instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.