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

jetiffy-payment-services-shared-functions

v1.0.12

Published

**HOW TO TEST**

Downloads

32

Readme

PAYSTACK

HOW TO TEST

  • make a POST request to https://api.paystack.co/transaction/initialize
  • pass the Authorization header as :
    Authorization : Bearer sk_test_f37d04c1c6eac6ad4239a04abc149ee126cd38e4
  • body Object:
    { "email": "[email protected]", "amount": "20000" }
  • a custom checkout link will be generated from the response that you can use to execute the transaction on paystack's checkout page. Sample response:
{
    "status": true,
    "message": "Authorization URL created",
    "data": {
        "authorization_url": "https://checkout.paystack.com/h05joqiw6vgze2v",
        "access_code": "h05joqiw6vgze2v",
        "reference": "v7o6mscp25"
    }
}
  • click on the authorization_url and perform a payment, you can then verify later.

VERIFY TRANSACTION SHARED FUNCTION

  • ensure the following environment variables are set in the serverless.env.json file for the service
    • PAYSTACK_BASE_URL : https://api.paystack.co
    • PAYSTACK_SECRET_KEY : use the test secret key for dev
    • call the paystack.verify(referenceId). the reference id will be sent from the frontend to verify a transaction Success Response Object
{
success: true
message : "a message describing the success flag. this can be sent to the client as a response"
data : {
    amount: 20000,
    fee: 300,
    currency: "NGN",
    reference: "qdats89k8y",
    }
}

Error Response Object 1

{
success: false
message : "a message describing the failure flag. this can be sent to the client as a response"
data : {
    amount: 20000,
    fee: null,
    currency: "NGN",
    reference: "qdats89k8y",
    }
}

Success Response Object 2

{
success: false
message : "a message describing the failure flag. this can be sent to the client as a response"
}

NOTES

  • depending on the error code, the error response might return a data or not. the key property is the success flag. once false simply return a custom error message or the message property to the client
  • the amount property can be used to verify the transaction amount against what was supplied from the frontend, after which the users wallet will be credited with the amount.
  • always save the referenceId on the wallet history and also the fundingType. e.g paystack, flutterwave, providusVirtualAccount. this should be enums that will be allowed on the wallet history.

FLUTTERWAVE

VERIFY TRANSACTION SHARED FUNCTION

  • ensure the following environment variables are set in the serverless.env.json file for the service
    • FLUTTERWAVE_BASE_URL : https://api.flutterwave.com
    • FLUTTERWAVE_SECRET_KEY : use the test secret key for dev
    • call the flutterwave.verify(referenceId). the reference id will be sent from the frontend to verify a transaction

THE SAME PROCESS APPLIES FOR SUCCESS AND ERROR RESPONSES