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

pesafy

v0.4.3

Published

A powerful payment gateway library for African payment systems, starting with M-Pesa Daraja API

Readme

Pesafy 💳

A powerful, type-safe payment gateway library for African payment systems, starting with M-Pesa Daraja API

npm version License: MIT TypeScript

Pesafy simplifies payment processing for Kenyan merchants by providing a clean, well-documented, and easy-to-use interface for M-Pesa transactions. Built with TypeScript, following industry best practices inspired by Stripe.

✨ Features

  • 🚀 Easy Integration: Simple, intuitive API design
  • 🔒 Type-Safe: Full TypeScript support with comprehensive types
  • 🎯 Complete M-Pesa Coverage: STK Push, B2C, B2B, C2B, QR Codes, and more
  • 🔐 Secure: Built-in security credential encryption and webhook verification
  • 🎨 Dashboard Ready: Payment monitoring and webhook management dashboard
  • 🧩 Component Library: Reusable payment components for React/Vue
  • 📚 Well Documented: Comprehensive documentation and examples
  • Fast: Built with Bun for optimal performance

📦 Installation

# Using npm
npm install pesafy

# Using yarn
yarn add pesafy

# Using pnpm
pnpm add pesafy

# Using bun
bun add pesafy

🚀 Quick Start

import { Mpesa } from "pesafy";

const mpesa = new Mpesa({
  consumerKey: "your-consumer-key",
  consumerSecret: "your-consumer-secret",
  environment: "sandbox",
  lipaNaMpesaShortCode: "174379",
  lipaNaMpesaPassKey: "your-passkey",
});

// STK Push (M-Pesa Express)
const result = await mpesa.stkPush({
  amount: 100,
  phoneNumber: "254712345678",
  callbackUrl: "https://yoursite.com/callback",
  accountReference: "ORDER-123",
  transactionDesc: "Payment for order",
});

📚 Documentation

🎯 Supported APIs

✅ Available

  • STK Push (M-Pesa Express) - Initiate payments via STK Push
  • STK Query - Check STK Push transaction status
  • B2C - Business to Customer payments
  • B2B - Business to Business payments
  • C2B - Register URLs & simulate (sandbox)
  • Dynamic QR Codes - Generate LIPA NA M-PESA QR codes
  • Transaction Status - Query transaction status
  • Reversal - Reverse transactions

📦 Components

  • PaymentButton - Simple button to trigger payments
  • PaymentForm - Complete form for collecting payment details
  • QRCode - Display M-Pesa dynamic QR codes
  • PaymentStatus - Show payment status with visual feedback

🏗️ Project Structure

pesafy/
├── src/              # Source code
├── docs/             # Documentation
├── tests/            # Test files
├── examples/         # Example projects
└── components/       # Payment components (coming soon)

See FOLDER_STRUCTURE.md for detailed structure.

🧪 Development

# Install dependencies
bun install

# Run tests
bun test

# Build the library
bun run build

# Run type checking
bun run typecheck

# Format code
bun run format

# Lint code
bun run lint

📊 Dashboard (SaaS)

Run the payment monitoring dashboard:

cd dashboard
bun install
bun run dev

Open http://localhost:3000 to view the dashboard. See RUNNING.md for full instructions.

📝 Contributing

Contributions are welcome! Please read our contributing guidelines before submitting PRs.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

🔐 Security

For security concerns, please email [email protected] instead of using the issue tracker.

📄 License

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

🙏 Acknowledgments

  • Safaricom Daraja API - For providing the M-Pesa API
  • Inspired by payment gateway patterns from Stripe and other industry leaders

📞 Support

🗺️ Roadmap

See PROJECT_PLAN.md for the complete development roadmap.

Phase 1 (Current): Core library foundation ✅
Phase 2: Payment processing implementation 🚧
Phase 3: Webhook management system 📅
Phase 4: Dashboard development 📅
Phase 5: Payment components 📅


Made with ❤️ for the African developer community