GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com โ€” GitHub - pariola/paystack: Paystack API wrapper

BranchesTags
Open more actions menu

Latest commit

 

History

39 Commits
39 Commits

Folders and files

NameName
Last commit message
Last commit date
resources
resources
 
 
.gitignore
.gitignore
 
 
README.md
README.md
 
 
index.js
index.js
 
 
package.json
package.json
 
 

Repository files navigation

paystack

Yet a new Paystack API wrapper ๐Ÿ˜‰

Installation

For Yarn

yarn add paystack-api

For NPM

npm install paystack-api --save

Usage

// Require the library
var paystack = require("paystack-api")("secret_key");

Making calls

The resource methods promisified

Format โ†’ paystack.{resource}.{method}

// paystack.{resource}.{method}
paystack.customer
  .list()
  .then(function(body) {
    console.log(body);
  })
  .catch(function(error) {
    console.log(error);
  });

All Resource methods parameters are provided as the only argument

paystack.plan
  .create({
    name: "API demo",
    amount: 10000,
    interval: "monthly"
  })
  .then(function(error, body) {
    console.log(error);
    console.log(body);
  });
paystack.transactions.list({ perPage: 20 }).then(function(error, body) {
  console.log(error);
  console.log(body);
});

Extras

I

A function to add Paystack's fee to your charging fee

const helper = new paystack.FeeHelper();
console.log(helper.addFeesTo(5000));

Outputs โ†’ 5077 which includes Paystack's fee upfront

OR set your desired parameters

const helper = new paystack.FeeHelper({
percentage: ...,
  cap: ...,
  threshold: ...,
  additionalCharge: ....
});
console.log(helper.addFeesTo(5000));

II

A Paystack Events helper (Express Middleware)

const paystack = require("paystack-api")("secret_key");
const events = paystack.Events;

events.on("event_name", data => {
    // Act
  console.log("hola!");
});

// Hooks with Express
app.post("/my/webhook/url", events.middleware);

Extend resources/methods

const PaystackAPI = require("paystack-api")

class Paystack extends PaystackApi {
  constructor(key) {
    super(key);
    // Update BVN match method with the new route
    this.verification.matchBVN = this.extend({
      method: 'post',
      route: `/bvn/match`,
      args: ['account_number*', 'bank_code*', 'bvn*'],
    });
  }
}

const paystack = new Paystack("secret_key");

Resources

  • customer
    • create
    • get
    • list
    • update
    • validate
    • setRiskAction
    • deactivateAuth
  • transaction
    • initialize
    • verify
    • list
    • get
    • chargeAuth
    • viewTimeline
    • viewTimelineRef
    • totals
    • export
    • reAuthorize
    • checkAuth
  • plan
    • create
    • get
    • list
    • update
  • page
    • create
    • get
    • list
    • update
    • slugAvailable
  • charge
    • tokenize
    • charge
    • submitPIN
    • submitOTP
    • submitPhone
    • submitBirthday
    • checkCharge
  • bulk_charge
    • create
    • list
    • get
    • getCharges
    • pause
    • resume
  • invoice
    • create
    • list
    • get
    • verify
    • notify
    • invoiceMetrics
    • draftInvoice
    • updateInvoice
    • archiveInvoice
  • control_panel
    • getSessionTimeout
    • updateSessionTimeout
  • refund
    • create
    • list
    • get
  • settlement
    • list
  • subaccount
    • create
    • list
    • get
    • update
  • subscription
    • create
    • disable
    • enable
    • get
    • list
  • transfer_control
    • balance
    • resendOTP
    • enableOTP
    • disableOTP
    • finalizeDisableOTP
  • transfer_recipient
    • create
    • list
    • update
    • remove
  • transfer
    • create
    • list
    • get
    • finalize
    • bulkTransfer
    • verify
  • verification
    • resolveBVN
    • matchBVN
    • resolveAccount
    • resolveBIN
    • resolvePhone
  • nuban
    • create
    • list
    • get
    • deactivate
  • misc
    • list_banks
  • feeHelper

Contributing

  • Please do ๐Ÿงก

TODO

  • Create a Paystack Events express middleware

About

Paystack API wrapper

Topics

api-wrappernigeriapaystackpromise

Resources

Readme
Activity

Stars

111 stars

Watchers

4 watching

Forks

44 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 โ€” GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800ร—600. No cookies required.