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 🙏

© 2026 – Pkg Stats / Ryan Hefner

onepay-sdk

v0.1.0

Published

A simple payment gateway for Node.js

Readme

🧾 OnePay-SDK - Unified Payment Gateway Wrapper

OnePay-SDK is a lightweight and developer-friendly TypeScript package that simplifies integration with multiple payment gateways such as Stripe and Razorpay in a single unified interface.

🔐 Use OnePay-SDK to easily validate and manage API keys for multiple gateways in one project.


🚀 Features

  • ✅ Multi-gateway support (Stripe & Razorpay)
  • 🛠️ Validate API keys with easy-to-use methods
  • 💳 Create, verify, and process payments through a consistent API
  • 🔄 Process refunds with a unified interface
  • 🔍 Retrieve payment details across gateways
  • 🔌 Plug-and-play class-based API
  • 💡 Written in TypeScript (with full types support)
  • 🔧 Easily extendable for more gateways in future

📦 Installation

npm install onepay-sdk
# or
yarn add onepay-sdk

🛠️ Usage

Initialize OnePay-SDK

To start using OnePay-SDK, initialize it with the API keys for the supported gateways:

import { OnePay } from "onepay-sdk";

const onePay = new OnePay([
  { gateway: "stripe", apiKey: "your-stripe-api-key" },
  { gateway: "razorpay", apiKey: "your-razorpay-key-id", apiSecret: "your-razorpay-key-secret" },
]);

Validate Gateways

You can validate the configured gateways to ensure the API keys are correct:

const stripeValidation = await onePay.validateGateway("stripe");
console.log(stripeValidation);

const razorpayValidation = await onePay.validateGateway("razorpay");
console.log(razorpayValidation);

Create Payments

OnePay allows you to create payments for the supported gateways:

Razorpay

const razorpayPayment = await onePay.createPayment({
  gateway: "razorpay",
  amount: 50, // Amount in regular currency (will be converted to paise internally)
  currency: "INR",
  description: "Premium Subscription",
  metadata: { customer_id: "cust_123", product_id: "prod_456" }
});
console.log(razorpayPayment);
// Returns Razorpay order details including orderId

Stripe

const stripePayment = await onePay.createPayment({
  gateway: "stripe",
  amount: 50, // Amount in regular currency (will be converted to cents internally)
  currency: "usd",
  description: "Test Payment",
  customerEmail: "[email protected]",
  paymentMethodTypes: ["card"],
  customerId: "cust_123456", // Optional Stripe customer ID
  metadata: { order_id: "6735" }
});
console.log(stripePayment);
// Returns a client secret that can be used with Stripe.js

Verify Payments

After payment completion on the client side, you can verify payments:

Razorpay Verification

const verifyRazorpay = await onePay.verifyPayment({
  gateway: "razorpay",
  paymentId: "pay_123456789",
  orderId: "order_123456789",
  signature: "signature_from_razorpay_callback" 
});
console.log(verifyRazorpay);

Stripe Verification

const verifyStripe = await onePay.verifyPayment({
  gateway: "stripe",
  paymentId: "pi_123456789" // Payment Intent ID
});
console.log(verifyStripe);

Process Refunds

You can process refunds for completed payments:

// Full refund
const fullRefund = await onePay.refundPayment(
  "stripe", 
  "pi_123456789"
);

// Partial refund
const partialRefund = await onePay.refundPayment(
  "razorpay", 
  "pay_123456789", 
  25.00 // Refund amount in regular currency
);

Retrieve Payment Details

Get payment information at any time:

const paymentDetails = await onePay.getPaymentDetails(
  "stripe", 
  "pi_123456789"
);
console.log(paymentDetails);

🧩 Type Definitions

OnePay-SDK exports TypeScript interfaces to help with development:

// Initialize payment gateways
type KeyProps = {
  gateway: 'stripe' | 'razorpay'; 
  apiKey: string;
  apiSecret?: string;
}

// Create payment payload
type PaymentPayload = {
  gateway: 'stripe' | 'razorpay';
  amount: number;
  currency: string;
  description: string;
  customerEmail?: string;
  metadata?: Record<string, any>;
  paymentMethodTypes?: string[];
  customerId?: string;
  receiptId?: string;
}

// Verify payment payload
type PaymentVerificationPayload = {
  gateway: 'stripe' | 'razorpay';
  paymentId: string;
  orderId?: string; // For Razorpay
  signature?: string; // For Razorpay
}

📋 Response Format

All methods return a consistent response format:

{
  success: boolean;
  gateway: 'stripe' | 'razorpay';
  message?: string; // Error message if success is false
  
  // For Stripe
  clientSecret?: string;
  paymentIntentId?: string;
  
  // For Razorpay
  order?: any;
  orderId?: string;
}

🤝 Contributing

Contributions are welcome! Feel free to open issues or submit pull requests.

📄 License

MIT