Code Examples
Integration examples in multiple programming languages. Copy and adapt these examples to integrate LakiPay into your application.
Node.js - Payment API
const axios = require('axios');
async function processPayment() {
try {
const response = await axios.post(
'https://api.lakipay.co/api/v2/payment/direct',
{
amount: 100.00,
currency: 'ETB',
phone_number: '+251911234567',
medium: 'MPESA',
description: 'Payment for order #12345',
reference: 'ORDER-12345',
callback_uri: 'https://yourwebsite.com/webhook'
},
{
headers: {
'Content-Type': 'application/json',
'X-API-Key': 'your-api-key-here'
}
}
);
console.log('Payment initiated:', response.data);
return response.data;
} catch (error) {
console.error('Payment failed:', error.response?.data);
throw error;
}
}