Skip to content

ashinzekene/paystack-simple

Repository files navigation

paystack-simple

Paystack-simple bundle size MIT NPM Build Status

<1kb Framework/Library agnostic paystack wrapper

INSTALLATION

npm install paystack-simple

USAGE

Basic Usage

import Paystack from "paystack-simple";

const paymentInstance = Paystack();

paymentInstance.init() // Optional - Fetch paystack script

paymentInstance.addOptions({
  amount: 5000,
  key: 'pk-xxxxx-xxxxxx',
  email: '[email protected]',
})

paymentInstance.addOptions({
  currency: 'NGN',
  callback: (res) => {
    // act on response
  }
})

paymentInstance.pay() // Pay

Embed

import Paystack from "paystack-simple";

const paymentInstance = Paystack();

paymentInstance.init() // Optional - Fetch paystack script

paymentInstance.addOptions({
  amount: 5000,
  key: 'pk-xxxxx-xxxxxx',
  email: '[email protected]',
})

paymentInstance.addOptions({
  container: 'container-ID',
  callback: (res) => {
    // act on response
  }
})

paymentInstance.pay() // Pay

Set GlobalConfig

import Paystack, { setGlobalConfig } from "paystack-simple";

setGlobalConfig({ key: 'pk-test-xxxx-xxxx' }) // Key has been set globally

paymentInstance.addOptions({ // No need to add it here
  amount: 5000,
  email: '[email protected]',
  callback: (res) => {
    // act on response
  }
})

paymentInstance.pay() // Pay

What's Cool?

  • Less than 1kb
  • Framework/Library agnostic
  • Simple API
  • Intellisense support

About

Framework/Library agnostic paystack wrapper

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published