This API is used to enable you to top up your service wallet via MPESA
You will make a POST request as described below and the phone number you provided will get an MPESA prompt to enter PIN to complete the top-up request to your service wallet.
API Method
This endpoint enables you to top up your service wallet on DarajaPay
POSThttps://darajapay.com/api/v1/topup
Headers
Name
Type
Description
Authorization:*
String
Basic basicAuthToken
Request Body
Name
Type
Description
amount*
Integer
Pass in the amount you want to top up eg: 100
phone_number*
String
Pass in the phone number that will be used to facilitate the top up payment via MPESA eg: 0787677676
Response
200: OK Upon successful request you will get the below JSON response
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
var client = new HttpClient();
var url = "https://darajapay.com/api/v1/wallets/top-up";
var data = new
{
amount = 100,
phone = "254712345678",
wallet_type = "service_wallet",
reference = "TOP001",
callback_url = "https://your-domain.com/callback"
};
client.DefaultRequestHeaders.Add("Authorization", "Basic YOUR_API_KEY");
var json = JsonSerializer.Serialize(data);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync(url, content);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}