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

one-pay

v1.0.6

Published

A versatile NPM library designed to simplify payment gateway integration for Razorpay and Cashfree. One-Pay allows developers to perform payments, refunds, and other operations with minimal effort, eliminating the need for extensive boilerplate code. It's

Downloads

452

Readme

Logo

One-Pay

A versatile NPM library designed to simplify payment gateway integration for Razorpay and Cashfree. One-Pay allows developers to perform payments, refunds, and other operations with minimal effort, eliminating the need for extensive boilerplate code. It's the ultimate tool for seamless transaction management in your applications.

How To Use

const OnePay = require('one-pay')

const config = {
    provider : '*', // Specify the provider (e.g., 'razorpay', 'cashfree')
    apiKey : '*', // Your API Key
    apiSecret : '', // Your API Secret
}

const instance = new OnePay(config);

Methods Available

1. Create an Order

Create a new order in the payment gateway.

async function createOrder() {
    const data = {
        amount: null, // Amount for the order
        currency: null, // Currency (e.g., 'INR', 'USD')
        customer: {
            name: null, // Customer's name
            email: null, // Customer's email
            phone: null, // Customer's phone
        },
        metaData: {}, // Additional metadata for the order
    };
    const res = await instance.createOrder(data);
    return res;
}

2. Fetch an Order

Fetch details of a specific order using its ID.

async function fetchOrder() {
    const orderId = null; // The ID of the order to fetch
    const res = await instance.fetchOrder(orderId);
    return res;
}

3. Fetch All Orders

Retrieve all orders created in the system.

async function fetchAllOrder() {
    const res = await instance.fetchAllOrder();
    return res;
}

4. Create a Refund

Initiate a refund for a specific payment or order.

async function createRefund() {
    const data = {
        orderId: null, // ID of the order
        paymentId: null, // ID of the payment
        options: {
            amount: null, // Refund amount
            refundId: null, // Optional refund ID
            speed: null, // Speed of refund (e.g., 'normal', 'instant')
            notes: {}, // Additional notes for the refund
        },
    };
    const res = await instance.createRefund(data);
    return res;
}

5. Fetch a Refund

Fetch details of a specific refund.

async function fetchRefund() {
    const data = {
        paymentId: null, // Payment ID associated with the refund
        orderId: null, // Order ID associated with the refund
        refundId: null, // ID of the refund
    };
    const res = await instance.fetchRefund(data);
    return res;
}

6. Fetch Multiple Refunds

Retrieve multiple refunds for a specific payment or order.

async function fetchMultipleRefund() {
    const data = {
        paymentId: null, // Payment ID
        orderId: null, // Order ID
        options: {
            from: null, // Start date/time
            to: null, // End date/time
            skip: null, // Number of records to skip
            count: null, // Number of records to fetch
        },
    };
    const res = await instance.fetchMultipleRefund(data);
    return res;
}

7. Fetch All Refunds

Retrieve all refunds in the system.

async function fetchAllRefund() {
    const data = {
        from: null, // Start date/time
        to: null, // End date/time
        skip: null, // Number of records to skip
        count: null, // Number of records to fetch
    };
    const res = await instance.fetchAllRefund(data);
    return res;
}

8. Capture a Payment

Capture a payment for an order.

async function capturePayment() {
    const data = {
        paymentId: null, // Payment ID to capture
        orderId: null, // Order ID associated with the payment
        amount: null, // Amount to capture
        currency: null, // Currency of the payment
        action: null, // Capture action
    };
    const res = await instance.capturePayment(data);
    return res;
}

9. Fetch a Payment

Fetch details of a specific payment.

async function fetchPayment() {
    const data = {
        paymentId: null, // Payment ID
        orderId: null, // Order ID associated with the payment
    };
    const res = await instance.fetchPayment(data);
    return res;
}

10. Fetch All Payments for an Order

Retrieve all payments for a specific order.

async function fetchAllOrderPayments() {
    const data = {
        orderId: null, // Order ID
    };
    const res = await instance.fetchAllOrderPayments(data);
    return res;
}

11. Fetch All Payments

Retrieve all payments in the system.

async function fetchAllPayments() {
    const data = {
        from: null, // Start date/time
        to: null, // End date/time
        skip: null, // Number of records to skip
        count: null, // Number of records to fetch
    };
    const res = await instance.fetchAllPayments(data);
    return res;
}