npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ahdeyy/paystack

v0.1.7

Published

an api wrapper for paystack's api with types

Downloads

304

Readme

paystack-api

A wrapper for the Paystack API with types.

Installation

NPM

    npm install @ahdeyy/paystack

PNPM

    pnpm add @ahdeyy/paystack

YARN

    yarn add @ahdeyy/paystack

BUN

    bun add @ahdeyy/paystack

Usage

Patterns

After using an API, check if the status of the call is true to work with the success response

import { Paystack } from "@ahdeyy/paystack"

// create the paystack object

const paystack = new Paystack(secret_key)

const created_request = await paystack.payment_request.create({
  amount: 10000,
  description: "Payment for goods",
  due_date: "2022-12-31",
  customer: "customer id",
})

// Check the status of the response
if (created_request.status) {
  // Work with the response success data
} else {
  // Work with the response error data
}

Payment request

Create payment request

const paystack = new Paystack(secret_key)

const created_request = await paystack.payment_request.create({
  amount: 10000,
  description: "Payment for goods",
  due_date: "2022-12-31",
  customer: "customer id",
})

Update payment request

const updated_request = await paystack.payment_request.update({
  amount: 10000,
  description: "Payment for goods",
  due_date: "2022-12-31",
  customer: "customer id",
})

Fetch payment request

const fetched_request = await paystack.payment_request.fetch("request id")

List payment requests

const list = await paystack.payment_request.list(query)

Verify payment request

const verified_request = await paystack.payment_request.verify("request id")

Send Notification

const sent_notification = await paystack.payment_request.sendNotification(
  "request id"
)

Payment request total

const total = await paystack.payment_request.total()

Finalize payment request

const finalized_request = await paystack.payment_request.finalize("request id")

Archive payment request

const archived_request = await paystack.payment_request.archive("request id")

Customer

Create customer

const customer = await paystack.customer.create({
  email: "[email protected]",
  first_name: "john",
  last_name: "doe",
})

List customers

const customer = await paystack.customer.list({ perPage: 10, page: 1 })

Fetch customer

const customer = await paystack.customer.fetch(customers_email)

Validate customer

const customer = await paystack.customer.validate(customer_code, {
  country,
  type,
  account_number,
  bvn,
  bank_code,
  first_name,
  last_name,
})

Update customer

const customer = await paystack.customer.update(customer_code, { phone })

Whitelist/Blacklist customer

const customer = await paystack.customer.whitelist_blacklist({
  customer: customer_code,
  risk_action: "deny",
})

Deactivate Authorization

const customer = await paystack.customer.deactivate_authorization(
  Authorization_code
)

Product

Create product

const product = await paystack.product.create({
  name: "sakura",
  description: "cherry blossom",
  price: 10000,
  currency: "NGN",
})

List products

const product = await paystack.product.list({ perPage: 10, page: 1 })

Fetch product

const product = await paystack.product.fetch(product_id)

Update product

const product = await paystack.product.update(product_id, { price: 69420 })

Dedicated Virtual Accounts

Create DVA

    const response = await paystack.dva.create({ customer: import.meta.env.CUSTOMER_CODE ?? '' })

Assign DVA

    const response = await paystack.dva.assign({
        email: "[email protected]",
        first_name: "Jane",
        middle_name: "Karen",
        last_name: "Doe",
        phone: "+2348100000000",
        preferred_bank: "test-bank",
        country: "NG"

    })

List DVA

    const response = await paystack.dva.list({ active: true, currency: "NGN" });

Fetch DVA

    const response = await paystack.dva.fetch("foo")

Requery DVA

    const response = await paystack.dva.requery({ account_number: "98897", provider_slug: "wema-bank" });

Deactivate DVA

    const response = await paystack.dva.deactivate("foo")

Split DVA

    const response = await paystack.dva.split({ customer: "janey" })

Remove split DVA

    const response = await paystack.dva.remove_split("bar")

Fetch bank providers

    const response = await paystack.dva.fetch_bank_providers();

Miscellanous

List banks

    const response = await paystack.miscellaneous.list_banks({ country: "nigeria", use_cursor: true, perPage: 40 })

List countries

    const response = await paystack.miscellaneous.list_countries()

List states

    const response = await paystack.miscellaneous.list_states("US")

ROADMAP

  • [x] Requests

    • [x] Create payment request
    • [x] Update payment request
    • [x] Fetch payment request
    • [x] List payment requests
    • [x] Verify payment request
    • [x] Send Notification
    • [x] Payment request total
    • [x] Finalize payment request
    • [x] Archive payment request
    • [x] Tests
  • [x] Customers

    • [x] Create Customer
    • [x] List Customers
    • [x] Fetch Customer
    • [x] Update Customer
    • [x] Validate Customer
    • [x] Whitelist/Blacklist Customer
    • [x] Deactivate Authorization
    • [x] Tests
  • [x] Products

    • [x] Create Product
    • [x] List Products
    • [x] Fetch Product
    • [x] Update Product
    • [x] Tests
  • [ ] Dedicated Virtual Accounts

    • [x] Create Dedicated Virtual Account
    • [x] Assign Dedicated Virtual Account
    • [x] List Dedicated Accounts
    • [x] Fetch Dedicated Account
    • [x] Requery Dedicated Account
    • [x] Deactivate Dedicated Account
    • [x] Split Dedicated Account Transaction
    • [x] Remove Split from Dedicated Account
    • [x] Fetch Bank Providers
    • [ ] Tests
  • [ ] Transactions

  • [ ] Transaction Splits

  • [ ] Terminal

  • [ ] Apple Pay

  • [ ] Subaccounts

  • [ ] Plans

  • [ ] Subscriptions

  • [ ] Payment Pages

  • [ ] Settlements

  • [ ] Transfer Recipients

  • [ ] Transfers

  • [ ] Transfers Control

  • [ ] Bulk Charges

  • [ ] Integration

  • [ ] Charge

  • [ ] Disputes

  • [ ] Refunds

  • [ ] Verification

  • [x] Miscellanous

Testing

To run the tests, clone the repository

    git clone https://github.com/Ahdeyyy/paystack-api.git
    bun test