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

qena-ai

v1.0.0

Published

TypeScript SDK for Kifiya (Qena) digital lending API integration

Downloads

6

Readme

LinkPharm Kifiya Payment Integration

A TypeScript service for integrating Kifiya (Qena) digital lending API into the LinkPharm platform, built with Bun.

Overview

This service provides a complete implementation of the Kifiya third-party API, including customer management, loan offers, credit operations, disbursement, and repayment functionality.

Documentation

Official Kifiya API Documentation: https://qena-digital-lending.github.io/qena-third-party-api-docs/

Installation

bun install

Configuration

Create a .env file in the root directory with your Kifiya credentials:

API_KEY=your-api-key-here
BASE_URL=http://api-qena-test.qena.dev
PRODUCT_ID=your-product-id-here

Project Structure

kifiya-types.ts      - TypeScript type definitions for all API requests/responses
kifiya-service.ts    - Main service class with all API endpoints
example-usage.ts     - Usage examples for all endpoints
index.ts            - Entry point

Quick Start

# Run the main service
bun index.ts

# Run examples
bun example-usage.ts

Usage

Import the Service

import { kifiyaService } from './kifiya-service';

Customer Management

// Create a new customer
const customer = await kifiyaService.createCustomer({
  phone: '+251911234567',
  fullName: 'John Doe',
  email: '[email protected]',
  birthDate: '1990-01-15',
  gender: 'MALE',
  // ... other required fields
});

// List customers
const customers = await kifiyaService.listCustomers(10, 0);

// Get customer details
const customer = await kifiyaService.getCustomer(customerId);

// Get customer accounts
const accounts = await kifiyaService.getCustomerAccounts(customerId);

Loan Offers

// Request loan offers
const offerRequest = await kifiyaService.createOffer({
  customerId: 'customer-id',
  callbackUrl: 'https://your-app.com/callback',
});

// Get available offers
const offers = await kifiyaService.getOffers(customerId);

// Choose an offer
const chosenOffer = await kifiyaService.chooseOffer(customerId, {
  loanProductId: 'product-id',
  action: 'ACCEPTED',
});

// Update offer amount
const updated = await kifiyaService.updateOffer({
  customerId: 'customer-id',
  loanId: 'loan-id',
  offerAmount: 15000,
});

Credit Operations

// Create a loan
const loan = await kifiyaService.createLoan({
  customerId: 'customer-id',
  loanProductId: kifiyaService.getProductId(),
  offerAmount: 10000,
  interestRate: 15.5,
  duration: 12,
});

// Accept a loan
const accepted = await kifiyaService.acceptLoan({
  loanProductId: 'product-id',
  customerId: 'customer-id',
  loanId: 'loan-id',
  action: 'ACCEPTED',
});

// Set disbursement account
const account = await kifiyaService.setDisbursementAccount({
  loanId: 'loan-id',
  customerAccountNumber: '1000123456789',
});

// Get loan details
const loanDetails = await kifiyaService.getLoan(customerId, loanId);

Disbursement

// Disburse a loan
const disbursement = await kifiyaService.disburseLoan({
  loanId: 'loan-id',
  customerId: 'customer-id',
});

Repayment

// Make a payment
const payment = await kifiyaService.makePayment({
  customerId: 'customer-id',
  loanId: 'loan-id',
  repaymentAmount: 5000,
  hashedAccountNumber: 'hashed-account',
});

Complete Workflow

The service includes a helper method to complete the entire loan workflow:

const result = await kifiyaService.completeLoanWorkflow({
  customerId: 'customer-id',
  callbackUrl: 'https://your-app.com/callback',
  loanProductId: kifiyaService.getProductId(),
  customerAccountNumber: '1000123456789',
  merchantAccountNumber: 'optional-merchant-account',
});

This will:

  1. Create an offer request
  2. Retrieve available offers
  3. Choose an offer
  4. Accept the loan
  5. Set the disbursement account
  6. Disburse the loan

API Endpoints

Customer Endpoints

  • POST /api/v1/customers/ - Register a new customer
  • GET /api/v1/customers/ - List all customers
  • GET /api/v1/customers/{customerId} - Get customer details
  • GET /api/v1/customers/{customerId}/accounts - Get customer accounts
  • GET /api/v1/customers/accounts/?accountNumber={accountNumber} - Look up customer by account

Offer Endpoints

  • POST /api/v1/offers/ - Request a loan offer
  • GET /api/v1/offers/{customerId} - Get current offers
  • PUT /api/v1/offers/{customerId} - Accept/reject an offer
  • PUT /api/v1/offers/updateOffer - Update offer parameters
  • PUT /api/v1/offers/{customerId}/{loanId}/changeAmount - Change loan amount (deprecated)

Credit Endpoints

  • POST /api/v1/credits/loan - Create a new loan
  • POST /api/v1/credits/acceptLoan - Accept a loan offer
  • POST /api/v1/credits/disbursementAccount - Set disbursement account
  • GET /api/v1/credits/loan/{customerId}/{loanId} - Get loan details

Disbursement Endpoints

  • POST /api/v1/finances/disburse - Disburse a loan

Repayment Endpoints

  • POST /api/v1/credits/pay - Process loan repayment

Error Handling

All methods throw a KifiyaError object on failure:

try {
  const customer = await kifiyaService.getCustomer(customerId);
} catch (error) {
  const kifiyaError = error as KifiyaError;
  console.error('Error:', kifiyaError.message);
  console.error('Code:', kifiyaError.errorCode);
  console.error('Severity:', kifiyaError.severity);
}

Type Safety

The service is fully typed with TypeScript. Import types as needed:

import type {
  Customer,
  CreateCustomerRequest,
  LoanOffer,
  PaymentResponse
} from './kifiya-types';

Development

Built with Bun - a fast all-in-one JavaScript runtime.

# Run with hot reload
bun --hot index.ts

# Run tests (when added)
bun test

License

Private - LinkPharm Platform