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 🙏

© 2025 – Pkg Stats / Ryan Hefner

chapa-node

v1.1.9

Published

Chapa payment sdk node

Readme

Chapa-Node

This library allows you to easily add Chapa as a payment method using nodejs

Installation

With npm

  npm install chapa-node

Or yarn

  yarn add chapa-node

Usage

import Chapa from "chapa-node";

//or
const {default:Chapa} = require("chapa-node");

const chapa = new Chapa("chapaKey");

//separate your customization from the initialize function
chapa.customize({
  logo: "logo url",
  description: "description about the app",
  title: "my app title",
});

//initialize payment
const initializeInfo = {
  amount: "1000",
  currency: "ETB",
  email: "[email protected]",
  first_name: "Abebe",
  last_name: "Kebede",
  tx_ref: "tx-ref-A110000...",
  return_url: "the return url after payment",
  callback_url: "https://myapp.com/my-verify-endpoint/:tx_ref",
};

chapa
  .initialize(initializeInfo)
  .then((response) => {
    console.log(response);
    /*if initialization was successfull response will look like this
        {
        "message": "Hosted Link",
        "status": "success",
        "data": {
            "checkout_url": "https://checkout.chapa.co/checkout/payment/27291184910"
        }

        redirect users to this 'checkout_url' to complete the transaction
    */
  })
  .catch((error) => {
    console.log(error);
});

  //generate auto tx_ref
chapa.initialize(initializeInfo,{autoTx_ref:true})

//or use chapa.genrateTxRef() to store the tx_ref
const tx_ref = chapa.generateTxRef();

const initializeInfo = {
  amount: "1000",
  currency: "ETB",
  email: "[email protected]",
  first_name: "Abebe",
  last_name: "Kebede",
  tx_ref:tx_ref,
  return_url: "the return url after payment",
  callback_url: "https://myapp.com/my-verify-endpoint/:tx_ref",
};

  //subaccount

  //create
  const subaccountId = chapa.createSubAccount({
      bank_code: '32735b19-bb36-4cd7-b226-fb7451cd98f0',
      business_name: 'shaka',
      account_name: 'shaka',
      account_number: '12345678',
      split_type: 'flat',
      split_value: 2,
    });

  // you can store this subAccount id for future use

  //split payment with subAccount
  const subAccountsInfo = [{
  id:subaccountId,
  /*The id is enough but you can also override the default setting
  like split type and split value like this
      split_type:"flat",
      split_value:20
  */
}];

chapa
  .initialize({...initializeInfo,subaccounts:subAccountsInfo})
  .then((response) => {
    console.log(response);
    /*if initialization was successfull the response will look like this
        {
        "message": "Hosted Link",
        "status": "success",
        "data": {
            "checkout_url": "https://checkout.chapa.co/checkout/payment/27291184910"
        }

        redirect users to this 'checkout_url' to complete the transaction
    */
  })
  .catch((error) => {
    console.log(error);
  });

//verify payment
chapa
  .verify("tx_ref")
  .then((response) =>
    /*after verifing the transaction, do your logic.*/ console.log(response)
  )
  .catch((error) => console.log(error));

//get banks
chapa
  .getBanks()
  .then((banks) =>
    /*supported banks with their bank code for transfer*/ console.log(banks)
  )
  .catch((err) => console.log(err));

//transfer money
const transferInfo = {
  account_name: "Abebe Kebede",
  account_number: "32423423",
  amount: "100",
  currency: "ETB",
  beneficiary_name: "Kebede Abebe",
  reference: "3241342142sfdd" //This a merchant’s uniques reference for the transfer, it can be used to query for the status of the transfe,
  bank_code: "fe087651-4910-43af-b666-bbd393d8e81f" //from the getBanks,
};

chapa
  .transfer(transferInfo)
  .then((response) => {
    console.log(response);
  })
  .catch((error) => console.log(error));

More Information

Visit https://chapa.co/