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

kobara

v1.0.0

Published

Official Node.js SDK for Kobara API - MonCash payments and withdrawals integration

Readme

Kobara Node.js SDK

Official Node.js library for integrating the Kobara API. This SDK enables quick integration of secure MonCash payments, payment links, webhooks, and manual withdrawal requests.


Installation

Install the package via npm:

npm install kobara

Or via yarn:

yarn add kobara

Configuration

Initialize the client with your secret API key. Never expose your secret key on the client side.

import { Kobara } from "kobara";

const kobara = new Kobara({
  secretKey: process.env.KOBARA_SECRET_KEY,
});

To configure a different base URL (for example, for testing environment):

const kobara = new Kobara({
  secretKey: process.env.KOBARA_SECRET_KEY,
  baseUrl: "https://api.kobara.app/api/v1" // Optional
});

Usage Examples

1. Payments

Create a Payment

Create a new payment transaction with optional metadata and a custom idempotency key to prevent double charging.

try {
  const payment = await kobara.payments.create({
    amount: 2500,
    currency: "HTG",
    description: "Order #89457",
    customer: {
      name: "Jean Exemple",
      email: "[email protected]",
      phone: "50900000000"
    },
    metadata: {
      internal_order_id: "ORD-89457"
    },
    success_url: "https://monsite.com/success",
    error_url: "https://monsite.com/error",
    webhook_url: "https://monsite.com/webhooks/kobara"
  }, {
    idempotencyKey: "unique-idempotency-key-value" // Optional
  });

  console.log("Checkout URL:", payment.checkout_url);
} catch (error) {
  console.error("Payment creation failed:", error.message);
}

Retrieve a Payment

Get the status and details of a specific payment transaction by its ID:

const payment = await kobara.payments.retrieve("payment_id");
console.log("Payment status:", payment.status);

List Payments

List recent payment transactions with optional limit and filter by status:

const response = await kobara.payments.list({
  limit: 10,
  status: "succeeded"
});

console.log("Total payments fetched:", response.data.length);

2. Payment Links

Create a Payment Link

Generate reusable, shareable payment links:

const link = await kobara.paymentLinks.create({
  title: "Ebook Tailwind CSS",
  description: "Ebook premium en format PDF",
  amount: 500,
  currency: "HTG"
});

console.log("Payment Link URL:", link.url);

List Payment Links

const response = await kobara.paymentLinks.list({
  limit: 5
});

3. Withdrawals

Request a Withdrawal

Request a manual payout to your MonCash or Bank account:

const withdrawal = await kobara.withdrawals.create({
  amount: 5000,
  method: "moncash",
  reference: "50937012345"
});

console.log("Withdrawal ID:", withdrawal.id);

Retrieve a Withdrawal

const withdrawal = await kobara.withdrawals.retrieve("withdrawal_id");

4. Webhooks Verification

Securely verify that incoming webhook requests are genuinely sent by Kobara using HMAC SHA-256 validation.

import express from "express";
import { Kobara } from "kobara";

const app = express();
const kobara = new Kobara({ secretKey: process.env.KOBARA_SECRET_KEY });

// webhook route must receive raw body string
app.post("/webhooks/kobara", express.raw({ type: "application/json" }), (req, res) => {
  const signature = req.headers["kobara-signature"];
  const secret = process.env.KOBARA_WEBHOOK_SECRET;

  try {
    const event = kobara.webhooks.constructEvent(
      req.body.toString(),
      signature,
      secret
    );

    console.log("Verified Event:", event.type);
    
    if (event.type === "payment.succeeded") {
      const payment = event.data.payment;
      // Deliver services
    }

    res.status(200).send({ received: true });
  } catch (err) {
    console.error("Webhook signature verification failed:", err.message);
    res.status(400).send(`Webhook Error: ${err.message}`);
  }
});

Error Handling

This SDK throws subclasses of KobaraError to help you identify failures quickly:

  • KobaraAPIError: For errors returned by the Kobara API endpoints (HTTP response statuses 4xx, 5xx).
  • KobaraSignatureVerificationError: Thrown by webhooks.constructEvent() when signature verification fails.
import { KobaraAPIError } from "kobara";

try {
  await kobara.payments.retrieve("non-existent-id");
} catch (error) {
  if (error instanceof KobaraAPIError) {
    console.error("API error status:", error.statusCode); // e.g. 404
  } else {
    console.error("Generic network error:", error.message);
  }
}

License

MIT License. See LICENSE for details.