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

@malipopay/react

v1.0.0

Published

Official Malipopay React SDK - Checkout components, payment widgets, and hooks for Tanzania mobile money, bank, card, and USSD payments

Readme

@malipopay/react

Official React SDK for Malipopay. Ready-to-use checkout components, payment widgets, and hooks for accepting payments in Tanzania via Mobile Money (M-Pesa, Airtel Money, Mixx/YAS, Halopesa, T-Pesa), Bank Transfer, USSD, and Card.

Installation

npm install @malipopay/react
# or
yarn add @malipopay/react

Architecture: Backend-First

The React SDK does not take your API key directly — that would expose it in the browser. Instead, your backend creates payments using the server-side SDK and the React SDK calls your backend.

 ┌─────────┐  1. user clicks pay   ┌─────────┐  3. collect()  ┌───────────┐
 │ React   │ ────────────────────► │ Your    │ ─────────────► │ Malipopay │
 │ SDK     │ ◄──────────────────── │ Backend │ ◄───────────── │ API       │
 └─────────┘  4. open payment link └─────────┘  2. reference  └───────────┘

Quick Start

1. Backend endpoint (Node.js example)

import express from "express";
import { Malipopay } from "malipopay";

const app = express();
app.use(express.json());
const client = new Malipopay(process.env.MALIPOPAY_API_KEY!);

app.post("/api/payments", async (req, res) => {
  const payment = await client.payments.collect(req.body);
  res.json(payment);
});

app.get("/api/payments/:ref/status", async (req, res) => {
  const result = await client.payments.verify(req.params.ref);
  res.json(result);
});

2. Wrap your app with MalipopayProvider

import { MalipopayProvider } from "@malipopay/react";

function App() {
  return (
    <MalipopayProvider apiUrl="/api/payments">
      <Checkout />
    </MalipopayProvider>
  );
}

3. Add a CheckoutButton

import { CheckoutButton } from "@malipopay/react";

function Checkout() {
  return (
    <CheckoutButton
      payment={{
        description: "Order #1234",
        amount: 10000,
        phoneNumber: "255712345678",
      }}
      onSuccess={(p) => console.log("Paid:", p.reference)}
      onFailure={(err) => console.error(err)}
    >
      Pay TZS 10,000
    </CheckoutButton>
  );
}

Components

<CheckoutButton>

Single-click payment button. Creates a payment, opens the checkout, and polls for completion.

<CheckoutButton
  payment={{ description: "...", amount: 10000, phoneNumber: "255712345678" }}
  mode="popup"                      // "popup" | "newtab" | "redirect"
  onSuccess={(payment) => {}}
  onFailure={(error) => {}}
  onCancel={() => {}}
>
  Pay now
</CheckoutButton>

<PaymentForm>

Inline form with amount, phone, and description inputs.

<PaymentForm
  amount={10000}                    // Optional: prefill & lock amount
  description="Monthly subscription" // Optional: prefill & lock description
  buttonLabel="Subscribe"
  onSuccess={(p) => console.log(p)}
/>

<PaymentLinkEmbed>

Embed a payment link as an iframe.

<PaymentLinkEmbed link={payment.link} height={700} />

<PaymentStatus>

Live status with polling (pending → completed/failed).

<PaymentStatus
  reference={payment.reference}
  onFinal={(p) => console.log("Done:", p.status)}
/>

Hooks

usePayment()

Create a payment programmatically.

const { createPayment, payment, loading, error } = usePayment();

const handleClick = async () => {
  const result = await createPayment({
    description: "Order #1234",
    amount: 10000,
    phoneNumber: "255712345678",
  });
  window.location.href = result.link!;
};

usePaymentStatus()

Poll a payment's status until a terminal state.

const { status, payment, polling } = usePaymentStatus({
  reference: "PAY-abc123",
  interval: 3000,
  onFinal: (p) => console.log("Done:", p.status),
});

useCheckout()

Combines usePayment + usePaymentStatus. Opens a checkout window and polls.

const { checkout, payment, loading } = useCheckout();

await checkout(
  { description: "Order", amount: 10000, phoneNumber: "255712345678" },
  { mode: "popup", onSuccess: (p) => console.log(p) }
);

Environments

<MalipopayProvider environment="uat">     // for testing
<MalipopayProvider environment="production"> // default

Error Handling

import { MalipopayError } from "@malipopay/react";

try {
  await createPayment(...);
} catch (err) {
  if (err instanceof MalipopayError) {
    console.log("Status:", err.statusCode, "Code:", err.code);
  }
}

Requirements

License

MIT


See Also

| SDK | Install | |-----|---------| | Node.js | npm install malipopay | | Python | pip install malipopay | | PHP | composer require malipopay/malipopay-php | | Java | Maven / Gradle | | .NET | dotnet add package Malipopay | | Ruby | gem install malipopay | | Flutter/Dart | flutter pub add malipopay | | React | npm install @malipopay/react |

API Reference | OpenAPI Spec