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

cpay-client

v0.0.7

Published

The `CpayClient` library provides a straightforward way to integrate a payment gateway into your applications, allowing you to generate URLs for processing payments with ease.

Downloads

2

Readme

CpayClient Library

The CpayClient library provides a straightforward way to integrate a payment gateway into your applications, allowing you to generate URLs for processing payments with ease.

Features

  • Easy initialization with API key and language settings.
  • Generate payment gateway URLs with detailed transaction information.

Installation

Install CpayClient using npm:

npm i cpay-client

Or if you prefer using yarn:

yarn add cpay-client

Usage

Initialize the Client First, initialize the CpayClient with your API key and optional language preference:

import CpayClient from 'cpay-client';

CpayClient.initial('YOUR_API_KEY', 'en'); // Replace 'YOUR_API_KEY' with your actual API key

Generate a Payment Gateway

To generate a payment gateway URL, provide the necessary transaction details as shown in the example below:

async function generatePaymentGateway() {
    const transactionDetails = {
        description: 'Wireless Headphones JBL', // Description of the item/service
        title: 'Online Store Purchase', // Title of the transaction
        price: 99.99, // Price of the transaction
        uiqueId: '123456789', // A unique identifier for the transaction
        useExternalAddress: false, // Set to true if using an external wallet address
        returnUrl: 'https://yourwebsite.com/payment-return', // URL to redirect after payment
        externalAddress: '', // Optional: External wallet address (if useExternalAddress is true)
    };

    try {
        const response = await CpayClient.generateGateway(transactionDetails);
        console.log('Payment Gateway URL:', response.url);
    } catch (error) {
        console.error('Error generating payment gateway:', error);
    }
}

generatePaymentGateway();

CpayClient Library

The CpayClient library enables easy integration of payment gateway functionalities into your applications, allowing for the generation of payment gateway URLs for various transactions.

API Reference

initial(apiKey: string, lang: string = 'en')

Initializes the CpayClient with the provided API key and language setting.

  • apiKey: Your unique API key for accessing the payment gateway.
  • lang: (Optional) The preferred language for API responses, default is 'en'.

generateGateway(data: object): Promise<Response<GenerateUrlResponse>>

Generates a payment gateway URL using the provided transaction details.

  • data: An object containing key transaction details.

Parameters for data:

  • description: A brief description of the transaction item or service.
  • title: The title or name of the transaction.
  • price: The total price of the transaction.
  • uniqueId: A unique identifier for the transaction.
  • useExternalAddress: A boolean indicating whether an external address is used for the transaction.
  • returnUrl: The URL to redirect to after payment completion.
  • externalAddress: (Optional) The external address to use for the transaction, if useExternalAddress is true.

getTransactionInfo(tnx: string): Promise<Response<GetTransactionInfoById>>

Retrieves detailed information about a specific transaction by its unique identifier. This function makes a GET request to the /invoice/getBy-api-key/{tnx} endpoint, where {tnx} is the transaction identifier.

  • tnx: The unique identifier for the transaction you want to retrieve information about.

Response Structure:

The function returns a promise that resolves to a Response object containing transaction details. The Response object has the following structure:

  • status: The HTTP status code of the response.
  • message: A message describing the outcome of the request.
  • success: A boolean indicating whether the request was successful.
  • result: An object containing the detailed transaction information wrapped in a data property.

Example Usage:

async function fetchTransactionInfo() {
    const transactionId = 'unique_transaction_id';

    try {
        const transactionInfo = await CpayClient.getTransactionInfo(transactionId);
        console.log('Transaction Info:', transactionInfo);
    } catch (error) {
        console.error('Error fetching transaction info:', error);
    }
}

fetchTransactionInfo();

‍‍

Support

For support, please open an issue on our GitHub repository or contact our support team directly through our official channels.

Contributing

Contributions to the CpayClient library are warmly welcomed. Please refer to our contributing guidelines for more information on how to contribute effectively.

License

This project is licensed under the ISC License - see the LICENSE file for details.