Giter VIP home page Giter VIP logo

paystack-lib's Introduction

Paystack Library

A PHP library for communicating with Paystack API

Requirements

  • PHP >= 5.4

Getting Started

Installation

composer require amirsanni/paystack-lib

Features

Initialise the library

require 'vendor/autoload.php';
use amirsanni\paystacklib\Paystack;

$paystack = new Paystack([
    'secret_key'=>'YOUR_PAYSTACK_SECRET_KEY'
]);

Transactions

Make a Transaction

$paystack->transaction->make([
    'ref'=>md5('dsef'),
    'amount_in_kobo'=>20000,
    'email'=>'[email protected]',
    'metadata'=>[
        'name'=>"Amir Olalekan",
        'ID'=>"AMS10",
        "Phone"=>"07045567890"
    ],
    'callback_url'=>'http://localhost/paystack-lib/examples/callback.php'
]);

Verify Transaction

$paystack->transaction->verify(TRANSACTION_REFERENCE);

Get Single Transaction Details

$single = $paystack->transaction->getOne(TRANSACTION_ID);

Get Multiple Transactions Details

$paystack->transaction->per_page = 25;//set number of items to return
$paystack->transaction->page_number = 3;//set page number

$multiple = $paystack->transaction->getMany();

Get transactions based on transaction status (failed, success, abandoned)

$paystack->transaction->per_page = 20;//set number of items to return
$paystack->transaction->page_number = 1;//set page number

$by_status = $paystack->transaction->whereStatus('success');

Get Transactions within a particular period

$between_dates = $paystack->transaction->betweenDates($from_date, $to_date);

Get a particular customer's transactions

$cust_trans = $paystack->transaction->whereCustomer(CUSTOMER_ID);

Get a transaction timeline

$trans_timeline = $paystack->transaction->timeline(TRANSACTION_ID_OR_REFERENCE);

Get total of all transactions done on your account

$all_time = $paystack->transaction->allTime();

Get total of all transactions done on your account within a particular period

$total_between_dates = $paystack->transaction->totalBetweenDates(FROM_DATE, TO_DATE);

Export Transactions

$paystack->transaction->export();//file will be downloaded in csv format

Charge Returning Customers

$paystack->transaction->chargeReturningCustomer($auth_code, $amount_in_kobo, $email, $transaction_ref, $metadata_array);

Customer

Create Customer

$created = $paystack->customer->create('[email protected]', 'Foo', 'Bar', '0703xxxxxxx', [
    'company'=>"Foo Bar"
]);

Get single customer information

$one = $paystack->customer->getOne(96992);

Get multiple customer information

$many = $paystack->customer->getMany();

Check the examples directory for more.

paystack-lib's People

Contributors

amirsanni avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.