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

saksh-easy-wallet

v1.0.7

Published

A simple and easy-to-use wallet management system for handling user balances and transactions.

Downloads

578

Readme

Saksh Easy Wallet: Secure and Flexible Wallet Management for Node.js

Saksh Easy Wallet Banner

SakshEasyWallet empowers you to manage user wallets within your Node.js applications. It offers robust features for handling multiple currencies, transaction fees, and event-driven notifications. Additionally, it seamlessly integrates with MongoDB for reliable data storage.

Key Features

  • Manage user balances across various currencies
  • Perform debit and credit operations with configurable transaction fees
  • Leverage event handling to stay informed about transactions
  • Maintain a detailed transaction history
  • Configure an admin user to manage transaction fees

Installation

  1. Grab the Code: Clone the repository or download the source code.

  2. Set Up Dependencies: Install required dependencies using npm:

    npm install saksh-easy-wallet

Example Usage

Here's a practical example demonstrating the usage of the SakshWallet class:




const mongoose = require('mongoose');
const SakshWallet = require('saksh-easy-wallet');

// Example usage
(async () => {
    try {
        const userEmail = '[email protected]';

        // Connect to the database
        await mongoose.connect('mongodb://localhost:27017/saksh2323Cart', {
            useNewUrlParser: true,
            useUnifiedTopology: true,
        });
        console.log('Database connected');

        const wallet = new SakshWallet();

        // Set admin email (optional)
        wallet.setAdmin('[email protected]');

        // Credit an amount to the user's wallet
        console.log(await wallet.sakshCredit(userEmail, 500, 'USD', 'ref123', 'Salary payment')); // Credited 500 USD. New balance is 500

        // Debit an amount from the user's wallet
        console.log(await wallet.sakshDebit(userEmail, 200, 'USD', 'ref124', 'Grocery shopping', 5)); // Debited 200 USD. New balance is 295

        // Get balance for a user
        const balance = await wallet.sakshGetBalance(userEmail, 'USD');
        console.log('User Balance:', balance); // User Balance: { email: '[email protected]', currency: 'USD', balance: 295 }

        // Get balance summary for a user
        const balanceSummary = await wallet.sakshGetBalanceSummary(userEmail);
        console.log('Balance Summary:', balanceSummary); // Balance Summary: { email: '[email protected]', balance: { 'USD': 295 } }

        // Close the MongoDB connection
        await mongoose.connection.close();
    } catch (error) {
        console.error('Error:', error);
    }
})();


In this example:

  • Connect to MongoDB: Establishes a connection to a MongoDB database.
  • Set Admin Email: Sets the admin email address.
  • Get Balance: Retrieves the balance for a specific user and currency.
  • Get Balance Summary: Retrieves the balance summary for all currencies for a specific user.
  • Credit Amount: Credits an amount to the user's wallet.
  • Debit Amount: Debits an amount from the user's wallet.

Make sure to replace './path/to/sakshWallet' with the actual path to your SakshWallet class file. This example demonstrates basic usage and can be expanded based on your application's requirements.

API Reference

setAdmin(adminEmail)

  • Sets the admin email address used for transaction fees. If not specified, defaults to [email protected].
  • Parameters:
    • adminEmail (string, optional): The admin user's email address.

sakshGetBalance(email, currency)

  • Retrieves a user's balance in a specific currency.
  • Parameters:
    • email (string): The user's email address.
    • currency (string): The currency code.
  • Returns:
    • A JSON object containing the user's email, currency, and balance.

sakshGetBalanceSummary(email)

  • Retrieves a summary of the user's balance across all currencies.
  • Parameters:
    • email (string): The user's email address.
  • Returns:
    • A JSON object containing the user's email and a balance summary.

sakshCredit(email, amount, currency, reference, description)

  • Credits an amount to the user's wallet.
  • Parameters:
    • email (string): The user's email address.
    • amount (number): The amount to credit.
    • currency (string): The currency code.
    • reference (string): A reference ID for the transaction.
    • description (string): A description of the transaction.
  • Returns:
    • A JSON object containing the transaction details, including the new balance.

sakshDebit(email, amount, currency, reference, description, transactionFee)

  • Debits an amount from the user's wallet.
  • Parameters:
    • email (string): The user's email address.
    • amount (number): The amount to debit.
    • currency (string): The currency code.
    • reference (string): A reference ID for the transaction.
    • description (string): A description of the transaction.
    • transactionFee (number, optional): The transaction fee to apply (if any).
  • Returns:
    • A JSON object containing the transaction details, including the new balance.

sakshGetTransactionReport(email, startDate, endDate)

  • Retrieves a report of transactions for a specific user within a date range.
  • Parameters:
    • email (string): The user's email address.
    • startDate (Date): The start date for the report.
    • endDate (Date): The end date for the report.
  • Returns:
    • An array of transaction objects containing details of each transaction within the specified date range.

Support

If you encounter any issues or have questions regarding Saksh Easy Wallet, please consider the following options for support:

Documentation

  • Refer to the Documentation for detailed information on installation, usage, and API references.

Issues

  • If you find a bug or have a feature request, please open an issue in the Issues section of this repository. Be sure to provide as much detail as possible, including steps to reproduce the issue.

Discussions

  • Join the conversation in the Discussions section to ask questions, share ideas, or seek help from the community.

Contact

  • For direct inquiries, you can reach out via email at susheel2339 @ gmail.com

Contributing

  • We welcome contributions! If you would like to contribute to Saksh Easy Wallet, please check out our Contributing Guidelines for more information.

Thank you for using Saksh Easy Wallet! Your support and feedback are greatly appreciated.