Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads
A PHP API wrapper for Paystack.
$ composer require yabacon/paystack-php
Download a release version from the releases page. Extract, then:
require 'path/to/src/Paystack.php'; \YabaCon\Paystack::registerAutoloader();
Check ibrahimlawal/paystack-php-sample for a sample donation page that uses this library
###Default: Uses curl for requests
$paystack = new \YabaCon\Paystack('secret_key'); // Make a call to the resource/method // $paystack->{resource}->{method}(); // for gets, use $paystack->{resource}(id) // $headers is an array of header values. // $body is an array created from json_decoding response list($headers, $body, $code) = $paystack->customer(12); list($headers, $body, $code) = $paystack->customer->list(); list($headers, $body, $code) = $paystack->customer->list(['perPage'=>5,'page'=>2]); // list the second page at 5 customers per page list($headers, $body, $code) = $paystack->customer->create([ 'first_name'=>'Dafe', 'last_name'=>'Aba', 'email'=>"dafe@aba.c", 'phone'=>'08012345678' ]); list($headers, $body, $code) = $paystack->transaction->initialize([ 'reference'=>'unique_refencecode', 'amount'=>'120000', 'email'=>'dafe@aba.c' ]); list($headers, $body, $code) = $paystack->transaction->verify([ 'reference'=>'refencecode' ]);
###Use Guzzle for requests Only available if project is managed using composer.
Install Guzzle
$ composer require guzzlehttp/guzzle
Make calls
// create a paystack object $paystack = new \YabaCon\Paystack('secret_key'); // tell it to use guzzle if found $paystack->useGuzzle(); // Make a call to the resource/method // $paystack->{resource}->{method}(); // for gets, use $paystack->{resource}(id) // $response is a GuzzleHttp\Psr7\Response Object $response = $paystack->customer(12); $response = $paystack->customer->list(); $response = $paystack->customer->list(['perPage'=>5,'page'=>2]); // list the second page at 5 customers per page $response = $paystack->customer->create([ 'first_name'=>'Dafe', 'last_name'=>'Aba', 'email'=>"dafe@aba.c", 'phone'=>'08012345678' ]); $response = $paystack->transaction->initialize([ 'reference'=>'unique_refencecode', 'amount'=>'120000', 'email'=>'dafe@aba.c' ]); $response = $paystack->transaction->verify([ 'reference'=>'refencecode' ]);
Check SAMPLES for more sample calls
Please see CHANGELOG for more information what has changed recently.
$ composer testPlease see CONTRIBUTING and CONDUCT for details. Check our todo list for features already intended.
If you discover any security related issues, please email yabacon.valley@gmail.com instead of using the issue tracker.
- YabaCon
- Issa Jubril
- Ibrahim Lawal
- Opeyemi Obembe - followed the style he employed in creating the NodeJS Wrapper
- All Contributors
The MIT License (MIT). Please see License File for more information.