SDK Integration

Official SDKs for integrating LakiPay into your applications. Choose your preferred language and get started in minutes with our easy-to-use SDKs.

Overview

LakiPay provides official SDKs for multiple programming languages to simplify integration with our payment API. All SDKs provide a consistent interface for processing payments, withdrawals, and hosted checkout.

Supported Languages

Go, JavaScript/TypeScript, Python, PHP

Features

Direct payments, withdrawals, hosted checkout, transaction details

Code Examples

Select a language to view installation and usage examples:

lakipay-js-sdk

JavaScript/TypeScript SDK for Node.js backends and serverless functions.

Requirements

Node.js >= 14.0.0, TypeScript >= 4.0.0 (optional). Do not expose API keys in browser code.

Installation

npm install lakipay-js-sdk
# or
yarn add lakipay-js-sdk
# or
pnpm add lakipay-js-sdk
# or
npm install github:lakipay-co/lakipay-js-sdk

Initialization

import { LakipaySDK } from "lakipay-js-sdk";

const sdk = new LakipaySDK({
  apiKey: "pk_test_xxx:sk_test_xxx", // PUBLICKEY:SECRETKEY
  environment: "production",            
  timeoutMs: 20000,
  logRequests: true,
});

Direct Payment

const res = await sdk.payments.createDirectPayment({
  amount: 100.0,
  currency: "ETB",
  phone_number: "251 XX XXX XXXX",
  medium: "TELEBIRR",               // "MPESA" | "TELEBIRR" | "CBE" | ...
  description: "Payment for order #12345",
  reference: "ORDER-12345",
  callback_url: "https://yourwebsite.com/webhook",
});

console.log("-- Direct Payment Response --");
console.log(JSON.stringify(res, null, 2));
/* Expected Response:
{
  "status": "INITIATED",
  "result": "SUCCESS",
  "reference": "ORDER-12345",
  "transaction_id": "LP_TXN_...",
  "amount": 100.0,
  "currency": "ETB",
  "medium": "TELEBIRR"
}
*/

Withdrawal

const res = await sdk.payments.createWithdrawal({
  amount: 500.0,
  currency: "ETB",
  phone_number: "251 XX XXX XXXX",
  medium: "MPESA",                  // "MPESA" | "TELEBIRR" | "CBE" | ... 
  reference: "WITHDRAW-12345",
  callback_url: "https://yourwebsite.com/webhook",
});

console.log("-- Withdrawal Response --");
console.log(JSON.stringify(res, null, 2));
/* Expected Response:
{
  "status": "INITIATED",
  "result": "SUCCESS",
  "reference": "WITHDRAW-12345",
  "transaction_id": "LP_WD_...",
  "amount": 500.0,
  "currency": "ETB",
  "medium": "MPESA"
}
*/

Hosted Checkout

const res = await sdk.payments.createHostedCheckout({
  amount: 1000.5,
  currency: "ETB",
  description: "Payment for order #123",
  reference: "ORDER123456",
  phone_number: "251 XX XXX XXXX",
  callback_url: "https://example.com/callback",
  redirects: {
    success: "https://example.com/success",
    failed: "https://example.com/failed",
  },
  supported_mediums: ["MPESA", "TELEBIRR", "CBE"],
});

console.log("-- Hosted Checkout Response --");
console.log(JSON.stringify(res, null, 2));
/* Expected Response:
{
  "checkout_url": "https://checkout.lakipay.co/pay/...",
  "reference": "ORDER123456",
  "status": "INITIATED"
}
*/

Transaction Details

const txn = await sdk.payments.getTransaction("TXN-123456789");

console.log("-- Transaction Detail --");
console.log(JSON.stringify(txn, null, 2));
/* Expected Response:
{
  "status": "COMPLETED",
  "amount": 1000.0,
  "currency": "ETB",
  "reference": "TXN-123456789",
  "transaction_id": "LP_TXN_...",
  "medium": "TELEBIRR"
}
*/

Common Features

Direct Payments

Process payments directly through supported providers (MPESA, TELEBIRR, CBE, ETHSWITCH, CYBERSOURCE).

  • • Support for ETB and USD currencies
  • • Real-time payment processing
  • • Automatic status updates via webhooks

Withdrawals

Initiate withdrawal requests to transfer funds from your LakiPay account.

  • • Multiple provider support
  • • Asynchronous processing
  • • Webhook notifications

Hosted Checkout

Create hosted checkout sessions that LakiPay renders for your customers.

  • • Multiple payment method selection
  • • Custom success/failure redirects
  • • Seamless user experience

Transaction Details

Retrieve full transaction information for reconciliation and status checking.

  • • Real-time status updates
  • • Complete transaction history
  • • Easy reconciliation

Next Steps