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

paystack-fees

v1.0.3

Published

Add paystack fees to an amount

Downloads

51

Readme

PaystackFees

A class for managing Paystack fees in your application.

Installation

Peer Dependency (required)

Install Joi which we have employed for validating parameters sent to functions in this library

npm install --save @hapi/joi

Now install the module

npm install --save paystack-fees

Sample Usage

const PaystackFees = require('paystack-fees');
// The lines below will create a new object that calculates fees based on the fee
// schedule for USD payments. The cap is set to an arbitrarily high number since there
// is no cap.
const paystackFees = (new PaystackFees())
            .withPercentage(0.035)
            .withAdditionalCharge(0)
            .withCap(1000000000000)
            .withThreshold(0);

// you can now calculate fees for an amount by calling the `calculateFor` function
const feesFor1000USD = paystackFees.calculateFor(100000);
// or the amount to be sent when we intend to be settled a target amount
const amountToSendToBeSettled50USD = paystackFees.addTo(5000);

Kind: global class

paystackFees.withPercentage(percentage) ⇒

set the percentage

Kind: instance method of PaystackFees
Returns: the current PaystackFees object
Throws:

  • if percentage sent is invalid

| Param | Type | Description | | --- | --- | --- | | percentage | number | positive number less than 1 |

paystackFees.withAdditionalCharge(additionalCharge) ⇒

set the additional charge which will be added if the amount is over threshold

Kind: instance method of PaystackFees
Returns: the current PaystackFees object
Throws:

  • if additional charge sent is invalid

| Param | Type | Description | | --- | --- | --- | | additionalCharge | number | 0 or more |

paystackFees.withThreshold(threshold) ⇒

set the threshold, beyond which additional charge will be added to fees.

Kind: instance method of PaystackFees
Returns: the current PaystackFees object
Throws:

  • if threshold sent is invalid

| Param | Type | Description | | --- | --- | --- | | threshold | number | 0 or more |

paystackFees.withCap(cap) ⇒

set the cap

Kind: instance method of PaystackFees
Returns: the current PaystackFees object
Throws:

  • if cap sent is invalid

| Param | Type | Description | | --- | --- | --- | | cap | number | positive number greater than or equal to 1 |

paystackFees.addTo(amountInLowerDenomination) ⇒

calculate amount to be sent to paystack to be settled the amount provided

Kind: instance method of PaystackFees
Returns: amount you should send in lower denomination
Throws:

  • if amountInLowerDenomination sent is invalid

| Param | Type | Description | | --- | --- | --- | | amountInLowerDenomination | number | The amount we want to be settled after paystack deducts fees |

Example

paystackFee.addTo(10000) // add fees so we can be settled 100 in higher denomination

paystackFees.calculateFor(amountInLowerDenomination) ⇒

Calculates the fee for an amount in lower denomination

Kind: instance method of PaystackFees
Returns: fees in lower denomination
Throws:

  • if amountInLowerDenomination sent is invalid

| Param | Type | Description | | --- | --- | --- | | amountInLowerDenomination | number | The amount we want to send to paystack |

Example

// calculate the charge that will be deducted if
// a local cards pays 100 naira
const amountInKobo = 10000; // 10000 kobo is 100 naira
paystackFee.calculateFor(amountInKobo);