A unified ecosystem for African payment providers, featuring both an SDK and MCP server for seamless integration.
This monorepo contains two main packages:
- afrimomo-sdk - TypeScript SDK for African payment providers
- afrimomo-mcp - Model Context Protocol server for AI assistants
- 🌍 Support for multiple African payment providers
- 🔒 Type-safe API with full TypeScript support
- 📚 Comprehensive documentation
- 🛠️ Easy to configure and use
- 🔄 Consistent error handling
- 🎯 Clean imports - no deep imports required
- 🤖 AI-powered payment operations via Claude Desktop
- 🛠️ 23 tools for comprehensive payment management
- 💳 Support for PayChangu and PawaPay
- 🔐 Environment-based configuration
- 📦 Easy installation via npm or npx
- PayChangu - Payment services in Malawi
- PawaPay - Mobile money payments across Africa
Before using the Afrimomo SDK, you'll need to create accounts with the payment providers:
- Visit PawaPay and create a developer account
- Complete the onboarding process and verification
- Get your API token from the PawaPay dashboard
- Note your environment (sandbox for testing, production for live transactions)
- Visit PayChangu and create a merchant account
- Complete the business verification process
- Get your secret key from the PayChangu merchant dashboard
- Configure your webhook URLs for payment notifications
npm install afrimomo-sdk
# or
pnpm add afrimomo-sdk
# or
yarn add afrimomo-sdk# Global installation
npm install -g afrimomo-mcp
# Or use with npx (no installation required)
npx afrimomo-mcpSee afrimomo-mcp documentation for configuration details.
import { AfromomoSDK } from "afrimomo-sdk";
const sdk = new AfromomoSDK({
environment: "sandbox", // Use "sandbox" for testing, "production" for live
pawapay: {
apiToken: "your-pawapay-api-token" // Get this from PawaPay dashboard
},
paychangu: {
secretKey: "your-paychangu-secret-key" // Get this from PayChangu dashboard
}
});
// Use PawaPay
const paymentResponse = await sdk.pawapay.payments.initiate({
depositId: "unique-deposit-id",
amount: "100.00",
msisdn: "260123456789", // Customer's phone number
returnUrl: "https://your-app.com/callback",
statementDescription: "Payment for services",
language: "EN",
country: "ZMB", // ISO country code
reason: "Service payment"
});
// Use PayChangu
const operatorsResponse = await sdk.paychangu.getMobileMoneyOperators();Note: Always use sandbox/test credentials during development. Switch to production credentials only when you're ready to process real payments.
All types are available from the main package import - no deep imports needed:
// ✅ Correct way
import type {
ActiveConfigResponse,
PayChanguOperatorsResponse,
PayChanguTypes
} from "afrimomo-sdk";
// ❌ Avoid deep imports (old way)
import type { ActiveConfigResponse } from "afrimomo-sdk/dist/services/pawapay/types/network";For a comprehensive guide on importing types, see TYPE_IMPORTS.md.
import { AfromomoSDK } from "afrimomo-sdk";
import type {
ActiveConfigResponse,
PaymentTransaction,
WalletBalance
} from "afrimomo-sdk";
const sdk = new AfromomoSDK({
environment: "sandbox",
pawapay: {
apiToken: "your-pawapay-token"
}
});
// Initiate a payment
const payment = await sdk.pawapay.payments.initiate({
depositId: "order-123",
returnUrl: "https://your-app.com/success",
statementDescription: "Online purchase",
amount: "50.00",
msisdn: "260971234567",
language: "EN",
country: "ZMB",
reason: "Payment for goods"
});
// Check network configuration
const config: ActiveConfigResponse = await sdk.pawapay.network.getActiveConfig();
// Get wallet balances
const balances: WalletBalance[] = await sdk.pawapay.wallets.getBalances();import type {
PayChanguOperatorsResponse,
PayChanguDirectChargePaymentResponse,
PayChanguTypes
} from "afrimomo-sdk";
const sdk = new AfromomoSDK({
environment: "sandbox",
paychangu: {
secretKey: "your-paychangu-secret"
}
});
// Get mobile money operators
const operators: PayChanguOperatorsResponse = await sdk.paychangu.getMobileMoneyOperators();
// Initiate direct charge payment
const payment: PayChanguDirectChargePaymentResponse = await sdk.paychangu.initiateDirectChargePayment({
amount: 1000,
currency: "MWK",
chargeId: "order-456",
accountInfo: {
email: "customer@example.com",
first_name: "John",
last_name: "Doe"
}
});
// Process transaction with namespace types
function processTransaction(transaction: PayChanguTypes.BaseTransaction) {
console.log(`Processing ${transaction.charge_id}: ${transaction.status}`);
}Both providers offer sandbox environments for testing:
PawaPay Sandbox:
- Use sandbox API tokens for testing
- Test with sandbox phone numbers provided in their documentation
- No real money is processed in sandbox mode
PayChangu Testing:
- Use test secret keys for development
- Test transactions won't affect real accounts
- Webhook URLs can point to local development servers (use ngrok for testing)
The SDK supports both sandbox and production environments:
import { Environment } from "afrimomo-sdk";
const sdk = new AfromomoSDK({
environment: Environment.SANDBOX, // or Environment.PRODUCTION
// ... provider configurations
});Security Tip: Never commit your production API keys to version control. Use environment variables or secure configuration management.
- Payment initiation and status tracking
- Payout processing with status monitoring
- Refund handling
- Wallet balance queries
- Network configuration and availability checks
- Full TypeScript support with comprehensive types
- Direct charge payments
- Mobile money payments
- Bank transfers and payouts
- Transaction verification
- Operator information retrieval
- Comprehensive error handling
This is a monorepo containing:
packages/sdk/- The Afrimomo SDK packagepackages/afrimomo-mcp/- The Afrimomo MCP Server packageexamples/- Usage examples and demostests/- Test suites.github/workflows/- GitHub Actions for CI/CD
To work with this project:
# Install dependencies
pnpm install
# Build all packages
pnpm build
# Run tests
pnpm test
# Run linting
pnpm lint
# Format code
pnpm formatThe project uses automated releases via GitHub Actions with separate workflows for each package:
Workflow: .github/workflows/release.yml
- Publish to npm as
afrimomo-sdk - Tags:
v{version}(e.g.,v1.0.0)
Workflow: .github/workflows/release-mcp.yml
- Publish to npm as
afrimomo-mcp - Tags:
afrimomo-mcp-v{version}(e.g.,afrimomo-mcp-v1.0.0)
patch- Bug fixes and small improvements (0.0.1 → 0.0.2)minor- New features (0.1.0 → 0.2.0)major- Breaking changes (1.0.0 → 2.0.0)beta- Pre-release versions (1.0.0 → 1.0.1-beta.1)
See Workflows README for detailed release instructions.
- Type Imports Guide - Complete guide for importing types
- API Documentation - Detailed API documentation
- Examples - Usage examples and demos
- MCP README - Overview and usage guide
- Installation Guide - Detailed setup instructions
- Changelog - Version history
- Workflows Guide - CI/CD and release process
Contributions are welcome! Please read our Contributing Guide for details on our code of conduct and the process for submitting pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.