iamolayemi/laravel-paystack

A laravel package for working with paystack api

v1.0.1 2023-07-02 16:57 UTC

README

Latest Version on Packagist Total Downloads Build Status Quality Score GitHub Actions

This package provides an expressive and convenient way to interact with the Paystack API within your Laravel Application.

Installation

Requires PHP 8.1+

You can install the package via composer:

composer require iamolayemi/laravel-paystack

Usage

Open your .env file and add your public key, secret key, callback url and webhook:

PAYSTACK_PUBLIC_KEY=pk_xxxxxxxxxxxxx
PAYSTACK_SECRET_KEY=sk_xxxxxxxxxxxxx

This package provides some fluent interface to interact with the paystack api. To learn all about it, head over to the extensive documentation.

Here are some of the things you can do with this package.

/**
 * Initialize a new payment, and return the response from the api call
 */
Paystack::transaction()->initialize($paymentData)->response();

/**
 * Using the helper function
 */
paystack()->transaction()->initialize($paymentData)->response();

You can also get a specific data from the api call by passing in the key of the data you want to return as an argument in the response() method

/**
 * Initialize a new payment, and return only the authorization url
 */
Paystack::transaction()->initialize($paymentData)->response('data.authorization_url');

/**
 * Using the helper function
 */
paystack()->transaction()->initialize($paymentData)->response('data.authorization_url');

Alternatively, this package also provide another fluent method that make it easy to fetch only the authorization url.

/**
 * Initialize a new payment, and return the authorization url
 */
Paystack::transaction()->initialize($paymentData)->authorizationURL();

/**
 * Using the helper function
 */
paystack()->transaction()->initialize($paymentData)->authorizationURL();

Documentation

You'll find the documentation on https://laravel-paystack.netlify.app.

Find yourself stuck using the package? Found a bug? Do you have general questions or suggestions for improving the media library? Feel free to create an issue on GitHub, we'll try to address it as soon as possible.

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email olatayo.olayemi.peter@gmail.com instead of using the issue tracker.

Credits

Alternatives

License

The MIT License (MIT). Please see License File for more information.