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

tsapay-sdk

v1.0.2

Published

The official Node.js / TypeScript SDK for TsaPay Mobile Money Aggregator

Readme

TsaPay Node.js SDK

NPM Version License

The official Node.js / TypeScript SDK for TsaPay, the universal Mobile Money aggregator for the CEMAC zone (MTN MoMo, Orange Money).

Integrate Mobile Money payments into your e-commerce platform, mobile app backend, or SaaS in just a few lines of code.

📦 Installation

npm install tsapay-sdk
# or
yarn add tsapay-sdk
# or
pnpm add tsapay-sdk

🚀 Quick Start

1. Initialization

First, get your API Key from your TsaPay Merchant Dashboard.

import { TsaPayClient } from 'tsapay-sdk';

const tsapay = new TsaPayClient({
  apiKey: 'sk_test_YOUR_API_KEY_HERE',
  // baseUrl is optional, defaults to the production gateway
});

2. Create a Payment

Initiate a USSD push directly to the customer's phone.

try {
  const response = await tsapay.createPayment({
    amount: 1500,
    currency: 'XAF', // Optional, defaults to XAF
    provider: 'mtn_momo', // or 'orange_money'
    phoneNumber: '+237670000000', // Customer's phone number
    description: 'Order #12345',
    reference: 'REF-12345', // Your internal order reference
    callbackUrl: 'https://your-site.com/api/webhooks/tsapay', // Where we should send the webhook
  });

  console.log('Payment initiated successfully:', response.payment.id);
  console.log('Status:', response.payment.status); // 'pending'
} catch (error) {
  console.error('Payment failed:', error.message);
}

3. Check Payment Status

const response = await tsapay.getPayment('pay_123456789');
console.log('Current status:', response.payment.status);

4. Verify Webhooks

When a payment succeeds or fails, TsaPay will send a POST request to your callbackUrl. To ensure this request actually came from TsaPay, you must verify the signature using your Webhook Secret.

import express from 'express';

const app = express();
const WEBHOOK_SECRET = 'whsec_YOUR_WEBHOOK_SECRET';

app.post('/api/webhooks/tsapay', express.raw({ type: 'application/json' }), (req, res) => {
  const signature = req.headers['x-tsapay-signature'] as string;
  const payload = req.body.toString();

  // Verify the signature
  const isValid = tsapay.verifyWebhookSignature(payload, signature, WEBHOOK_SECRET);

  if (!isValid) {
    return res.status(400).send('Invalid signature');
  }

  const event = JSON.parse(payload);
  
  if (event.event_type === 'payment.success') {
    console.log('Payment successful for:', event.data.reference);
    // TODO: Fulfill the order in your database
  }

  res.send('Webhook received');
});

📚 Features

  • Zero dependencies (uses native fetch)
  • Full TypeScript support with strict types
  • Built-in idempotency to prevent duplicate charges
  • Secure webhook verification helper included

📄 License

MIT