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

telebirr-nodejs

v1.1.8

Published

Unofficial Node.js SDK for Telebirr C2B payments with automatic request signing, Fabric token handling, checkout URL generation, simulator support, and simplified refunds & payment status APIs.

Readme

telebirr-nodejs

A simple, opinionated Node.js SDK for integrating Telebirr C2B payments with automatic request signing, Fabric token handling, and checkout URL generation.


Installation

npm install telebirr-nodejs

Required Configuration

Telebirr requires credentials and callback URLs. You should never hard-code secrets. Always load them from process.env.


Required Credentials

| Name | Description | | ------------------- | -------------------------------------------------------------------------------------- | | FABRIC_APP_ID | Fabric application ID (c4182ef8-9249-458a-985e-06d191f4d505 uuid-v4 string) | | FABRIC_APP_SECRET | Fabric application secret ("fad0f06383c6297f54rr78694b974599" 32 hex character string) | | MERCHANT_APP_ID | Merchant application ID ("7606201678956824" 16 integer character string) | | MERCHANT_CODE | Merchant code ("000000" 6 integer character string) | | PRIVATE_KEY | RSA private key (PEM string) |


Required URLs

| Name | Description | | ----------------------- | ------------------------------- | | TELEBIRR_NOTIFY_URL | Server-to-server callback URL | | TELEBIRR_REDIRECT_URL | User redirect URL after payment |


Basic Setup


import { C2B } from "telebirr-nodejs";

const c2bClient = new C2B({
  mode: "sandbox", // "simulate" | "sandbox" | "production"
  appId: process.env.FABRIC_APP_ID,
  appSecret: process.env.FABRIC_APP_SECRET,
  merchantAppId: process.env.MERCHANT_APP_ID,
  merchantCode: process.env.MERCHANT_CODE,
  privateKey: process.env.PRIVATE_KEY,
  notifyUrl: process.env.TELEBIRR_NOTIFY_URL,
  redirectUrl: process.env.TELEBIRR_REDIRECT_URL,
  http: true, // allow HTTP in simulator mode
});

Important

MERCHANT_PRIVATE_KEY must be the full PEM string, including:

-----BEGIN RSA PRIVATE KEY-----
...
-----END RSA PRIVATE KEY-----

Example API Routes

  1. POST /payment/initiate
  2. GET /payment/status
  3. POST /payment/refund

1. Initiate Payment

Creates an order and redirects the user to the Telebirr checkout page.

app.post("/payment/initiate", async (req, res) => {
    const checkoutUrl = await c2bClient.checkout({
        merchOrderId: "order123",
        title: "Phone",
        amount: "12",
        callbackInfo: "from web checkout",
    });

    res.redirect(checkoutUrl);
});

If you are using a frontend framework (for example React) and do not want to lose application state, return the checkout URL as JSON and let the frontend handle the redirection.


2. Query Payment Status

Used to check the payment result using the merchant order ID.

app.get("/payment/status", async (req, res) => {
    const { merchOrderId } = req.body;

    const info = await c2bClient.queryOrder(merchOrderId);

    res.json(info);
});

Please refer to Telebirr’s official documentation to correctly handle the query order json response: https://developer.ethiotelecom.et/docs/H5%20C2B%20Web%20Payment%20Integration%20Quick%20Guide/queryOrder


3. Refund Payment

Refunds a completed transaction.

app.post("/payment/refund", async (req, res) => {
    const refundData = await c2bClient.refundOrder({
        merchOrderId: "order123",
        refundRequestNo: "CJD7GBPXIP", // unique Identifier of the request generated by the merchant app used for idempotency
        refundReason: "The product is not as I expected",
        amount: "1200",
    });

    res.json(refundData);
});

Please refer to Telebirr’s official documentation to correctly handle the refund order json response: https://developer.ethiotelecom.et/docs/H5%20C2B%20Web%20Payment%20Integration%20Quick%20Guide/RefundOrder


Simulator Mode

To use the simulator provided by this package, set the mode to simulate.

import { C2B } from "telebirr-nodejs";

const c2bClient = new C2B({
    mode: "simulate",
    appId: process.env.FABRIC_APP_ID,
    appSecret: process.env.FABRIC_APP_SECRET,
    merchantAppId: process.env.MERCHANT_APP_ID,
    merchantCode: process.env.MERCHANT_CODE,
    privateKey: process.env.PRIVATE_KEY,
    notifyUrl: "https://example.com/notify",
    redirectUrl: "https://example.com/redirect",
    http: true
});

This mode will generate credentials and add the in .env file in your project root directory The simulator is for learning and development purposes only. The simulation server is provided by this package, not by Telebirr. For real testing, use Telebirr’s sandbox mode and whitelist your public IP address in the Telebirr portal.


Supported Features

  • Fabric token handling
  • RSA-SHA256 request signing
  • C2B checkout
  • Order query
  • Refunds
  • Simulator support
  • Notify URL Handling

Please refer to Telebirr’s official documentation to correctly handle notify callbacks:

https://developer.ethiotelecom.et/docs/H5%20C2B%20Web%20Payment%20Integration%20Quick%20Guide/Notify_Callback


RSA Key Generation

You can generate private and public keys instantly.

import { generateKeys } from "telebirr-nodejs";

generateKeys({
    dir: process.cwd(),
    privateKeyName: "telefy_private.pem",
    publicKeyName: "telefy_public.pem",
    overwrite: false,
});

This will generate two .pem files in your root directory.

The merchantPrivateKey option always accepts a string, so you must read the private key file using Node.js fs and pass the value to the client configuration.

License

MIT © Chernet Manaye