LokiPayLokiPay Docs
v*.*.* Latest

Payments made seamless.

Reliable Mobile Money verification for your apps. Accept payments from MTN, Telecel, and AirtelTigo instantly with our robust SDK.

Dashboard Website

Installation

Install via your favorite package manager.

bash
npm install lokipay-sdk
yarn add lokipay-sdkpnpm add lokipay-sdk

Authentication

Initialize the library with your Secret Key. You can find this in your Dashboard Settings. Never expose your secret key on the client-side.

lib/lokipay.ts
typescript
import { LokiPay } from 'lokipay-sdk';

export const lokipay = new LokiPay({
  secretKey: process.env.LOKIPAY_SECRET_KEY as string,
  // Optional: Custom merchant config if not using defaults
  merchant: {
     mtnMerchantCode: '190638'
  }
});
POST

Create Order

Initiate a transaction. This creates a pending order in the system which you can then ask the user to pay for.

Parameters

NameTypeDescription
phonestringThe payer's mobile number (e.g., 0551234567)
amountnumberAmount in GHS.
descriptionstringOptional note for the order.
typescript
const result = await lokipay.createOrder({
  phone: "0551234567",
  amount: 150.00,
  description: "Electronics Store Order #12345"
});

console.log(result.order);
// {
//   orderId: "ord_82910",
//   vfmReference: "LP-82910",
//   status: "pending",
//   instructions: { ... }
// }

Poll Payment Status

Use the builtin waitForPayment helper to automatically check status until completion.

typescript
// Check every 5 seconds for up to 10 minutes
const status = await lokipay.waitForPayment(result.order.orderId, {
   intervalMs: 5000,
   timeoutMs: 600000,
   onStatusChange: (status) => {
      console.log('Current status:', status.status);
   }
});

if (status.status === 'confirmed') {
   console.log("✅ Payment received!");
}
NEW

React Component

The SDK exports a pre-built LokiPayCheckout component that handles the entire payment flow for you.

components/Payment.tsx
tsx
import { LokiPay } from 'lokipay-sdk';
import { LokiPayCheckout } from 'lokipay-sdk/react';

const lokipay = new LokiPay({
  secretKey: 'sk_live_...'
});

export default function Payment() {
  return (
    <div className="flex justify-center p-12">
      <LokiPayCheckout
        client={lokipay}
        amount={150.00}
        description="Premium Plan"
        onSuccess={(order) => {
          console.log('Payment Verified:', order);
          alert('Payment successful!');
        }}
        darkMode={false} // Toggle dark mode
        color="#30D158"  // Custom accent color
      />
    </div>
  );
}

Component Props

PropTypeRequiredDescription
clientLokiPayYesInitialized SDK instance.
amountnumberYesAmount to pay in GHS.
descriptionstringNoPayment description.
onSuccessfunctionNoCallback when payment is confirmed.
darkModebooleanNoForce dark mode style.
colorstringNoPrimary accent color (hex).

Webhooks

For production apps, we recommend listening to webhooks rather than holding a connection open. LokiPay sends a `POST` request to your URL when status changes.

!Security Note

Always verify the X-LokiPay-Signature header to ensure the request is genuinely from us.

Payload Example
json
{
  "event": "payment.confirmed",
  "data": {
    "order_id": "ord_12345",
    "status": "confirmed",
    "amount": 150.00,
    "transaction": {
       "id": "trans_99182",
       "sender": "John Doe",
       "reference": "72819102"
    }
  }
}

Need Help?