
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
node-paykit
Advanced tools
A flexible Node.js package for seamless integration with multiple payment gateways
node-paykit is a flexible Node.js package designed for seamless integration with multiple payment gateways, such as Stripe and Paystack (with more gateways planned). This package allows you to switch between different payment providers without changing complex settings in your codebase.
To install the package, use npm or yarn:
npm install node-paykit
or
yarn add node-paykit
JavaScript Example:
const { PaymentGateway } = require("node-paykit"); // Ensure you are importing the class correctly
require("dotenv").config();
const stripeProvider = new PaymentGateway('stripe', process.env.STRIPE_SECRET_KEY); // Use 'new' to instantiate the class
async function runPayment() {
const payload = {
success_url: 'https://example.com/success',
cancel_url: 'https://example.com/cancel',
payment_method_types: ['card'],
line_items: [
{
price_data: {
currency: 'usd',
product_data: {
name: 'Sample Product',
},
unit_amount: 2000,
},
quantity: 2,
},
],
mode: 'payment',
};
try {
const payment = await stripeProvider.createPayment(payload);
console.log("Payment reference:", payment);
} catch (error) {
console.error("Error creating payment:", error);
}
}
async function listPayments() {
const params = { limit: 3 };
try {
const payments = await stripeProvider.listPayments(params);
console.log("Payment list:", payments);
} catch (error) {
console.error("Error listing payments:", error);
}
}
async function retrieveSinglePayment() {
const transId = "cs_test_a1O7BLn85hx512NIS3zfI2AQqNpvRcgTOAwMcLyMOtWE48mpjAGzZjiUzm";
try {
const payment = await stripeProvider.retrieveSinglePayment(transId);
console.log("Payment details:", payment);
} catch (error) {
console.error("Error retrieving payment:", error);
}
}
async function verifyPayment() {
const transId = "cs_test_a1O7BLn85hx512NIS3zfI2AQqNpvRcgTOAwMcLyMOtWE48mpjAGzZjiUzm";
try {
const payment = await stripeProvider.verifyPayment(transId);
console.log("Payment verification:", payment);
} catch (error) {
console.error("Error verifying payment:", error);
}
}
// Call the functions
runPayment();
verifyPayment();
listPayments();
retrieveSinglePayment();
TypeScript Example:
import { PaymentGateway } from "node-paykit";
import * as dotenv from 'dotenv';
dotenv.config();
const stripeKey = process.env.STRIPE_SECRET_KEY;
if (!stripeKey) {
throw new Error("STRIPE_SECRET_KEY is not set in the environment variables");
}
// Initiate your payment provider (in this case, Stripe)
const provider = new PaymentGateway('stripe', stripeKey);
async function runPayment() {
const payload = {
success_url: 'https://example.com/success',
cancel_url: 'https://example.com/cancel',
payment_method_types: ['card'],
line_items: [
{
price_data: {
currency: 'usd',
product_data: {
name: 'Sample Product',
},
unit_amount: 2000,
},
quantity: 2,
},
],
mode: 'payment',
};
// For more information and payload details, see the official Stripe docs https://docs.stripe.com/api/checkout/sessions/create
try {
const payment = await provider.createPayment(payload);
console.log("Payment reference:", payment);
} catch (error) {
console.error("Error creating payment:", (error as Error).message);
}
}
async function listPayments() {
// For more info about the params to pass, see the official docs https://docs.stripe.com/api/checkout/sessions/list
const payload2 = { limit: 3 };
try {
const payments = await provider.listPayments(payload2);
console.log("Payment list:", payments);
} catch (error) {
console.error("Error listing payments:", (error as Error).message);
}
}
async function retrieveSinglePayment() {
// For more info about verification of payment, see https://docs.stripe.com/api/checkout/sessions/retrieve
const transId = "cs_test_a1O7BLn85hx512NIS3zfI2AQqNpvRcgTOAwMcLyMOtWE48mpjAGzZjiUzm";
try {
const payment = await provider.retrieveSinglePayment(transId);
console.log("Payment details:", payment);
} catch (error) {
console.error("Error retrieving payment:", (error as Error).message);
}
}
async function verifyPayment() {
// For more info about verifying payment, see https://docs.stripe.com/api/checkout/sessions/retrieve
const transId = "cs_test_a1O7BLn85hx512NIS3zfI2AQqNpvRcgTOAwMcLyMOtWE48mpjAGzZjiUzm";
try {
const payment = await provider.verifyPayment(transId);
console.log("Payment verification:", payment);
} catch (error) {
console.error("Error verifying payment:", (error as Error).message);
}
}
// Call the functions
runPayment();
verifyPayment();
listPayments();
retrieveSinglePayment();
JavaScript Example:
const { PaymentGateway } = require("node-paykit"); // Ensure you are importing the class correctly
require("dotenv").config();
const paystackProvider = new PaymentGateway('paystack', process.env.PAYSTACK_SECRET_KEY); // Use 'new' to instantiate the class
(async () => {
const payload = {
email: "customer@email.com",
amount: "20000",
callback_url: "https://www.google.com",
// to add more to this payload, see official docs https://paystack.com/docs/api/transaction/#initialize
};
try {
const createPayment = await paystackProvider.createPayment(payload);
console.log("Payment reference:", createPayment);
} catch (error) {
console.error("Error creating payment:", error);
}
})();
(async () => {
// More info here https://paystack.com/docs/api/transaction/#verify
const reference = "i3mg37nrys";
try {
const verifyPayment = await paystackProvider.verifyPayment(reference);
console.log("Payment verification:", verifyPayment);
} catch (error) {
console.error("Error verifying payment:", error);
}
})();
(async () => {
// Filter params for the listPayments more info here https://paystack.com/docs/api/transaction/#list
const params = {
perPage: 10,
page: 1,
status: 'success',
from: '2024-01-01T00:00:00.000Z',
to: '2024-01-31T23:59:59.000Z'
};
try {
const listPayments = await paystackProvider.listPayments(params);
console.log("Payment list:", listPayments);
} catch (error) {
console.error("Error listing payments:", error);
}
})();
(async () => {
// More info here https://paystack.com/docs/api/transaction/#retrieve
const tranId = "3806666186";
try {
const retrieveSinglePayment = await paystackProvider.retrieveSinglePayment(tranId);
console.log("Payment details:", retrieveSinglePayment);
} catch (error) {
console.error("Error retrieving payment:", error);
}
})();
TypeScript Example:
import { PaymentGateway } from "node-paykit";
import * as dotenv from 'dotenv';
dotenv.config();
const paystackKey = process.env.PAYSTACK_SECRET_KEY;
if (!paystackKey) {
throw new Error("PAYSTACK_SECRET_KEY is not set in the environment variables");
}
// Initiate your payment provider (in this case, Paystack)
const provider = new PaymentGateway('paystack', paystackKey);
async function runPayment() {
const payload = {
email: "customer@example.com",
amount: 2000,
currency: 'NGN',
callback_url: "https://www.google.com",
};
// For more information and payload details, see the official Paystack docs https://paystack.com/docs/api/transaction/#initialize
try {
const payment = await provider.createPayment(payload);
console.log("Payment reference:", payment);
} catch (error) {
console.error("Error creating payment:", (error as Error).message);
}
}
async function verifyPayment() {
// For more info about verification of payment, see https://paystack.com/docs/api/transaction/#verify
const reference = "i3mg37nrys";
try {
const payment = await
provider.verifyPayment(reference);
console.log("Payment verification:", payment);
} catch (error) {
console.error("Error verifying payment:", (error as Error).message);
}
}
async function listPayments() {
// Filter params for listPayments, more info here https://paystack.com/docs/api/transaction/#list
const params = {
perPage: 10,
page: 1,
status: 'success',
from: '2024-01-01T00:00:00.000Z',
to: '2024-01-31T23:59:59.000Z'
};
try {
const payments = await provider.listPayments(params);
console.log("Payment list:", payments);
} catch (error) {
console.error("Error listing payments:", (error as Error).message);
}
}
async function retrieveSinglePayment() {
// For more info about retrieving a single payment, see https://paystack.com/docs/api/transaction/#retrieve
const tranId = "3806666186";
try {
const payment = await provider.retrieveSinglePayment(tranId);
console.log("Payment details:", payment);
} catch (error) {
console.error("Error retrieving payment:", (error as Error).message);
}
}
// Call the functions
runPayment();
verifyPayment();
listPayments();
retrieveSinglePayment();
createPayment(payload: object)
verifyPayment(reference: string)
listPayments(params: object)
retrieveSinglePayment(transactionId: string)
Contributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/AmazingFeature)git commit -m 'Add some AmazingFeature')git push origin feature/AmazingFeature)Distributed under the MIT License. See LICENSE for more information.
Nwafor Glory - GitHub
FAQs
A flexible Node.js package for seamless integration with multiple payment gateways
We found that node-paykit demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.