To add Yabacon Paystack to a Laravel application, you will need to first install the Paystack package using Composer. You can do this by running the following command in your terminal:
composer require yabacon/paystack-php
Once the package is installed, you will need to add your Paystack secret key and public key to your .env file. You can find these keys in your Paystack dashboard.
Next, you will need to register the Paystack service provider and facade in your config/app.php file. In the providers array, add the following entry:
Yabacon\Paystack\PaystackServiceProvider::class,
In the aliases array, add the following entry:
'Paystack' => Yabacon\Paystack\Facade\Paystack::class,
Once you have done this, you can use the Paystack facade in your Laravel application to access the Paystack API. For example, to charge a customer’s card, you could do something like this:
use Paystack;
// Set the customer's email address and the amount to charge (in kobo)
$email = "customer@example.com";
$amount = 100000; // equivalent to 1000 naira
// Charge the customer's card
$response = Paystack::charge([
'amount' => $amount,
'email' => $email
]);
// Check if the charge was successful
if ($response['status']) {
// The charge was successful
// Here, you can store the transaction details in your database
} else {
// The charge was not successful
// You can check the response for more details
}