PAY HERO DOCS
  • Introduction-Pay Hero Developer APIs
  • Creating Account
  • Authorization
  • GET: Service Wallet Balance
  • GET: Payments Wallet Balance
  • POST: Service Wallet Top Up
  • POST: Initiate MPESA STK Push Request
  • Payment Button
  • Lipwa Link
  • POST: Pay Hero Wallet- Withdraw To Mobile
  • GET: Account Transactions
  • GET: Transaction Status
  • WooCommerce Plugin
    • Plugin Installation
  • Shopify
  • Videos
  • Other Integrations
  • Email API Reference
    • Register SMTP
    • Send Email
    • Mail status
  • WhatsApp API Reference
    • Introduction
    • Getting Started
    • Send API Whats App Text
    • Bulk WhatsApp API Messaging
    • Bulk WhatsApp Using UI/CSV File
Powered by GitBook
On this page
  • API Method
  • This endoint enable you to top up your service wallet on Pay Hero
  • Code Sample

Was this helpful?

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

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

{
    "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;
PreviousGET: Payments Wallet BalanceNextPOST: Initiate MPESA STK Push Request

Last updated 9 months ago

Was this helpful?