Skip to content

femotizo/paystack-php

 
 

Repository files navigation

paystack-php

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

A PHP API wrapper for Paystack.

Paystack

Install

Via Composer

$ composer require yabacon/paystack-php

Via download

Download a release version from the releases page. Extract, then:

require 'path/to/src/Paystack.php';
\YabaCon\Paystack::registerAutoloader();

Usage

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

Change log

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CONDUCT for details. Check our todo list for features already intended.

Security

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

Credits

License

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

About

A PHP Wrapper for Paystack API - https://www.paystack.com

Resources

License

CC0-1.0, MIT licenses found

Licenses found

CC0-1.0
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%