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

naafipay

v1.0.1

Published

Official NaafiPay SDK — accept one-time and subscription payments in Bangladesh (bKash, Nagad, Upay, cards) with one install.

Readme

NaafiPay

Official NaafiPay SDK for Node.js, Bun, Deno, and edge runtimes. Accept one-time payments and recurring subscriptions in Bangladesh (bKash, Nagad, Upay, cards) with a single install.

npm license

Install

npm install naafipay
# or
bun add naafipay
# or
pnpm add naafipay
# or
yarn add naafipay

Requires Node 18+ (uses global fetch).

Quick start

import { NaafiPay } from "naafipay";

const pay = new NaafiPay(process.env.NAAFIPAY_API_KEY!);

Get your API key from Dashboard → API Keys at https://naafipay.com.

One-time payment link

const link = await pay.payments.createLink({
  name: "Order #1234",
  amount: 1500,
  currency: "BDT",
  success_url: "https://shop.example.com/thanks",
  cancel_url: "https://shop.example.com/cart",
});

// Redirect the customer
res.redirect(link.checkout_url);

Subscription (SaaS / recurring digital products)

const sub = await pay.subscriptions.checkout({
  plan_id: "plan_pro_monthly",
  customer_email: "[email protected]",
  customer_name: "Tasin Fahim",
  success_url: "https://app.example.com/welcome",
  cancel_url: "https://app.example.com/pricing",
});

res.redirect(sub.checkout_url!);

Create plans in Dashboard → Subscriptions → Plans (amount, currency, interval, optional trial). NaafiPay handles recurring charges + dunning automatically.

Retrieve & cancel

await pay.payments.retrieve("pay_01HZY...");
await pay.subscriptions.retrieve("sub_01HZY...");
await pay.subscriptions.cancel("sub_01HZY...");
await pay.payments.refund("pay_01HZY...", 500); // partial refund

Webhooks

import { NaafiPay } from "naafipay";

app.post("/webhooks/naafipay", express.raw({ type: "application/json" }), (req, res) => {
  const sig = req.header("x-naafipay-signature") ?? "";
  const ok = NaafiPay.verifyWebhook(req.body.toString("utf8"), sig, process.env.NAAFIPAY_WEBHOOK_SECRET!);
  if (!ok) return res.status(401).end();

  const event = JSON.parse(req.body.toString("utf8"));
  switch (event.type) {
    case "payment.completed": /* fulfill order */ break;
    case "subscription.renewed": /* extend access */ break;
    case "subscription.cancelled": /* revoke access */ break;
  }
  res.json({ received: true });
});

Framework examples

Next.js (App Router)

// app/api/checkout/route.ts
import { NaafiPay } from "naafipay";

export async function POST() {
  const pay = new NaafiPay(process.env.NAAFIPAY_API_KEY!);
  const link = await pay.payments.createLink({ name: "Pro plan", amount: 500 });
  return Response.json({ url: link.checkout_url });
}

Bun

import { NaafiPay } from "naafipay";
const pay = new NaafiPay(Bun.env.NAAFIPAY_API_KEY!);

Cloudflare Workers / edge

Works out of the box — uses global fetch, no Node-only modules at runtime (webhook helper uses node:crypto which is available on Workers with nodejs_compat).

API

| Method | Description | |---|---| | payments.create(input) | Create a payment record | | payments.createLink(input) | Create a hosted checkout link | | payments.retrieve(id) | Fetch a payment by id or reference | | payments.list({ limit, status }) | List payments | | payments.refund(id, amount?) | Refund (full or partial) | | subscriptions.checkout(input) | Start a subscription checkout | | subscriptions.retrieve(id) | Fetch a subscription | | subscriptions.cancel(id) | Cancel a subscription | | NaafiPay.verifyWebhook(body, sig, secret) | Verify webhook signature |

TypeScript

Fully typed. All inputs and responses ship with .d.ts.

License

MIT © NaafiPay