Skip to main content
This guide walks you through integrating the Bila SDK into your application. You’ll learn how to configure the SDK, manage accounts, initiate collections, and send payouts across local markets.

Overview

The Bila SDK provides a unified, type-safe interface to:

Collections

Accept mobile money payments from customers in Zambia and beyond.

Payouts & Transfers

Send funds to bank accounts and mobile money wallets with ease.

Account Management

Check balances and manage sub-wallets programmatically.

Webhooks

Receive real-time notifications for transaction status updates.

Installation


Configuration

Before making API calls, configure the SDK with your API credentials from the Bila Console. You can obtain your BILA_API_KEY from the dashboard under Settings → API Keys.
Never hardcode your API key in production code. Always use environment variables or a secure secrets manager.

Core Flows

1. Check Account Balance

Verify your wallet balance before initiating payouts.

2. Collect Mobile Money

Initiate a mobile money collection request from a customer. The customer receives a USSD push prompt on their phone to authorise the payment.

Check Collection Status

Poll or verify the status of a collection using its reference.

3. Send a Mobile Money Payout

Send funds directly to a recipient’s mobile money wallet.

4. Send a Bank Transfer

Send funds to a recipient’s bank account.

Webhook Integration

Use webhooks to receive real-time notifications when transactions are completed, failed, or updated - without polling the API.

Transfer Events

Create a Webhook

List Webhooks

Handling Webhook Events

When Bila sends an event to your endpoint, verify the signature and process the payload.
TypeScript

Complete Integration Example

Here’s a real-world example demonstrating the complete flow:
  1. Configure the SDK with your API credentials
  2. Retrieve your account balance
  3. Initiate a mobile money collection
  4. Set up a webhook to receive real-time status updates

Error Handling

All SDK methods may throw exceptions. Here are common error scenarios and how to handle them.

Best Practices

1

Secure Your Credentials

Always use environment variables or a secrets manager for API credentials. Never commit credentials to version control.
2

Implement Webhook Signature Verification

Always verify webhook signatures to ensure events are legitimately from Bila and haven’t been tampered with.
3

Handle Errors Gracefully

Implement proper error handling with retry logic for transient failures (5xx errors, rate limits).
4

Use Idempotent References

Always pass a unique reference on transfers and collections. This prevents duplicate transactions if a request is retried.
5

Use Webhooks Over Polling

Rely on webhook events for transaction status updates rather than polling the status endpoint repeatedly.

Next Steps

TypeScript SDK Reference

Full method-by-method reference for the TypeScript SDK.

API Reference

Explore the underlying REST API directly.

Webhooks Overview

Deep dive into webhook events and security.

Collections Guide

Learn more about mobile money collections.