Download the PHP package coderatio/paystack-mirror without Composer
On this page you can find all versions of the php package coderatio/paystack-mirror. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download coderatio/paystack-mirror
More information about coderatio/paystack-mirror
Files in coderatio/paystack-mirror
Package paystack-mirror
Short Description An actionable PHP library for Paystack Api
License GPL-3.0
Homepage https://github.com/coderatio/paystack-mirror
Informations about the package paystack-mirror
The missing Paystack PHP Library.
Overview
Paystack Mirror is a clean, simple and fluent php library for paystack payment gateway. This library is birthed out of the fact that I needed something flexible than what is in existance for myself and the php community.
What was wrong with the existing one?
The official paystack library for php is the yabacon/paystack-php on github. It's cool. Supports almost all paystack end-points and some other cool features like a dedicated Fee class, MetaDataBuilder class and Event handler class. Many people have been using the library but I wanted something that can give people freedom over what they do. I wanted something that supports multiple accounts at once. It's why I decided to work on this library.
What is unique about the library?
- The conversion of paystack end-points to full fledged extendable php classes.
- Supports for multiple accounts
- Clean and better event handler class
- Fluent Params Builder class
- Nigerian money conversion e.g 1k => 1,000 naira and 1,000 naira => 100000 kobo and even (millions(xM), billions(xB), trillions(xT)) to kobo e.t.c.
Server Requirements
PHP version ^7.1.3 requirement was done intentionally. Reason been that it's safer, better and faster than 5.6 and 7.0. So, if you have been using php version less than that, kindly upgrade before using this library.
- php ^7.1.3
- cURL extension enabled
- OpenSSL extension enabled
This library has suppports for all Paystack end-points which we refer to as Actions. Let's take a look at the available actions.
List of actions groups
Below are actions groups supported by the library in alphabetical order.
- BULK CHARGES
- CHARGES
- CONTROL PANEL
- CUSTOMERS
- INVOICES
- MISCELLANEOUS
- PAGES
- PLANS
- REFUNDS
- SETTLEMENTS
- SUB-ACCOUNTS
- SUBSCRIPTIONS
- TRANSACTIONS
- TRANSFER RECIPIENTS
- TRANSFERS
- TRANSFERS CONTROL
- VERIFICATIONS
Note: To see the list of all actions under each action groups available on this library, kindly Click Here.
Arrangements are on the way to list all of them like the first two above.
Installation
Usage
With Single Paystack Account
Method One
Method Two
Method Three
Method Four
Notice: By default,
->getResponse()
returns a json object. But, you can chain->asArray()
to convert the response to phparray
or->asObject()
to conver the response to phpobject
at runtime.
With Multiple Paystack Accounts
With this library, you can mirror single action on multiple paystack accounts. This is super cool for multitenants applications or firms with multiple paystack accounts.
Let's see how to do it.
You can overwrite all the accounts data by providing your params on the action. When that is done, the library will use the parameters supplied on the action for all the accounts instead e.g
Quick Note: All the query or body params used on paystack api documentation site are all available in this library. The only different is, they must be sent as an array or as
ParamBuilder::class
object.
Create your action
One good thing about this library is the ability to plug and play actions. You can replace existing actions by creating yours.
Please note that
$this->data
property returns an array. If you want to send parameters as json to paystack, use$this->getData()
.
Webhook Event Handling
This library ships with a fluent Event handling class to be used at your webhook url set on your paystack dashboard. See example below on how to listen to different events.
Create a separate event class
With this library, you can write a separate event class for a single event. For example, the subscription.create
event can be created like this:
This can then be used like this:
Here, you can see that we are just implementing the ActionEvent::class
interface and extending the Event::class
on the ::validate()
method.
Addons
The library has a few of in-built functionalities to do somethings quicker and better. Let's take a look at them:
1. Nairas to kobo
Since paystack accepts amount in kobo only, there should be a quick way to do that. Below are helper functions to help you out.
Note: The
short_naira_to_kobo()
helper function, supports onlyk
as thousands,m
as millions,b
as billions andt
as trillions notations.
2. Reference Generator
You can easily generate especially, transaction reference easily by doing this:
Todo
- Build a dedicated docs site
Tests
Contributions
Correcting a typographical error is a huge a contribution to this project. Do well to do that. You can fork the repo and send pull request or reach out easily to me via twitter here => Josiah Ovye Yahaya.
Collaborators
Licence
This project is built and used with GPL.3.0
licence.