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 🙏

© 2025 – Pkg Stats / Ryan Hefner

workforce-sdk

v1.0.0

Published

Workforce Payment System Integration SDK

Readme

A comprehensive JavaScript SDK for integrating with workforce payment systems, designed to provide a complete flow from onboarding to withdrawal completion.

🚀 Features

  • Authentication: ID and phone number support
  • Mobile-First Design: Beautiful, responsive interface
  • Complete Flow Implementation: 7-step process from onboarding to withdrawal completion
  • Payment System Integration: Seamless integration with workforce payment systems
  • Fee Calculation: Automatic early access fees and VAT calculation
  • Transaction Management: Full transaction history and balance tracking
  • Comprehensive Testing: 25 automated tests covering all functionality
  • Modern UI/UX: Beautiful gradients, animations, and mobile-responsive design

🏗️ Architecture Overview

The SDK follows a complete flow:

  1. 🔐 Get Started: ID and phone number authentication
  2. 👤 Welcome: User profile, employer info, and financial summary
  3. 📊 Transaction History: Available balance and transaction list
  4. 💰 Get Paid: Amount selection with fee breakdown
  5. 🔒 Validation: System validates user and checks eligibility
  6. ⚙️ Processing: System processes withdrawal and generates receipt
  7. 🎉 Success: Show receipt and return to dashboard option

💰 Financial Calculations

  • Available Balance: 25% of earned salary
  • Early Access Fee: 5% of withdrawal amount
  • VAT: 5% on early access fee
  • Total Fee: Early access fee + VAT
  • You Receive: Requested amount - Total fee

🚀 Quick Start

Installation

# Install dependencies
npm install

# Start development server
npm run dev

# Build the SDK for distribution
npm run build:sdk

Integration Methods

1. NPM Package (Recommended)

npm install workforce-sdk

2. CDN (Browser)

<script src="https://unpkg.com/[email protected]/dist/index.umd.js"></script>

3. Direct Import

git clone https://github.com/workforce/workforce-sdk.git
cd workforce-sdk
npm install
npm run build:sdk

Basic Usage

import WorkforceSDK from './sdk/index.js';

// Initialize SDK
const sdk = new WorkforceSDK({ debug: true });

// Step 1: Onboard user with ID
const credentials = {
  id: '123-4567-8901234-0',
  phoneNumber: '+1234567890'
};

const onboardResult = await sdk.onboardUser(credentials);

// Step 2: Get user details
const userDetails = sdk.getUserDetails();

// Step 3: Get transaction history
const history = sdk.getTransactionHistory();

// Step 4: Calculate fees
const fees = sdk.calculateWithdrawalFees(100);

// Step 5: Initiate withdrawal
const withdrawal = await sdk.handleWithdrawalRequest(100, 'salary');

// Step 6: System validation
const callback = withdrawal.callback;
const validation = await callback.validateUser({
  method: 'id',
  value: '123-4567-8901234-0'
});

// Step 7: System processing
const processing = await callback.processWithdrawal(validation);

🧪 Testing

Interactive Demo

  1. Open the app in your browser
  2. Go to "SDK Flow Demo" tab
  3. Follow the 7-step flow:
    • Login with ID: 123-4567-8901234-0
    • Phone: +1234567890
    • Navigate through each step
    • Test fee calculations
    • Complete system integration

Automated Tests

  1. Go to "Run Tests" tab
  2. Click "🚀 Run All Tests"
  3. View results for 25 comprehensive tests

Test Coverage

  • ✅ UserSession management (3 tests)
  • ✅ UserEligibility checks (3 tests)
  • ✅ TransactionHistory management (2 tests)
  • ✅ SystemIntegration validation (4 tests)
  • ✅ WithdrawalHandler processing (3 tests)
  • ✅ WorkforceSDK integration (5 tests)
  • ✅ End-to-End flow testing (2 tests)
  • ✅ Error handling scenarios (3 tests)

📚 API Reference

🔐 UserSession Class

Manages user authentication state and session data:

createSession(userData)     // Create new user session
getSession()                // Get current session information
clearSession()              // Clear session and logout user

✅ UserEligibility Class

Handles eligibility checks and withdrawal limits:

checkEligibility(userData)           // Check if user is eligible for withdrawals
getIneligibilityReasons(userData)    // Get reasons why user is ineligible
calculateLimits(userData)            // Calculate available balance based on earned salary
calculateFees(amount, userData)      // Calculate early access fees and VAT

📊 TransactionHistory Class

Manages transaction records:

addTransaction(transaction)                    // Add new transaction
getTransactionHistory(userId, limit)          // Get user's transaction history
updateTransactionStatus(transactionId, status) // Update transaction status
formatTransactionDate(timestamp)              // Format dates for display

💰 WithdrawalHandler Class

Handles withdrawal requests and system integration:

initiateWithdrawal(userData, amount, type)    // Create withdrawal request
validateWithdrawalRequest(userData, amount)   // Validate withdrawal parameters
createCallback(withdrawalRequest)             // Create system integration callback

🏦 SystemIntegration Class

Payment system integration layer:

validateUser(credentials, withdrawalRequest)      // Validate user with system
checkEligibility(withdrawalRequest)               // Check eligibility on system side
processWithdrawal(withdrawalRequest, validationResult) // Process withdrawal through system
generateReceipt(withdrawalRequest)               // Generate transaction receipt

🚀 WorkforceSDK Class

Main SDK class orchestrating the entire flow:

onboardUser(credentials)              // Step 1: ID authentication
getUserDetails()                      // Step 2: Display user information
getTransactionHistory()               // Step 3: Get balance and transactions
calculateWithdrawalFees(amount)      // Step 4: Calculate fees and VAT
handleWithdrawalRequest(amount, type) // Step 5: Initiate withdrawal
exitSDK()                            // Exit and clear session

🔄 System Callback Flow

The SDK exposes callbacks to the payment system for their side of logic:

  • validateUser: System validates ID and eligibility
  • processWithdrawal: System processes the withdrawal and generates receipt
  • Return to Dashboard: After successful processing, user returns to main interface

⚙️ Configuration

SDK can be configured with various options:

const sdk = new WorkforceSDK({
  debug: true,                    // Enable/disable debug logging
  endpoint: 'https://api.example.com', // API endpoint URL
  currency: 'USD',                // Currency (default: USD)
  country: 'US',                  // Country (default: US)
  version: '1.0.0'               // SDK version string
});

🎨 UI Components

Mobile-First Design

  • Responsive Layout: Works perfectly on all device sizes
  • Beautiful Gradients: Modern purple-blue gradient theme
  • Smooth Animations: Hover effects and transitions
  • Interactive Elements: ID fields, currency display

Interactive Elements

  • Step-by-Step Flow: Clear navigation between 7 steps
  • Quick Amount Selection: Pre-defined amounts (100, 250, 500, 750)
  • Real-time Fee Calculation: Instant fee breakdown as you type
  • Progress Indicators: Visual flow navigation
  • Success Receipts: Beautiful transaction confirmation

🚀 Development

Project Structure

src/
├── sdk/
│   ├── index.js              # Main SDK implementation
│   ├── testRunner.js         # Automated test runner
│   └── __tests__/
│       └── sdk.test.js       # Comprehensive test suite
├── App.jsx                   # Main React application
├── App.css                   # Beautiful styling
└── main.jsx                  # App entry point

Running the Project

# Install dependencies
npm install

# Start development server
npm run dev

# Run tests
npm test

Network Access

The development server is configured to be accessible from other devices on your network:

# Local access
http://localhost:5173

# Network access (from other devices)
http://192.168.0.122:5173

🔧 Mock Data

For testing purposes, the SDK includes mock user data:

  • ID: 123-4567-8901234-0
  • Phone: +1234567890
  • Name: John Doe
  • Employer: Example Corp
  • Partner: Payment Partner
  • Monthly Salary: 3,000 USD
  • Earned Salary: 1,500 USD
  • Available Balance: 375 USD (25% of earned salary)

🔗 Integration with Other Systems

The SDK is designed for seamless integration with various platforms and systems:

Frontend Frameworks

  • React: Full component integration with hooks
  • Vue.js: Component-based integration
  • Angular: Service-based integration
  • Vanilla JavaScript: Direct SDK usage

Backend Systems

  • Node.js: Express.js API integration
  • Python: Flask/Django integration
  • Java: Spring Boot integration
  • PHP: Laravel integration

Mobile Applications

  • React Native: Cross-platform mobile integration
  • Flutter: Dart-based integration
  • Native iOS: Swift/Objective-C integration
  • Native Android: Java/Kotlin integration

Enterprise Systems

  • Banking Platforms: Core banking integration
  • Payment Gateways: Payment processor integration
  • HR Systems: Employee management integration
  • ERP Systems: Enterprise resource planning integration

🌟 What Makes This Special

  • Complete Flow: Built to handle the entire workforce payment process
  • Production Ready: Comprehensive error handling and validation
  • Beautiful UI: Modern, mobile-first design with smooth animations
  • Full Testing: 25 automated tests ensure reliability
  • Documentation: Complete API reference and examples
  • System Ready: Seamless integration with payment systems

📚 Additional Resources

📄 License

This project is designed for workforce payment SDK integration and testing purposes.


Built with ❤️ for workforce payment systems