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 endoint enable you to top up your service wallet on Pay Hero

POST https://backend.payhero.co.ke/api/v2/topup

Headers

Request Body

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

Code Sample

This represents PHP Curl example of how to make the request, you can implement this in your specific language of choice

<?php
$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://backend.payhero.co.ke/api/v2/topup',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "amount": 10,
    "phone_number": "0798988989"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: Basic 3A6anVoWFZrRk5qSVl0MGNMOERGMlR3dlhrQ0VWUWJHNDVVVnNaMEdDSw=='
  ),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;

Last updated