POST: Service Wallet Top Up

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

POST https://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

JSON
{
    "success": true,
    "status": "QUEUED",
    "reference": "09b8794f-4da0-4c93-af9b-43bdcdb58ea2",
    "CheckoutRequestID": "ws_CO_15012024161614816708344101"
}

Code Examples

PHP
 100,
    'phone' => '254712345678',
    'wallet_type' => 'service_wallet',
    'reference' => 'TOP001',
    'callback_url' => 'https://your-domain.com/callback'
);

$headers = array(
    'Content-Type: application/json',
    'Authorization: Basic YOUR_API_KEY'
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);

echo $response;